meshchaninov / flipper-zero-mh-z19

Application for measuring carbon dioxide (CO2) with mh-z19 sensor and Flipper zero
MIT License
41 stars 2 forks source link

Wrong temperature #1

Closed RnmX closed 1 year ago

RnmX commented 1 year ago

Hello meshchaninov,

first of all, thanks a lot for this plugin, it is quite nice! I setup my flipper with mh-z19 exactly as you are sugegsting in your readme here. I noticed, that my ppm are way off (I have a professional device which can measure CO2, so I could compare). Initialy I thought that my sensor could be damaged somehow, so I decided to check it with Arduino. Then, result were correct, which led me to believe there is something in your code which makes results not reliable.

After some googling I found a solution! It seems that there are some mh-z19 which has concentration limit set to 2000 and others to 5000. Please read the discussion here: https://electronics.stackexchange.com/questions/262473/mh-z19-co2-sensor-giving-diferent-values-using-uart-and-pwm (relevant part: "I'm quite sure that there are two versions of this sensor. One reading up to 2000ppm and the other up to 5000ppm.").

Now when we look into your code (https://github.com/meshchaninov/flipper-zero-mh-z19/blob/81ddaee501ac2c32c7f639edc5c71c0f9dcd9f4e/mh_z19/mh_z19app.c#L234), it seems that you hardcoded value "2000", which produces wrong results for those of us, who have the other version. After I changed that code (replace 2000 with 5000) flipper started to show correct values (almost idendical to the professional device).

Workaround is kinda easy in this case, as I only need to change a number and compile my own firmware, then it works OK. However, this is not the most convicinet way as with every update of flipper (which happens a lot) I need to recompile it again. This might be a problem for less experienced users who don't know how to compile their own flipper build.

That is why I got an idea - maybe you could implement some code which would allow to change this constant by just clicking an arrow on flipper. Your repo already made it to RogueMaster repo, so this is the easiest way to distribute this functionality among all flipper users.

Thanks a lot!

meshchaninov commented 1 year ago

Thanks for your detailed description and solving of the problem. I think I will do as you suggest

meshchaninov commented 1 year ago

Solved