Hi All. I’ve got an AirGradient DIY Pro (pre-soldered) assembled and generally running well. I configured the YAML to be able to control the OLED display, able to send Turn On/Off as a command, and control Contrast levels. In general the board is working well, sensors are updating fine, and logs seem all fine.
Every few hours though, if I have turned the OLED display off, it turns back on. In Home Assistant, the switch for the display control goes ‘Unavailable’ at this point, as though something disconnected from the Home Assistant API. The sensors don’t appear to suffer the same outage, leading me to suspect it’s solely the display acting up.
However, I’m fairly clueless as to what could be going on. There’s enough layers of abstraction between the display hardware & the results that it’s not clear how to diagnose further, especially since ESPhome doesn’t seem to preserve logs over long periods.
Any thoughts or advice from those more familiar with the hardware side of things, or ESPhome, would be appreciated.
ESPhome YAML
esphome:
name: "${devicename}"
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
# name_add_mac_suffix: true
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_update_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: .lan
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${upper_devicename_ap_ssid}"
password: !secret ap_fallback_password
captive_portal:
# Use keep_user_credentials when available
i2c:
sda: D2
scl: D1
#setup_priority: -100 If wifi has issues
text_sensor:
- platform: wifi_info
ip_address:
name: "${upper_devicename} IP address"
icon: mdi:ip-network-outline
ssid:
name: "${upper_devicename} SSID"
icon: mdi:wifi
- platform: version
name: "${upper_devicename} ESPHome Version"
icon: mdi:chip
switch:
- platform: safe_mode
name: "${upper_devicename} Flash Mode (Safe Mode)"
- platform: restart
name: "${upper_devicename} Restart"
- platform: template
name: "${upper_devicename} Display"
lambda: return id(main_screen).is_on();
turn_on_action:
- lambda: id(main_screen).turn_on();
turn_off_action:
- lambda: id(main_screen).turn_off();
uart:
- rx_pin: D5
tx_pin: D6
baud_rate: 9600
id: uart1
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: uart2
sensor:
- platform: sht3xd
temperature:
id: temp
name: "${upper_devicename} Temperature"
icon: mdi:home-thermometer-outline
humidity:
id: humidity
name: "${upper_devicename} Humidity"
icon: mdi:water-percent
address: 0x44
update_interval: 5s
- platform: senseair
uart_id: uart2
co2:
id: co2
name: "${upper_devicename} SenseAir CO2 Value"
icon: mdi:molecule-co2
update_interval: 30s
# - platform: sgp4x
# voc:
# name: "${upper_devicename} VOC Index"
# nox:
# name: "${upper_devicename} NOx Index"
# compensation:
# humidity_source: humidity
# temperature_source: temp
- platform: pmsx003
type: PMSX003
uart_id: uart1
update_interval: 60s # Improves lifetime of sensor
pm_1_0:
name: "${upper_devicename} Particulate Matter <1.0µm Concentration Atmospheric"
id: pm_1_0
icon: mdi:smoke
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
pm_2_5:
name: "${upper_devicename} Particulate Matter <2.5µm Concentration Atmospheric"
id: pm_2_5
icon: mdi:smoke
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
pm_10_0:
name: "${upper_devicename} Particulate Matter <10.0µm Concentration Atmospheric"
id: pm_10_0
icon: mdi:smoke
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
pm_0_3um:
name: "${upper_devicename} Particulate Count >0.3µm"
id: pm_0_3um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
pm_0_5um:
name: "${upper_devicename} Particulate Count >0.5µm"
id: pm_0_5um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
pm_1_0um:
name: "${upper_devicename} Particulate Count >1.0µm"
id: pm_1_0um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
pm_2_5um:
name: "${upper_devicename} Particulate Count >2.5µm"
id: pm_2_5um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
pm_5_0um:
name: "${upper_devicename} Particulate Count >5.0µm"
id: pm_5_0um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
pm_10_0um:
name: "${upper_devicename} Particulate Count >10.0µm"
id: pm_10_0um
icon: mdi:counter
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 45
number:
- platform: template
name: "${upper_devicename} Display Contrast"
id: "main_screen_contrast"
icon: mdi:brightness-percent
step: 0.01
min_value: 0
max_value: 1
mode: slider
initial_value: 1
# Bug with ESPHome, contrast is protected, so can't be retrieved in a lambda
set_action:
then:
- lambda: id(main_screen).set_contrast(x);
font:
- file: "font/Product Sans Regular.ttf"
id: font_product
size: 32
glyphs: |
0123456789 .
- file: "font/Roboto-Light.ttf"
id: font_unit
size: 16
glyphs: |
!"%°CRH pmgµ³/
- file: "font/Roboto-Light.ttf"
id: font_label
size: 11
glyphs: |
HTPCD abcdeilmnoprstuxy
- file: "font/materialdesignicons-webfont.ttf"
id: font_icon
size: 38
glyphs: [
"", #CO2
"", #home thermometer outline
"", #water percent
"", #smoke
]
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
rotation: "180°"
id: main_screen
pages:
- id: page1
lambda: |-
it.printf(84, 72, id(font_product), TextAlign::BOTTOM_RIGHT, "%.1f", id(temp).state);
it.printf(84, 64, id(font_unit), TextAlign::BOTTOM_LEFT, "°C");
it.printf(128, 0, id(font_icon), TextAlign::TOP_RIGHT, "");
it.printf(86, 12, id(font_label), TextAlign::TOP_RIGHT, "Temperature");
- id: page2
lambda: |-
it.printf(84, 72, id(font_product), TextAlign::BOTTOM_RIGHT, "%.1f", id(humidity).state);
it.printf(84, 64, id(font_unit), TextAlign::BOTTOM_LEFT, "%% RH");
it.printf(128, 0, id(font_icon), TextAlign::TOP_RIGHT, "");
it.printf(86, 12, id(font_label), TextAlign::TOP_RIGHT, "Humidity");
- id: page3
lambda: |-
it.printf(84, 72, id(font_product), TextAlign::BOTTOM_RIGHT, "%.0f", id(co2).state);
it.printf(84, 64, id(font_unit), TextAlign::BOTTOM_LEFT, "ppm");
it.printf(128, 0, id(font_icon), TextAlign::TOP_RIGHT, "");
it.printf(86, 12, id(font_label), TextAlign::TOP_RIGHT, "Carbon Dioxide");
- id: page4
lambda: |-
it.printf(84, 72, id(font_product), TextAlign::BOTTOM_RIGHT, "%.0f", id(pm_2_5).state);
it.printf(84, 64, id(font_unit), TextAlign::BOTTOM_LEFT, "µg/m³");
it.printf(128, 0, id(font_icon), TextAlign::TOP_RIGHT, "");
it.printf(86, 12, id(font_label), TextAlign::TOP_RIGHT, "Particulates");
interval:
- interval: 5s
then:
- display.page.show_next: main_screen
- component.update: main_screen