I’ve connected two AM2302 temperature and humidity sensors to D1 and D2 (Wemos D1 mini ESP8266) with external Pull-Up resistors. To D3 with internal Pull-Up is a TACH signal of one fan connected, to D6 with an external Pull-Up resistor a second TACH signal. To D5 is finally the PWM output of one fan connected, the other fan doesn’t have PWM.
This works and at the same time doesn’t work, maybe somebody could point me what might be wrong?
After fresh “Install” from ESPHome I get the expected results in Home Assistant, but after a reboot of the ESP8266 the temperature and humidity sensors don’t work correct anymore and I don´t understand why. But it’s reproducable, every time I “Install” the code on the Wemos it works, after a reboot I get wrong results. Any ideas?
My guess is your choice of GPIO and external resistors is preventing the ESP from booting - try disconnecting the pins one by one and see if the uP boots.
Have a look at the reference table for GPIO usage:
Thanks for your ideas and hints. The Random Nerd Pinout reference I’ve used for selecting my Pins and thought it should fit. I guess the problem is not that it doesn’t boot, because for at least one TACH signal I get reasonable results with my described setup.
I’ve tested to replace D3 with D7, but the behavior stays the same, except that I don’t get results for that TACH anymore. With and without Pull-up
These are the results after fresh install. The second TACH is switched from D3 to D7 as you suggested, but in this setup I don’t get any value anymore for this signal, I’ve tried pull-up resistors with different values (10k, 5,1k, 670). In D3 (without external resistor) it works as it should.
INFO Reading configuration /config/esphome/[redacted].yaml...
INFO Starting log output from [redacted] using esphome API
INFO Successfully connected to [redacted]
[16:44:50][I][app:102]: ESPHome version 2022.8.3 compiled on Sep 20 2022, 16:33:17
[16:44:50][C][wifi:491]: WiFi:
[16:44:50][C][wifi:353]: Local MAC: [redacted]
[16:44:50][C][wifi:354]: SSID: [redacted]
[16:44:50][C][wifi:355]: IP Address: 192.168.0.245
[16:44:50][C][wifi:356]: BSSID: [redacted]
[16:44:50][C][wifi:358]: Hostname: [redacted]
[16:44:50][C][wifi:360]: Signal strength: -57 dB ▂▄▆█
[16:44:50][C][wifi:364]: Channel: 13
[16:44:50][C][wifi:365]: Subnet: 255.255.255.0
[16:44:50][C][wifi:366]: Gateway: [redacted]
[16:44:50][C][wifi:367]: DNS1: [redacted]
[16:44:50][C][wifi:368]: DNS2: [redacted]
[16:44:50][C][logger:275]: Logger:
[16:44:50][C][logger:276]: Level: DEBUG
[16:44:50][C][logger:277]: Log Baud Rate: 115200
[16:44:50][C][logger:278]: Hardware UART: UART0
[16:44:50][C][esp8266_pwm:022]: ESP8266 PWM:
[16:44:50][C][esp8266_pwm:023]: Pin: GPIO14
[16:44:50][C][esp8266_pwm:024]: Frequency: 20000.0 Hz
[16:44:50][C][dht:017]: DHT:
[16:44:50][C][dht:018]: Pin: GPIO5
[16:44:50][C][dht:020]: Auto-detected model: DHT22
[16:44:50][C][dht:027]: Update Interval: 5.0s
[16:44:50][C][dht:029]: Temperature 'Cell upper Temperature'
[16:44:50][C][dht:029]: Device Class: 'temperature'
[16:44:50][C][dht:029]: State Class: 'measurement'
[16:44:50][C][dht:029]: Unit of Measurement: '°C'
[16:44:50][C][dht:029]: Accuracy Decimals: 1
[16:44:50][C][dht:030]: Humidity 'Cell upper Humidity'
[16:44:50][C][dht:030]: Device Class: 'humidity'
[16:44:50][C][dht:030]: State Class: 'measurement'
[16:44:50][C][dht:030]: Unit of Measurement: '%'
[16:44:50][C][dht:030]: Accuracy Decimals: 0
[16:44:51][C][dht:017]: DHT:
[16:44:51][C][dht:018]: Pin: GPIO4
[16:44:51][C][dht:020]: Auto-detected model: DHT22
[16:44:51][C][dht:027]: Update Interval: 5.0s
[16:44:51][C][dht:029]: Temperature 'Cell lower Temperature'
[16:44:51][C][dht:029]: Device Class: 'temperature'
[16:44:51][C][dht:029]: State Class: 'measurement'
[16:44:51][C][dht:029]: Unit of Measurement: '°C'
[16:44:51][C][dht:029]: Accuracy Decimals: 1
[16:44:51][C][dht:030]: Humidity 'Cell lower Humidity'
[16:44:51][C][dht:030]: Device Class: 'humidity'
[16:44:51][C][dht:030]: State Class: 'measurement'
[16:44:51][C][dht:030]: Unit of Measurement: '%'
[16:44:51][C][dht:030]: Accuracy Decimals: 0
[16:44:51][C][pulse_counter:153]: Pulse Counter 'RPM big fan'
[16:44:51][C][pulse_counter:153]: State Class: 'measurement'
[16:44:51][C][pulse_counter:153]: Unit of Measurement: 'pulses/min'
[16:44:51][C][pulse_counter:153]: Accuracy Decimals: 2
[16:44:51][C][pulse_counter:153]: Icon: 'mdi:pulse'
[16:44:51][C][pulse_counter:154]: Pin: GPIO12
[16:44:51][C][pulse_counter:155]: Rising Edge: INCREMENT
[16:44:51][C][pulse_counter:156]: Falling Edge: DISABLE
[16:44:51][C][pulse_counter:157]: Filtering pulses shorter than 13 µs
[16:44:51][C][pulse_counter:158]: Update Interval: 3.0s
[16:44:51][C][pulse_counter:153]: Pulse Counter 'RPM small fan'
[16:44:51][C][pulse_counter:153]: State Class: 'measurement'
[16:44:51][C][pulse_counter:153]: Unit of Measurement: 'pulses/min'
[16:44:51][C][pulse_counter:153]: Accuracy Decimals: 2
[16:44:51][C][pulse_counter:153]: Icon: 'mdi:pulse'
[16:44:51][C][pulse_counter:154]: Pin: GPIO13
[16:44:51][C][pulse_counter:155]: Rising Edge: INCREMENT
[16:44:51][C][pulse_counter:156]: Falling Edge: DISABLE
[16:44:51][C][pulse_counter:157]: Filtering pulses shorter than 13 µs
[16:44:51][C][pulse_counter:158]: Update Interval: 3.0s
[16:44:51][C][speed.fan:016]: Speed Fan 'PWM Output Fan'
[16:44:51][C][speed.fan:147]: Speed: YES
[16:44:51][C][speed.fan:148]: Speed count: 100
[16:44:51][D][dht:048]: Got Temperature=25.0°C Humidity=51.7%
[16:44:51][D][sensor:126]: 'Cell lower Temperature': Sending state 25.00000 °C with 1 decimals of accuracy
[16:44:51][D][sensor:126]: 'Cell lower Humidity': Sending state 51.70000 % with 0 decimals of accuracy
[16:44:51][C][captive_portal:088]: Captive Portal:
[16:44:51][C][mdns:094]: mDNS:
[16:44:51][C][mdns:095]: Hostname: [redacted]
[16:44:51][C][ota:085]: Over-The-Air Updates:
[16:44:51][C][ota:086]: Address: [redacted]:8266
[16:44:51][C][ota:089]: Using Password.
[16:44:51][C][api:138]: API Server:
[16:44:51][C][api:139]: Address: [redacted]:6053
[16:44:51][C][api:141]: Using noise encryption: YES
[16:44:52][D][pulse_counter:167]: 'RPM small fan': Retrieved counter: 0.00 pulses/min
[16:44:52][D][sensor:126]: 'RPM small fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[16:44:52][D][dht:048]: Got Temperature=24.8°C Humidity=48.5%
[16:44:52][D][sensor:126]: 'Cell upper Temperature': Sending state 24.80000 °C with 1 decimals of accuracy
[16:44:52][D][sensor:126]: 'Cell upper Humidity': Sending state 48.50000 % with 0 decimals of accuracy
[16:44:52][D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 2781.85 pulses/min
[16:44:52][D][sensor:126]: 'RPM big fan': Sending state 1390.92725 pulses/min with 2 decimals of accuracy
[16:44:55][D][pulse_counter:167]: 'RPM small fan': Retrieved counter: 0.00 pulses/min
[16:44:55][D][sensor:126]: 'RPM small fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[16:44:55][D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 2783.71 pulses/min
[16:44:55][D][sensor:126]: 'RPM big fan': Sending state 1391.85583 pulses/min with 2 decimals of accuracy
[16:44:56][D][dht:048]: Got Temperature=25.0°C Humidity=51.7%
[16:44:56][D][sensor:126]: 'Cell lower Temperature': Sending state 25.00000 °C with 1 decimals of accuracy
[16:44:56][D][sensor:126]: 'Cell lower Humidity': Sending state 51.70000 % with 0 decimals of accuracy
...
With a reboot I get these logs
INFO [redacted]: Ping timed out!
INFO Disconnected from ESPHome API for [redacted]
WARNING Disconnected from API
INFO Successfully connected to [redacted]
[17:05:14][D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 2829.60 pulses/min
[17:05:14][D][sensor:126]: 'RPM big fan': Sending state 1414.80212 pulses/min with 2 decimals of accuracy
[17:05:15][D][pulse_counter:167]: 'RPM small fan': Retrieved counter: 0.00 pulses/min
[17:05:15][D][sensor:126]: 'RPM small fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[17:05:15][D][dht:048]: Got Temperature=-12.5°C Humidity=2.4%
[17:05:15][D][sensor:126]: 'Cell lower Temperature': Sending state -12.50000 °C with 1 decimals of accuracy
[17:05:15][D][sensor:126]: 'Cell lower Humidity': Sending state 2.40000 % with 0 decimals of accuracy
[17:05:16][D][dht:048]: Got Temperature=-12.2°C Humidity=24.0%
[17:05:16][D][sensor:126]: 'Cell upper Temperature': Sending state -12.20000 °C with 1 decimals of accuracy
[17:05:16][D][sensor:126]: 'Cell upper Humidity': Sending state 24.00000 % with 0 decimals of accuracy
...
I created a serial sensor in HA and it shows the logs as the fast changing state, but I don’t know how to get the full logs of that sensor.
I’ve connected it to my desktop with minicom, these are the logs after a Wemos reset
Log initialized
[C][ota:461]: There have been 4 suspected unsuccessful boot attempts.
[I][app:029]: Running through setup()...
[C][esp8266_pwm:017]: Setting up ESP8266 PWM Output...
[C][dht:011]: Setting up DHT...
[C][dht:011]: Setting up DHT...
[C][pulse_counter:140]: Setting up pulse counter 'RPM big fan'...
[C][pulse_counter:140]: Setting up pulse counter 'RPM small fan D7'...
[C][pulse_counter:140]: Setting up pulse counter 'RPM small fan D3'...
[D][fan:091]: 'PWM Output Fan' - Sending state:
[D][fan:092]: State: OFF
[D][fan:094]: Speed: 0
[C][wifi:037]: Setting up WiFi...
[D][wifi:373]: Starting scan...
[D][dht:048]: Got Temperature=23.9°C Humidity=55.3%
[D][sensor:126]: 'Cell lower Temperature': Sending state 23.90000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell lower Humidity': Sending state 55.30000 % with 0 decimals of accuracy
[D][dht:048]: Got Temperature=23.6°C Humidity=52.2%
[D][sensor:126]: 'Cell upper Temperature': Sending state 23.60000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell upper Humidity': Sending state 52.20000 % with 0 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D3': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D3': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][dht:048]: Got Temperature=23.9°C Humidity=55.7%
[D][sensor:126]: 'Cell lower Temperature': Sending state 23.90000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell lower Humidity': Sending state 55.70000 % with 0 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D7': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D7': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM big fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][dht:048]: Got Temperature=23.6°C Humidity=52.2%
[D][sensor:126]: 'Cell upper Temperature': Sending state 23.60000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell upper Humidity': Sending state 52.20000 % with 0 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D3': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D3': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D7': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D7': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM big fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][wifi:388]: Found networks:
[I][wifi:431]: - [redacted] ▂▄▆█
[D][wifi:433]: Channel: 13
[D][wifi:434]: RSSI: -54 dB
[D][wifi:436]: - [redacted] ▂▄▆█
[D][wifi:436]: - [redacted] ▂▄▆█
[I][wifi:248]: WiFi Connecting to [redacted]...
[I][wifi:505]: WiFi Connected!
[C][wifi:353]: Local MAC: [redacted]
[C][wifi:354]: SSID: [redacted]
[C][wifi:355]: IP Address: [redacted]
[C][wifi:356]: BSSID: [redacted]
[C][wifi:358]: Hostname: [redacted]
[C][wifi:360]: Signal strength: -59 dB ▂▄▆█
[C][wifi:364]: Channel: 13
[C][wifi:365]: Subnet: 255.255.255.0
[C][wifi:366]: Gateway: [redacted]
[C][wifi:367]: DNS1: [redacted]
[C][wifi:368]: DNS2: [redacted]
[D][wifi:514]: Disabling AP...
[C][ota:085]: Over-The-Air Updates:
[C][ota:086]: Address: [redacted]
[C][ota:089]: Using Password.
[W][ota:094]: Last Boot was an unhandled reset, will proceed to safe mode in 6 restarts
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2022.8.3 compiled on Sep 20 2022, 17:16:39
[C][wifi:491]: WiFi:
[C][wifi:353]: Local [redacted]
[C][wifi:354]: SSID: [redacted]
[C][wifi:355]: IP Address: [redacted]
[C][wifi:356]: BSSID: [redacted]
[C][wifi:358]: Hostname: [redacted]
[C][wifi:360]: Signal strength: -59 dB ▂▄▆█
[C][wifi:364]: Channel: 13
[C][wifi:365]: Subnet: 255.255.255.0
[C][wifi:366]: Gateway: [redacted]
[C][wifi:367]: DNS1: [redacted]
[C][wifi:368]: DNS2: [redacted]
[D][dht:048]: Got Temperature=23.9°C Humidity=55.6%
[D][sensor:126]: 'Cell lower Temperature': Sending state 23.90000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell lower Humidity': Sending state 55.60000 % with 0 decimals of accuracy
[C][logger:275]: Logger:
[C][logger:276]: Level: DEBUG
[C][logger:277]: Log Baud Rate: 115200
[C][logger:278]: Hardware UART: UART0
[C][esp8266_pwm:022]: ESP8266 PWM:
[C][esp8266_pwm:023]: Pin: GPIO14
[C][esp8266_pwm:024]: Frequency: 20000.0 Hz
[C][dht:017]: DHT:
[C][dht:018]: Pin: GPIO5
[C][dht:020]: Auto-detected model: DHT22
[C][dht:027]: Update Interval: 5.0s
[C][dht:029]: Temperature 'Cell upper Temperature'
[C][dht:029]: Device Class: 'temperature'
[C][dht:029]: State Class: 'measurement'
[C][dht:029]: Unit of Measurement: '°C'
[C][dht:029]: Accuracy Decimals: 1
[C][dht:030]: Humidity 'Cell upper Humidity'
[C][dht:030]: Device Class: 'humidity'
[C][dht:030]: State Class: 'measurement'
[C][dht:030]: Unit of Measurement: '%'
[C][dht:030]: Accuracy Decimals: 0
[C][dht:017]: DHT:
[C][dht:018]: Pin: GPIO4
[C][dht:020]: Auto-detected model: DHT22
[C][dht:027]: Update Interval: 5.0s
[C][dht:029]: Temperature 'Cell lower Temperature'
[C][dht:029]: Device Class: 'temperature'
[C][dht:029]: State Class: 'measurement'
[C][dht:029]: Unit of Measurement: '°C'
[C][dht:029]: Accuracy Decimals: 1
[C][dht:030]: Humidity 'Cell lower Humidity'
[C][dht:030]: Device Class: 'humidity'
[C][dht:030]: State Class: 'measurement'
[C][dht:030]: Unit of Measurement: '%'
[C][dht:030]: Accuracy Decimals: 0
[C][pulse_counter:153]: Pulse Counter 'RPM big fan'
[C][pulse_counter:153]: State Class: 'measurement'
[C][pulse_counter:153]: Unit of Measurement: 'pulses/min'
[C][pulse_counter:153]: Accuracy Decimals: 2
[C][pulse_counter:153]: Icon: 'mdi:pulse'
[C][pulse_counter:154]: Pin: GPIO12
[C][pulse_counter:155]: Rising Edge: INCREMENT
[C][pulse_counter:156]: Falling Edge: DISABLE
[C][pulse_counter:157]: Filtering pulses shorter than 13 µs
[C][pulse_counter:158]: Update Interval: 3.0s
[C][pulse_counter:153]: Pulse Counter 'RPM small fan D7'
[C][pulse_counter:153]: State Class: 'measurement'
[C][pulse_counter:153]: Unit of Measurement: 'pulses/min'
[C][pulse_counter:153]: Accuracy Decimals: 2
[C][pulse_counter:153]: Icon: 'mdi:pulse'
[C][pulse_counter:154]: Pin: GPIO13
[C][pulse_counter:155]: Rising Edge: INCREMENT
[C][pulse_counter:156]: Falling Edge: DISABLE
[C][pulse_counter:157]: Filtering pulses shorter than 13 µs
[C][pulse_counter:158]: Update Interval: 3.0s
[C][pulse_counter:153]: Pulse Counter 'RPM small fan D3'
[C][pulse_counter:153]: State Class: 'measurement'
[C][pulse_counter:153]: Unit of Measurement: 'pulses/min'
[C][pulse_counter:153]: Accuracy Decimals: 2
[C][pulse_counter:153]: Icon: 'mdi:pulse'
[C][pulse_counter:154]: Pin: GPIO0
[C][pulse_counter:155]: Rising Edge: INCREMENT
[C][pulse_counter:156]: Falling Edge: DISABLE
`[C][pulse_counter:157]: Filtering pulses shorter than 13 µs`
[C][pulse_counter:158]: Update Interval: 3.0s
[C][speed.fan:016]: Speed Fan 'PWM Output Fan'
[C][speed.fan:147]: Speed: YES
[C][speed.fan:148]: Speed count: 100
[C][captive_portal:088]: Captive Portal:
[C][mdns:094]: mDNS:
[C][mdns:095]: Hostname: [redacted]
[C][ota:085]: Over-The-Air Updates:
[C][ota:086]: Address: [redacted]:8266
[C][ota:089]: Using Password.
[W][ota:094]: Last Boot was an unhandled reset, will proceed to safe mode in 6 restarts
[C][api:138]: API Server:
[C][api:139]: Address: [redacted]:6053
[C][api:141]: Using noise encryption: YES
[D][api:102]: Accepted [redacted IP]
[D][pulse_counter:167]: 'RPM small fan D3': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D3': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][api.connection:861]: Home Assistant 2022.9.4 ([redacted IP]): Connected successfully
[D][pulse_counter:167]: 'RPM small fan D7': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D7': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM big fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][dht:048]: Got Temperature=23.6°C Humidity=51.9%
[D][sensor:126]: 'Cell upper Temperature': Sending state 23.60000 °C with 1 decimals of accuracy
[D][sensor:126]: 'Cell upper Humidity': Sending state 51.90000 % with 0 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D3': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D3': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM small fan D7': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM small fan D7': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][pulse_counter:167]: 'RPM big fan': Retrieved counter: 0.00 pulses/min
[D][sensor:126]: 'RPM big fan': Sending state 0.00000 pulses/min with 2 decimals of accuracy
[D][dht:048]: Got Temperature=23.9°C Humidity=55.6%
I hope that helps. Here I just made an additional pulse counter so I could change between the GPIOs without chaning the code.
Is this a problem?
[C][pulse_counter:157]: Filtering pulses shorter than 13 µs
It’s strange. If the Wemos is unplugged and then plugged again, it doesn’t send correct results. If the Wemos stays plugged in and is resetted by the button (or as in my first post flashed with the code), it works as it should.
Which of the pins are connected during boot and if D3 or D7 is used doesn’t change that behavior.
Any idea what could be the cause?
The absolute beginning of the startup I don’t get logged, as minicom and picocom complain about missing file if the USB is not yet plugged in and the reset button obviously gives different results. Any idea how to improve the logging?
I’ve also changed the Wemos, but the second Wemos behaves the same way
Yes, the two temperature sensors and the TACH reading are powered by the onboard LDO. This could indeed be the problem and a reasonable explanation of the error I’m confronted with.
Thanks for the link to the list of Wemos and other ESP8266 clones, I didn’t even know that my “Wemos” are clones. I’ve ordered some Lolin Boards now and will check once they are delivered to me … and hope it’s the solution.
With another (external) power supply the behavior kept the same.
Other microcontrollers with different LDOs didn’t change the behavior.
After these explorations I figured out it’s an issue with the ESPhome DHT Temperature+Humidity Sensor. Obviously it doesn’t recognize the correct Sensor (AM2302) when powered first. As mentioned in the documentation of ESPHome DHT, to manually specify the DHT model solved “some connection issue”
After adding model: AM2302 to the dht platform sensor it works fine