Closed dedepene closed 3 years ago
After another round of attempts with more devices the takeaway so far is that only the AMICA branded boards are any good with the exact same config for the MHZ19. No dice with the rest :(
IME, the MHZ19 (is it a 'B'?) are really fussy with serial timing to the extent of you use logging above VERBOSE it doesn't work. Have you tried with just the UART configured and nothing else?
IME, the MHZ19 (is it a 'B'?) are really fussy with serial timing to the extent of you use logging above VERBOSE it doesn't work. Have you tried with just the UART configured and nothing else?
Yes, it's a "B", never tried anything above "DEBUG" with it anyway. With only UART config it will boot up and just chill - no error messages of any sort. How is this helping with troubleshooting?
You're using pins GPIO1 and GPIO3 - these are also the pins used for logging and the USB FTDI adapter.
Please use different pins or disable logging over UART with logger->baud_rate.
You're using pins GPIO1 and GPIO3 - these are also the pins used for logging and the USB FTDI adapter.
Please use different pins or disable logging over UART with logger->baud_rate.
Thanks for chiming in, Otto!
I did try:
logger:
baud_rate: 0
...but I'm still getting:
[09:02:52][E][uart:240]: Reading from UART timed out at byte 0!
[09:02:52][W][mhz19:034]: Reading data from MHZ19 failed!
Moving over to GPIO15 and GPIO13 did not help either :(
and, yup...without fail it works just fine on AMICA branded NodeMCUs - just flashed a fresh one. Every other one I have around (LoLin, noname etc.) is a no-go. With the Amica it's just fine on GPIO1 and GPIO3, no need to diasble logging over UART...
If it works with some NodeMCU boards and not with others, this is probably a hardware issue.
The MHZ19 operates at 5V if I remember correctly - and if the pins you're connecting it to on the ESP have pullups that might cause issues (see also https://github.com/esphome/issues/issues/812#issuecomment-549572377).
I'll leave the issue open for if you find a different solution, but otherwise I'm going to say this is not a software bug.
I've got the same problem with my AMICA NodeMCU.
logger:
baud_rate: 0
uart:
rx_pin: GPIO3
tx_pin: GPIO1
baud_rate: 9600
sensor:
- platform: mhz19
id: mhz19sensor
co2:
name: "MH-Z19 CO2 Value"
temperature:
name: "MH-Z19 Temperature"
update_interval: 60s
automatic_baseline_calibration: false
I've also tried switching GPIO1 and GPIO3 but I always get this error:
[19:43:02][C][uart:140]: UART Bus:
[19:43:02][C][uart:142]: TX Pin: GPIO1
[19:43:02][C][uart:145]: RX Pin: GPIO3
[19:43:02][C][uart:147]: Baud Rate: 9600 baud
[19:43:02][C][uart:148]: Stop bits: 1
[19:43:02][C][uart:150]: Using hardware serial interface.
[19:43:02][C][logger:175]: Logger:
[19:43:03][C][logger:176]: Level: DEBUG
[19:43:03][C][logger:177]: Log Baud Rate: 0
[19:43:03][C][logger:178]: Hardware UART: UART0
[19:43:03][C][mhz19:094]: MH-Z19:
[19:43:03][C][mhz19:095]: CO2 'MH-Z19 CO2 Value'
[19:43:03][C][mhz19:095]: Unit of Measurement: 'ppm'
[19:43:03][C][mhz19:095]: Accuracy Decimals: 0
[19:43:03][C][mhz19:095]: Icon: 'mdi:periodic-table-co2'
[19:43:03][C][mhz19:096]: Temperature 'MH-Z19 Temperature'
[19:43:03][C][mhz19:096]: Unit of Measurement: '°C'
[19:43:03][C][mhz19:096]: Accuracy Decimals: 0
[19:43:03][C][mhz19:096]: Icon: 'mdi:thermometer'
[19:43:45][E][uart:229]: Reading from UART timed out at byte 0!
[19:43:45][W][mhz19:034]: Reading data from MHZ19 failed!
I also tried getting 5v and ground from a different power supply.
I have no idea how to debug such problems and how to rule out hardware problems.
I have little bit different issue Im using ESP32 with MH-Z19B And weird thing is, ESP32 connects to a WiFi access point within 1 meter from it, if I put it in 5 meters it loses WiFi connection with MH-Z19B attached to it or unable to connect (No MH - no connect issue) Changed MH-Z19 sensors - same issue... Have changed power supplies (2-3A), even used StepUp module to make a little bit higher voltage (5.05v) for MH-Z19
If it works with some NodeMCU boards and not with others, this is probably a hardware issue.
The MHZ19 operates at 5V if I remember correctly - and if the pins you're connecting it to on the ESP have pullups that might cause issues (see also #812 (comment)).
I'll leave the issue open for if you find a different solution, but otherwise I'm going to say this is not a software bug.
Hi @OttoWinter, I am having identical issue with this. At that post, you suggest to disable FTDI adapter. Is it okay to avoid FTDI adapter by hardwire the UART from my device to GPIO1 and GPIO3? I mean hardwire is connecting to ESP12E pinout, not to the Wemos D1 pinhead. Thanks
I had loads of issues with this sensor and ESPHome. Ended up using Tasmota instead and it is rock solid. This was a while ago so things may be different now.
I have NodeMCU V3 and MH-Z19B. I have tried a lot of different GPIO pins, configurations, etc, but unfortunately, see:
22:52:09][E][uart:230]: Reading from UART timed out at byte 0! [22:52:09][W][mhz19:034]: Reading data from MHZ19 failed!
I have the same issue, but previously I tested the same hardware with ESPEasy firmware and everything was working fine, so this is not a hw issue in my case and I assume in general (@OttoWinter )
I have such configuration on esp8266 and it works but you have to disable uart logger as it's bound to the same pin.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I also had this problem after leaving a working esphome device unpowered for a long time. Ultimately the fix was to recalibrate the MHZ-19 by tying the HD pin to ground for 7 seconds. After restarting the device it worked again.
P.S. Doing this resets the calibration, so the device should be left in fresh air for 20 minutes afterwards.
GPIO16 && GPIO17 worked for me on a board like this:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Operating environment/Installation (Hass.io/Docker/pip/etc.):
hassio add-on ESP (ESP32/ESP8266, Board/Sonoff):
NodeMCU, ESP32 Affected component:
https://esphome.io/components/sensor/mhz19.html
Description of problem: The CO2 sensor won't connect on a variety of controllers - Nodemcus and ESP32. The very same sensor works fine on just this one NodeMCU with the exacts same settings across the board. Super weird - how do I even begin to troubleshoot?
Problem-relevant YAML-configuration entries:
Logs (if applicable):
Additional information and things you've tried: Again, the same sensor, with the exact same settings and wiring will work on just one nodemcu board (Amica), on every other board it fails to connect via UART?!
Here's the log from the nodemcu I was lucky with: