Erroneous readings

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Erroneous readings

#1 Post by Hoogendoorn » 07 Dec 2020, 23:42

Hi,

I have a MH-Z19B on an ESP8266 NodeMCU platform with CP2102 USB chip (Amica), with ESP Easy Mega v2.0.0-dev13.

As far as I can tell, I installed everything correctly. However, I get erroneous readings, f.i.:
511610 : MHZ19: Read error : CRC = 7 / 255 bytes read => 255/255/255/255/255/255/255/255/255/
511612 : MHZ19: Shifted 1 bytes to attempt to fix buffer alignment

I read other posts with read errors from the MH-Z19(B), but could not find a solution. Anyone an idea how to get the right readings from the MH-Z19B?

Kind regards,
Jan.
Kind regards, Jan Hoogendoorn

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Erroneous readings

#2 Post by Ath » 08 Dec 2020, 07:51

Hello Jan,
Welcome to this forum :)

You seem to be using a really ancient version of ESPEasy, please install one of the (quite stable) regularly updated 'nightly' builds from https://github.com/letscontrolit/ESPEasy/releases

Assuming of course that your wiring is stable, this should greatly improve the chance this will work as expected.
/Ton (PayPal.me)

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#3 Post by Hoogendoorn » 08 Dec 2020, 09:54

Thanks for your response, Ton.

I upgraded to ESP_Easy_mega_20201130_normal_ESP8266_4M1M, but the problem persists. The error message is now 60868: MHZ19: Unknown response: 0 0 0 0 0 0 0 0 0

What can be the next step to a working sensor?
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#4 Post by TD-er » 08 Dec 2020, 09:59

Has it ever been working in this setup?

Please give a bit more information:
- Used pins for RX/TX
- Double check RX of the sensor is connected to TX on the ESP and vice verse.
- If using hardware serial (e.g. GPIO3 and 1), make sure to disable "Use Serial" in tools -> Advanced.
- How is the sensor powered?

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#5 Post by Hoogendoorn » 08 Dec 2020, 10:27

Hallo TD-er,

I just purchased the stuff, its the first time I am setting this up.

For the pin settings and adapter for the sensor, see the attached files. I double checked the connection.

MHZ19B-settings.jpg
MHZ19B-settings.jpg (96.81 KiB) Viewed 12188 times
Adapter_for_sensor.jpg
Adapter_for_sensor.jpg (48.68 KiB) Viewed 12188 times
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#6 Post by TD-er » 08 Dec 2020, 10:36

So I assume the ESP does have its own 3v3 regulator, like for example a NodeMCU board or a Wemos D1 mini?
TX of the sensor is connected to GPIO-12?
RX of the sensor is connected to GPIO-14?
The sensor itself is powered from the 5V?
GND is connected to GND of the ESP board and the - of the power supply?

Can you measure the 5V of the power supply, just to be sure it actually is 5V and not (a lot) higher?
When using a higher voltage, you may have fried the sensor.

As you can see on your screenshot, there are some statistics present on the web interface.
As long as "pass" and "fail" keep at 0, you can be sure no data is received by the ESP.
This can be an indicator RX and TX are swapped (you can switch the pin definition in the settings, no need to desolder stuff)
Or the sensor may be broken (or not powered right)

If the "fail" counter increases, you may have some other issue at hand. For example either picking up noise (long cables) or other sensors interacting with the reading of this one.

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#7 Post by Hoogendoorn » 08 Dec 2020, 13:06

So I assume the ESP does have its own 3v3 regulator, like for example a NodeMCU board or a Wemos D1 mini? Yes, it has.
TX of the sensor is connected to GPIO-12? Yes.
RX of the sensor is connected to GPIO-14? Yes.
The sensor itself is powered from the 5V? Yes.
GND is connected to GND of the ESP board and the - of the power supply? Yes.

Can you measure the 5V of the power supply, just to be sure it actually is 5V and not (a lot) higher? I measured 5,03 Volt. Seems OK.

If the "fail" counter increases, you may have some other issue at hand. For example either picking up noise (long cables) . . . The connector cables have a length of 20 cm.
. . . or other sensors interacting with the reading of this one. There is only one sensor attached to the ESP8266.
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#8 Post by TD-er » 08 Dec 2020, 13:18

