Hello!
Yesterday night I configured a ESP32 NodeMCU, with a AHT10 and BH1750 (Luminosity sensor), I wired up everything, and then I started to look for the ESPHome templates and I thought that was not going to work on the first attempt but to my surprise, it worked flawlessly. I was able to see temperature, humidity, and lx on my home assistant dashboard. I used this configuration:
esphome:
name: esp32node04
friendly_name: esp32node04
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxx="
ota:
- platform: esphome
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32node04"
password: "xxx"
captive_portal:
# Example configuration entry for ESP32
i2c:
sda: GPIO21
scl: GPIO22
scan: true
id: bus_a
binary_sensor:
- platform: gpio
pin: GPIO35
name: "PIR"
device_class: motion
sensor:
- platform: bh1750
name: "LUX"
address: 0x23
update_interval: 60s
- platform: aht10
variant: AHT10
# address: 0x38
temperature:
name: "TEMP"
humidity:
name: "HUM"
update_interval: 60s
After that is started thinking with filters, more specifically with throttle and delta, I wanted to have more responsive updates when detecting abrupt changes, so I set the update_interval to 1s and added this filter:
- platform: aht10
variant: AHT20
# address: 0x38
temperature:
name: "TEMP"
filters:
- or:
- throttle: 60s
- delta: .5
humidity:
name: "HUM"
filters:
- or:
- throttle: 60s
- delta: .5
update_interval: 1s
After that looks like my AHT10 stopped working, I tried a bunch of things:
- rewiring everything up again
- changed de variant from AHT10 to AHT20
- changed the frequency parameter under the i2c configuration to 100kHz and 200Hz (with both I got: Communication with AHT10 failed!)
- cleaned the build cache
- set the address manually
None of these attempts worked. When I initialize the ESP32 I can see the i2C device listed, but I never saw temperature or humidity readings again
[23:03:52][I][i2c.arduino:096]: Results from i2c bus scan:
[23:03:52][I][i2c.arduino:102]: Found i2c device at address 0x23 # bh1750
[23:03:52][I][i2c.arduino:102]: Found i2c device at address 0x38 # AHT10
I think that’s a good sign, the device is being recognized, but isn’t working and I don’t know what else I can test, For me the strangest part is that it was working before I started playing with filters… And on all my attempts the bh1750 never stopped working.
Someone have any idea about what is going on and what else I can try?
Thanks
Here is my full log by the way:
INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/esp32node04.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32node04 (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.6
|-- Wire @ 2.0.0
Compiling .pioenvs/esp32node04/src/main.cpp.o
Linking .pioenvs/esp32node04/firmware.elf
RAM: [= ] 12.5% (used 41088 bytes from 327680 bytes)
Flash: [===== ] 51.4% (used 944041 bytes from 1835008 bytes)
Building .pioenvs/esp32node/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/esp32node04/firmware.bin"], [".pioenvs/esp32node04/firmware.elf"])
Wrote 0xf7e30 bytes to file /data/build/esp32node04/.pioenvs/esp32node04/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/esp32node04/firmware.bin"], [".pioenvs/esp32node04/firmware.elf"])
========================= [SUCCESS] Took 21.01 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.107.38 port 3232...
INFO Connected to 192.168.107.38
INFO Uploading /data/build/esp32node04/.pioenvs/esp32node04/firmware.bin (949808 bytes)
Uploading: [============================================================] 100% Done...
INFO Upload took 9.49 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.1xx.xx.xx using esphome API
WARNING Can't connect to ESPHome API for esp32node04 @ 192.168.107.38: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.1xx.xx.xx', port=6053))]: [Errno 113] Connect call failed ('192.1xx.xx.xx', 6053) (SocketAPIError)
INFO Trying to connect to esp32node04 @ 192.168.107.xx in the background
INFO Successfully connected to esp32node04 @ 192.1xx.xx.xx in 0.012s
INFO Successful handshake with esp32node04 @ 192.1xx.xx.xx in 0.145s
[23:09:46][I][app:100]: ESPHome version 2024.12.4 compiled on Jan 27 2025, 23:08:14
[23:09:46][C][wifi:600]: WiFi:
[23:09:46][C][wifi:428]: Local MAC: xx:0A:xx:C6:xx:xx
[23:09:46][C][wifi:433]: SSID: [redacted]
[23:09:46][C][wifi:436]: IP Address: 192.1xx.xx.xx
[23:09:46][C][wifi:440]: BSSID: [redacted]
[23:09:46][C][wifi:441]: Hostname: 'esp32node04'
[23:09:46][C][wifi:443]: Signal strength: -54 dB ▂▄▆█
[23:09:46][C][wifi:447]: Channel: 1
[23:09:46][C][wifi:448]: Subnet: 255.255.255.0
[23:09:46][C][wifi:449]: Gateway: 192.1x.xx.xx
[23:09:46][C][wifi:450]: DNS1: x.x.x.x
[23:09:46][C][wifi:451]: DNS2: xx.xx.xx.xx
[23:09:46][C][logger:185]: Logger:
[23:09:46][C][logger:186]: Level: DEBUG
[23:09:46][C][logger:188]: Log Baud Rate: 115200
[23:09:46][C][logger:189]: Hardware UART: UART0
[23:09:46][C][i2c.arduino:071]: I2C Bus:
[23:09:46][C][i2c.arduino:072]: SDA Pin: GPIO21
[23:09:46][C][i2c.arduino:073]: SCL Pin: GPIO22
[23:09:46][C][i2c.arduino:074]: Frequency: 50000 Hz
[23:09:46][C][i2c.arduino:086]: Recovery: bus successfully recovered
[23:09:46][I][i2c.arduino:096]: Results from i2c bus scan:
[23:09:46][I][i2c.arduino:102]: Found i2c device at address 0x23
[23:09:46][I][i2c.arduino:102]: Found i2c device at address 0x38
[23:09:46][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'PIR'
[23:09:46][C][gpio.binary_sensor:015]: Device Class: 'motion'
[23:09:46][C][gpio.binary_sensor:016]: Pin: GPIO35
[23:09:46][C][bh1750.sensor:118]: BH1750 'LUX'
[23:09:46][C][bh1750.sensor:118]: Device Class: 'illuminance'
[23:09:46][C][bh1750.sensor:118]: State Class: 'measurement'
[23:09:46][C][bh1750.sensor:118]: Unit of Measurement: 'lx'
[23:09:46][C][bh1750.sensor:118]: Accuracy Decimals: 1
[23:09:46][C][bh1750.sensor:119]: Address: 0x23
[23:09:46][C][bh1750.sensor:124]: Update Interval: 10.0s
[23:09:46][C][aht10:162]: AHT10:
[23:09:46][C][aht10:163]: Address: 0x38
[23:09:46][C][aht10:167]: Temperature 'TEMP'
[23:09:46][C][aht10:167]: Device Class: 'temperature'
[23:09:46][C][aht10:167]: State Class: 'measurement'
[23:09:46][C][aht10:167]: Unit of Measurement: '°C'
[23:09:46][C][aht10:167]: Accuracy Decimals: 2
[23:09:46][C][aht10:168]: Humidity 'HUM'
[23:09:46][C][aht10:168]: Device Class: 'humidity'
[23:09:46][C][aht10:168]: State Class: 'measurement'
[23:09:46][C][aht10:168]: Unit of Measurement: '%'
[23:09:46][C][aht10:168]: Accuracy Decimals: 2
[23:09:46][C][captive_portal:089]: Captive Portal:
[23:09:46][C][mdns:116]: mDNS:
[23:09:46][C][mdns:117]: Hostname: esp32node04
[23:09:46][C][esphome.ota:073]: Over-The-Air updates:
[23:09:46][C][esphome.ota:074]: Address: esp32node04.local:3232
[23:09:46][C][esphome.ota:075]: Version: 2
[23:09:46][C][esphome.ota:078]: Password configured
[23:09:46][C][safe_mode:018]: Safe Mode:
[23:09:46][C][safe_mode:020]: Boot considered successful after 60 seconds
[23:09:46][C][safe_mode:021]: Invoke after 10 boot attempts
[23:09:46][C][safe_mode:023]: Remain in safe mode for 300 seconds
[23:09:46][C][api:140]: API Server:
[23:09:46][C][api:141]: Address: esp32node04.local:6053
[23:09:46][C][api:143]: Using noise encryption: YES
[23:09:50][D][bh1750.sensor:159]: 'LUX': Got illuminance=2.3lx
[23:09:50][D][sensor:094]: 'LUX': Sending state 2.26378 lx with 1 decimals of accuracy
[23:10:00][D][bh1750.sensor:159]: 'LUX': Got illuminance=2.3lx
[23:10:10][D][bh1750.sensor:159]: 'LUX': Got illuminance=2.3lx