RobTillaart / MHZCO2

Arduino Library for MHZ series CO2 sensors
MIT License
5 stars 1 forks source link

setPPM does not work; solution: see description #9

Closed gert-ineke closed 11 months ago

gert-ineke commented 11 months ago

line 41 in cpp is: data[8] = PPM >> 8; must be: data[6] = PPM >> 8;

RobTillaart commented 11 months ago

Thanks for catching I will try to verify and patch today.

RobTillaart commented 11 months ago

Looking again at the code, I saw that there might be a race condition in the receive function too. I will investigate to fix that one too.

RobTillaart commented 11 months ago

Created a develop branch, Do you have time to test it?

RobTillaart commented 11 months ago

@gert-ineke You might need to edit your last post as there might be some private information in it. (I can do it for you)

gert-ineke commented 11 months ago

setPPM(2000) works as expected. setPPM(5000) does not work. I use a MH-Z19C. The results are 56831, 65414, 65414 (3 minute interval) instead of about 532. I assume this is not a problem of the code, but the MH-Z19C. Is it?

RobTillaart commented 11 months ago

From the MH-Z19C-DZ User’s Manual (Version 1.21)

image

5000 is within range of the spec above. However the PWM output can only do up to 2000

https://emariete.com/en/sensor-co2-mh-z19b/ states at the bottom that there are 2 different models of the 19C

Model MH-Z19C 400~2000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
Model MH-Z19C 400~5000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.
Model MH-Z19C 400~10000 ppm range. This version has an accuracy of 50 ppm + 5% of measurement.

Some googling

MH-Z19C-DC

MH-Z19C-PH

10000 PPM model niet kunnen vinden.

gert-ineke commented 11 months ago

Very strange. I did a re-test with setPPM(5000). It works :-) It gives 579, 558, 559. I have to gather a lot of people to get above 2000. With Christmas this was easy to accomplish. Thank you very much.

RobTillaart commented 11 months ago

Not convinced yet it will output above 2000. Sending 5000 to the device does not change hardware. You could test it with a car exhaust or the breath of a smoker or put a plastic bag over it and keep breathing the air in the bag?

RobTillaart commented 11 months ago

I will merge the change

RobTillaart commented 11 months ago

Version 0.2.0 released. Thanks again for finding the bug!

gert-ineke commented 11 months ago

Not convinced yet it will output above 2000. Sending 5000 to the device does not change hardware. You could test it with a car exhaust or the breath of a smoker or put a plastic bag over it and keep breathing the air in the bag?

With setPPM(5000) the sensor has got a limit of 5000 ppm. With setPPM(2000) a limit of 2000 ppm. I measured these limit values. According to the label (from Tinytronics?) it is a 400-2000ppm model. I assume the difference between the DC en PH models is just a preset of the limit.

RobTillaart commented 11 months ago

Ok, did you read values above 2000 too? That would be interesting.

gert-ineke commented 11 months ago

Ok, did you read values above 2000 too? That would be interesting.

Yes, I used a bag. The values cannot get higher than 5000. I did not verify on setPPM(10000). Maybe I get values above 5000, but I am satisfied with a limit of 5000 ppm.

RobTillaart commented 11 months ago

Question: Is the setPPM() persistent when you reboot / disconnect the power? Could you test with the bag?

gert-ineke commented 11 months ago

Question: Is the setPPM() persistent when you reboot / disconnect the power? Could you test with the bag?

Yes. It is persistent. And yes I measure values like 500, 3000 and 5000 (max).

RobTillaart commented 11 months ago

Super, i make a note for the readme.md