xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.98k stars 635 forks source link

MHZ19 CO2 problem #971

Closed MariusLaurinaitis closed 5 years ago

MariusLaurinaitis commented 6 years ago

Hello Xose,, I have same problem witth MHZ19 , maybe here's the same problem with the serial? Does it work for you? Thanks

image

image

MariusLaurinaitis commented 6 years ago

UPDATE: Espurna: MHZ19 @ SwSerial(13,15) MHZ19_RX_PIN -> 13 MHZ19_TX_PIN -> 15

I did not compil the new one, just: I swapped the wires only (I'll switch to RX and TX) and worked. But maybe you need to specify a PIN so that it does not mix others?

MHZ19 rx -> Wemos pin 15 MH19 TX -> Wemos pin 13

image

xoseperez commented 6 years ago

Sorry, do you mean GPIO 13 must be connected to the MHZ19 TX?

MariusLaurinaitis commented 6 years ago

Yes: GPIO 13 must be connected to the MHZ19 TX Thats work for me

xoseperez commented 6 years ago

Well, that's right, in the definition 13 is RX (from the device point of view) and must be connected to sensor TX.

IvanUA commented 6 years ago

Hi! I have the same problem - Error reading data from MH-Z19. Power source for MH-Z19 - external 5V.

Is there any way to debug MHZ19?

MariusLaurinaitis commented 6 years ago

did you swapped RX and TX?

IvanUA commented 6 years ago

Of course, many times. Gpio 13,15 (rx,tx and vice versa) Gpio 1,3 No success

Old one MH-Z19 (1st generation)

xoseperez commented 6 years ago

I'm not much into these sensors and I don't know what changes were there between different generations... @IvanUA, do you have a working code for your sensor?

IvanUA commented 6 years ago

Hi. Now I'm not sure about working condition of my MHZ19 (couldn't get it work directly through USB-UART). I'll will take a try with another one. Thank you.

jsponz commented 5 years ago

@MariusLaurinaitis, I have some problems when compiling for having support for MHZ19 -> https://github.com/xoseperez/espurna/issues/1063

Any idea?

Thanks!

MariusLaurinaitis commented 5 years ago

did you swapped RX and TX?

P.S. UPDATE: Espurna: MHZ19 @ SwSerial(13,15) MHZ19_RX_PIN -> 13 MHZ19_TX_PIN -> 15

I did not compil the new one, just: I swapped the wires only (I'll switch to RX and TX) and worked. But maybe you need to specify a PIN so that it does not mix others?

MHZ19 rx -> Wemos pin 15 MH19 TX -> Wemos pin 13

jsponz commented 5 years ago

I tried it as well, but the same library error. I have a new installation, following all the steps of the guideline...

Which libraries are you using?

Thanks!

MariusLaurinaitis commented 5 years ago

I tried 1.13.1 with all libraries

jsponz commented 5 years ago

same here :-(

jsponz commented 5 years ago

@MariusLaurinaitis It worked finally. Wrong reference on the libraries.

@IvanUA Does it work for you? I have the same:

[236659] [SENSOR] Error reading data from MHZ19 @ SwSerial(14,15) (error: 5) [242669] [SENSOR] Error reading data from MHZ19 @ SwSerial(14,15) (error: 5)

I have changed the pins, but with the same result.

Any idea? How do you know it is a first generation product?

MariusLaurinaitis commented 5 years ago

I will try in the evening

derlucas commented 5 years ago

try skipping the checksum check in MHZ19Sensor.h around line 181.

if ((buffer[0] == 0xFF) && (buffer[1] == 0x86)) {

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue will be auto-closed because there hasn't been any activity for two months. Feel free to open a new one if you still experience this problem.

berezovskyi-oleksandr commented 5 years ago

I believe that I faced same problem with checksum calculation.

In calculation loop, there is next line: for (unsigned char i = 1; i < MHZ19_REQUEST_LEN-1; i++) { This definition will let sum from 1 till 7 (MHZ19_REQUEST_LEN - 1).

According to datasheet (page 9) there should be sum from 1 till 8.

After replacing MHZ19_REQUEST_LEN with MHZ19_RESPONSE_LEN , calculations became valid.

ruimarinho commented 5 years ago

@berezovskyi-oleksandr I have applied your suggested change but I still have the same issue. Tried multiple pins as well.