Skip to content

Commit

Permalink
mhz-19b verify before sensor read
Browse files Browse the repository at this point in the history
  • Loading branch information
yakumo-saki committed Jan 8, 2021
1 parent 04cd8f8 commit 274b541
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sensors/mhz19b/mhz19_uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "sensors/mhz19_main.h"
#include "sensors/mhz19_util.h"

const int MHZ_RESULT_OK = 1;

// 400ppmの校正(ABC)を行う。これをするには、20分以上外気に晒し続ける必要がある。
// 終了後は false に戻す。
bool AUTO_BASELINE_CORRECTION = false;
Expand Down Expand Up @@ -64,7 +66,6 @@ void mhz_setup_uart() {
mhzlog("Wait for MHZ UART serial");
while(!mhzSerial);

mhzlog("MHZ-19B begin()");
mhz19.begin(mhzSerial);

mhzlog("setRange()");
Expand Down Expand Up @@ -97,6 +98,12 @@ void mhz_read_data_uart() {
return;
}

mhz19.verify();
if (mhz19.errorCode == 1) {
printErrorCode();
mhzlog("MH-Z19B connection failed. abort.");
}

int co2ppm = mhz19.getCO2();
if (mhz19.errorCode == 1) {
mhzGetDataTimer = millis();
Expand Down

0 comments on commit 274b541

Please sign in to comment.