I’m new to ESPhome and Home Assistant. I am trying to make a weather station by replaceing the electronics of a cheap broken Sencor station. I wanted to add a display to the project to show some of the sensor data on the unit itself.
I’m using a Wemod D1-mini, a BME280 temperature, humidity and pressure sensor, an AS5600 magnetic sensor to get wind direction, and the original reed switches to get wind speed, and rainfall readings via pulse counters.
I also added a small OLED to display the sensor data, wich is wehere I encountered the problem. At first it was working somewhat. I gave id-s to the sensor data, and used
“it.printf(0, 0, id(my_font), “Temperature: %.1f°C, Humidity: %.1f%%”, id(temperature).state, id(humidity).state);”
to print the data to the display. It was working, but the data was overflowing the display, and I could not find sample code to display it in multiple lines. I duplicated the above line and modified the y position to 20. Now I had two lines owerflowing the display. I modified the first line to only display the temperature and the secound to display only the humidity. Then the first error appeared and ever since I can’t compile the yaml file. Even after reverting back to the original code wich was working before.
"INFO ESPHome 2024.8.3
INFO Reading configuration /config/esphome/weather-station.yaml…
ERROR Error while reading config: Invalid YAML syntax:
while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/esphome/weather-station.yaml”, line 81, column 48
My config:
esphome:
name: weather-station
friendly_name: Weather Station
esp8266:
board: d1_mini
i2c:
sda: D2
scl: D1
scan: true
id: bus_a
frequency: 400kHz
font:
- file: "Roboto-Regular.ttf"
id: my_font
size: 12
as5600:
dir_pin: D5
start_position: 0deg
range: 180deg
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "9DeZgDupsiTXs3VnY5EpFo6xRgN7GlcEl0I0uCSjx/Y="
ota:
- platform: esphome
password: "449cfc6710e8f26524c5d0434d9f8b98"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Weather-Station Fallback Hotspot"
password: "VUpknRO75Y6X"
captive_portal:
sensor:
- platform: bme280_i2c
address: 0x76
temperature:
name: "BME280 Temperature"
id: temperature
pressure:
name: "BME280 Pressure"
id: pressure
humidity:
name: "BME280 Humidity"
id: humidity
update_interval: 10.0s
- platform: as5600
name: Position
raw_position:
name: Raw Position
gain:
name: Gain
magnitude:
name: Magnitude
status:
name: Status
update_interval: 10.0s
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
reset_pin: D0
address: 0x3C
update_interval: 0.25s
lambda: |-
it.printf(0, 0, id(my_font), "Temperature: %.1f°C, Humidity: %.1f%%", id(temperature).state, id(humidity).state);