Closed vmarseguerra closed 10 months ago
Thank you for your contribution! I appreciate the effort you've put into this.
Your proposed changes will affect error handling. In the current implementation, negative values are used as status codes to signify errors. See https://github.com/tobiasschuerg/MH-Z-CO2-Sensors/blob/82d85c331229a6a8479ee3a56c20e6dcff92cfc0/MHZ.h#L21-L27
Is there a real-world usecase for supporting such high concentrations? As far as I know the sensors only supoprt a concentration up ro 10.000 ppm anyways: https://github.com/tobiasschuerg/MH-Z-CO2-Sensors#supported-sensors
Indeed, an int32_t
also works.
MH-Z14B and MH-Z16 can have a range above 10 000ppm From the Winsen Aliexpress store:
I have MH-Z14B sensor with a range of 0-50000 ppm, we use it in caving to check if we can go deeper or not. Since CO2 is heavier than air, it can accumulate at the bottom of certain caves.
On Arduino ATmega boards an
int
is stored on 2 bytes. With a CO2 value above 32 768 ppm, the value returned by the library became negative. Switched touint32_t
int32_t
.