From 7be7cf0f22e8c3bcd9c7357b2a1ef2f70d8d0c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=BE=8A=E7=8A=AC=E7=9C=9FQ?= <43088530+CollieIsCute@users.noreply.github.com> Date: Tue, 28 Sep 2021 16:15:22 +0800 Subject: [PATCH] fixed typoes in readme and fixed error in MHZ.cpp files (#24) * correct the type of sensor in readme * fix overflow in int datatype in arduino Uno. In Uno, it's 16 bits in int variable. So I add a explicit type cast in MHZ.cpp file * fix the warning of implicit convert from hex to char. I change the data type to unit_8t, and it also helps to unify the datatype of these cmd arrays. --- MHZ.cpp | 6 +++--- README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MHZ.cpp b/MHZ.cpp index b7942f1..b3081c9 100644 --- a/MHZ.cpp +++ b/MHZ.cpp @@ -14,8 +14,8 @@ const int MHZ_10K = 3; const unsigned long MHZ14A_PREHEATING_TIME = 3L * 60L * 1000L; const unsigned long MHZ19B_PREHEATING_TIME = 3L * 60L * 1000L; -const unsigned long MHZ14A_RESPONSE_TIME = 60 * 1000; -const unsigned long MHZ19B_RESPONSE_TIME = 120 * 1000; +const unsigned long MHZ14A_RESPONSE_TIME = (unsigned long)60 * 1000; +const unsigned long MHZ19B_RESPONSE_TIME = (unsigned long)120 * 1000; const int STATUS_NO_RESPONSE = -2; const int STATUS_CHECKSUM_MISMATCH = -3; @@ -286,7 +286,7 @@ void MHZ::setRange(int range) //only available for MHZ-19B < 1.6 and MH-Z 14a void MHZ::calibrateZero() { - char cmd[9] = {0xFF, 0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78}; + uint8_t cmd[9] = {0xFF, 0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78}; _serial->write(cmd,9); } diff --git a/README.md b/README.md index d4e9491..d478be8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MH-Z14A, MH-Z19B CO2 ... Module -Arduino implementation for MH-Z CO2 sensors such as **MH-Z14A**, **MH-Z18B** (as I didn't find all info in one place). +Arduino implementation for MH-Z CO2 sensors such as **MH-Z14A**, **MH-Z19B** (as I didn't find all info in one place). The sensor is available for ~20 bucks at the usual places.