Closed orimate closed 6 years ago
I had exactly the same problems. I got the feeling that the MHZ19 is very picky with software serial ports. Running it on the hardware serial ports of devices seems to much better. After patching Tasmota to call Serial.Swap I was able to get it running stable with a Wemos using the alternative RX/TX ports.
Hi, thanks for the answer, then I'm not alone I calmed down. :) I have always used the RX / TX line. Where should I perform the patch?
Observed too.
If you are using the Sonoff TH, you should already be connected to the hardware serial, if I remember correctly. The problem occurred for me when using the wemos, where hardware serial is mapped to the USB port. On the wemos, I solved the problem by calling serial.swap.
Note that you need to deactivate logging so serial out completely if you connect the MHZ!
I also noticed the behavior when using a Wemos D1.
Now the test runs with 5.13 disabled SerialLog on NodeMCU board via TX / RX port. (GPIO1/3) @tobox "The problem occurred for me when using the wemos, where hardware serial is mapped to the USB port."<= I understood. "On the wemos, I solved the problem by calling serial.swap." <= Unfortunately, I'm not a programmer (not noob, but beginner) and I still do not know where I would like the serial.swap calling if I do not want to use sonoff.
I modified the Tasmota Source code to call Serial.Swap before initializing the MHZ driver. I don't remember exactly how I did it. I just compiled the firmware and it worked, so I did not bother to keep the source code of that file - sorry...
Wait! I will release an updated version today which might solve the lost info. Longer term testing is needed.
Ok I'll wait. After 2 hours result is equal = 0ppm. :(
Give it a try let me know your results.
Still fails on me :-(
On me since 4 hours is working. I let it run at night.
Afer 10 hours 0 ppm :(
Currently working on an optional hardware serial solution and see how that performs...
You might want to try the hardware serial option which is auto-enabled when the below settings are used:
Are the settings identical for the model MHZ-19B as well? In the past I often had the problem that my "B" model was wrongly recognized as MHZ-19.
I have B.
The settings are the same. The software should detect the kind of MHZ, either 19 or 19B depending on result of serial data.
After 6 hours = 0 ppm :( I send 4 pictures what is my config. I hope that is not my fault.
From your config you are still using software serial. To run hardware serial you will need to swap rx and tx in both the config and the 2 serial wires.
I'm running still ok for over 14 hours with hardware serial.
I updated the firmware, rewired the Wemos and it is running for 3 hours without problems. I will keep you updated.
OHH....swapped.
After 3 Tests it took less than 15 minutes and it was 0 ppm.... My settings are, as before, this:
@FabianHM You need to swap the TX/RX to use Hardware serial!
I have swapped the cable connections (Rx. ->Tx) and thought that the same effect was achieved. I test again with changed settings
I forgot to swap too. Since 10 hours is stable.
See here (https://github.com/arendst/Sonoff-Tasmota/wiki/What's-New#20180510---5131a-with-tasmotaserial-200) for other sensor information
After I clarified my understanding problem with the configuration I tested with a Wemos. After 1,0 hours, a completely new problem has occurred. The GUI is frozen and the web interface is no longer accessible. Multiple on and staking of the wemos has brought nothing, the Webgui is no longer available. The device is only accessible via ping.
@FabianHM I saw similar problems when compiling with Core 2.4.0, does the problem persist when using 2.3.0?
@arendst My CO2-Sensor is still running fine with your latest changes. With the previous firmware it has never lasted that long without problems.
Still running without any problems. One less custom firmware that can be replaced with stock tasmota! Thanks for the great work!
@arendst Until now (since 3 days) works good. Thanks for the amazing software and support!
Anybody has this problem now? I have exact problem as described in this thread.
I have MH-Z19B module connected through hardware serial with configuration like this: . Relay and switch configuration are always enabled as I removed relay module and power sensor from 5V line there.
According to link provided in previous post this should enable hardware serial and judging from console log it does (i see log like "Hardware serial" in console after each restart).
See here (https://github.com/arendst/Sonoff-Tasmota/wiki/What's-New#20180510---5131a-with-tasmotaserial-200) for other sensor information
On tasmota and Sonoff Basic R1 it stop working after a couple of hour. After powering down and up the sensor (ex. using relay) it is working again until next freeze.
Sensor was working fine on custom firmware on esp8266 using MHZ library for over a week. I do find one difference, I was using this library and it is loading data from sensor less often than tasmota does. Author have mention in comment to issue that he had made explicit waiting to mitigate problem with sensor.
A friend of mine had similar problems. The reason was:
He switched to a better USB power supply and the problem disappeared.
Thanks, I will invastigate it further. Sonoff has nice 5V±3%, but when sensor is connected voltage drop to 4.5V and even to 4.0V when IR diod is firing at sensor. I was not expecting that as avg power consumption of sensor should be 19mA (yeah I know - avarage) and relay coil is rated at 200-400mA depending on model.
I will try to add some capacitors and let you know.
Nevertheless I will try to modify tasmota so that sensor read interval could be changed. Currently it is 8s and default MQTT push is 300s so in many scenarios there no point to read data this often (I imagine this could improve expected life time of sensor). Also (from specification) measurement should be taken after 3 minutes from powering sensor (to give it time to heats up heats up).
EDIT: It looks like @tobox was right (thanks again!). I stabilize voltage with quite big capacitor and now sensor works like a charm for almost 24h.
Hi all, my config is exact like here: https://tasmota.github.io/docs/MH-Z19B/ same problem. 0° and 0ppm from the start. I tried different things:
I used the newest tasmota_sensors.bin
Can I somehow check, if the sensor is working? Perhaps the sensor is defect....
Any further Ideas? What should I try?
Best regards, Frank
Can anybody help? I feal alone...
I am not using tasmota but an ESP32 Module and i have the same problem. I purchased two MMZ 19 sensors. One is working very well. The other one is crashing afer some hours of working. Sometimes after 8 hours , sometime after two days. The MHZ 19 does not answer and that results in showing 0ppm by the driver.
What i tried without success: -Support capacitors 10u Tantal and 470u Aluminium -An external power supply -Pullup resistors 2k2 on TxD and RxD -Calling the CO2 reading function only in quiet periods with no other Software activity running in parallel
At the moment i give up.
I have also problems with the MHZ-19. I use also a ESP32 board, the sensor has run for a few hours and gave expected readings but after that it went to 5000ppm and after a reboot it got 0ppm and stayed there.
I have also problems with the MHZ-19. I use also a ESP32 board, the sensor has run for a few hours and gave expected readings but after that it went to 5000ppm and after a reboot it got 0ppm and stayed there.
- Tried swapping TX and RX on hardware and software (and tried all combinations.
- Powered the MHZ-19 with external 5V power supply.
- Tried other GPIO pins. Somebody an idea?
Did you resolve the problem? I already tried the calibration on it. I got two sensors shipped from the same seller on aliexpress. One works fine, and the other one is only giving me the 0ppm co2 value. The temperature is "fine" though, quite inaccurate but within 5 degrees. I remember this one drifting to 5000ppm before the calibration attempt.
I've installed 5.12 / 5.13, since after boot randomly (5 minutes - 2-3 hours) the sensor shows 0 ppm. I have flashed on Sonoff TH10, NodeMCU and Wemos mini d1 with 5.11 everything is normal since 3-4 months. With hyperterminal I analyzed the query FF 01 86 00 00 00 00 00 79 comes every ~ 2 sec, but answer from the MHZ19 nothing. Software restart does not help, I have to unplug the power plug that it communicates again. Power supply 5 volts extra included. Idea? Sorry about bad english.