co2minimon

Get temperature and CO2 concentration data from a CO2Mini sensor.
Log | Files | Refs | README | LICENSE

commit 3d335a4f4a6f3720bea46252badefb1ad5d84d71
parent 5f70c0976700af5a39bd9382a2a18fe30b1d13c9
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Sat, 15 Jan 2022 12:30:54 -0800

Fix checksum calculation

I had missed that the specification says to use only the lower byte of
the sum.

Diffstat:
Mmain.c | 3+--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/main.c b/main.c @@ -92,9 +92,8 @@ int main(void) if (bytes_read == sizeof(data) && end == 0x0d && (item == 0x42 || item == 0x50) - && item + msb + lsb == checksum) + && ((item + msb + lsb) & 0xFF) == checksum) { - uint16_t value = (((uint16_t)msb) << 8) | lsb; char buf[1024] = {0}; int str_len = 0;