Can you connect the RX and TX of the sensor to the pins labelled TX and RX (remember to cross-connect RX and TX) on the ESP board?
This way you can peek into what is being sent and received by the sensor via the USB to serial chip.
Just any terminal program able to communicate with a serial port will do.

Make sure to disable "Use Serial" on tools->advanced page of ESPEasy and configure the task to use Serial0 (Gpio 1 & 3)

This allows you to see if the sensor sends data as it will be echo'ed on the terminal application.

N.B. don't forget to set the terminal application to the baud rate used by the plugin. (9600 baud)

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#9 Post by Hoogendoorn » 08 Dec 2020, 14:11

Mmm, what the terminal receives seems not very sensible, however the ESP displays data which seems to be something like CO2. If I blow over the sensor, the value increases and after a while deceases. Also, the value arrives in Domoticz. Can I leave it like this or is this actually an unusual connection?

By the way, what is U?


Terminal.jpg
Terminal.jpg (32.96 KiB) Viewed 12169 times
ESP_Easy.jpg
ESP_Easy.jpg (74.45 KiB) Viewed 12169 times
Domoticz.jpg
Domoticz.jpg (106.7 KiB) Viewed 12169 times
Kind regards, Jan Hoogendoorn

User avatar
Ath
Normal user
Posts: 3481
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Erroneous readings

#10 Post by Ath » 08 Dec 2020, 15:22

That terminal seems like a wrong baud rate or other serial parameter (No parity, 8 databits, 1 stopbit are the most common parameters)
/Ton (PayPal.me)

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#11 Post by Hoogendoorn » 08 Dec 2020, 15:41

I thought so too, but as far as I can see the settings are ok.
Terminal_settings.jpg
Terminal_settings.jpg (62.46 KiB) Viewed 12162 times
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#12 Post by TD-er » 08 Dec 2020, 15:43

OK, so the sensor does seem to work.

The "U" value is believed to be some representation of the lowest RAW value seen in the last N hours.
I think it is used in the ABC function to determine a new 400 ppm level.
Some kind of self-calibration function, but on the MH-Z19 it is a rather tricky one as its ABC period is only 24h.
So if you haven't had proper ventilation (during the day) in the last 24h, the "400 ppm" level may be set incorrect and thus reporting too low values until the ABC corrects it.

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#13 Post by TD-er » 08 Dec 2020, 15:44

By the way, the sensor outputs binary data, so it is probably not readable.
My intention was more to see if the sensor does report back anything.
If you see like ~9 charachetrs output every N seconds, then you know the sensor is sending data and thus also receiving a request from the ESP to take a sample.

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#14 Post by Hoogendoorn » 08 Dec 2020, 15:58

Ok, but as I mentioned in my post #9 (08 Dec 2020, 14:11) the readings via Tx and Rx on the ESP8266 seem ok. But that is not a normal way of connecting a sensor to the ESP8266, is it?
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#15 Post by TD-er » 08 Dec 2020, 16:03

You can connect it to a HW serial port, but then it may interfere with programming it via serial and makes it impossible to read logs via serial.
So I would personally use other pins, unless it is easy to remove for debugging.

Hoogendoorn
New user
Posts: 8
Joined: 07 Dec 2020, 23:34
Location: Netherlands

Re: Erroneous readings

#16 Post by Hoogendoorn » 08 Dec 2020, 22:48

Ok, I put Tx from the sensor back to GPIO-14 (D5) and Rx to GPIO-12 (D6) and to my surprise this works now also. I don't know why. The only difference between the original connections I had and what I have now is "GND is connected to GND of the ESP board and the - of the power supply" (see post #6 and #7), although I made that connection already before moving to the Tx and Rx pins on the board. Anyway, if I disconnect the connection between GND of the ESP and the - on the power supply, I get erroneous readings again.

Well, the device works now. I hope it will persist. TD-er and Ton, thanks for your support.
Kind regards, Jan Hoogendoorn

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Erroneous readings

#17 Post by TD-er » 09 Dec 2020, 19:51

Yep a loose ground can often cause strange errors.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 20 guests