mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-16 10:12:09 +02:00
Revert "Explicitly set active mode for PM sensor upon initialization"
This reverts commit 0d39643e76
.
This commit is contained in:
@ -697,7 +697,7 @@ static void oneIndoorInit(void) {
|
||||
ledBarEnabledUpdate();
|
||||
|
||||
/** Show message init sensor */
|
||||
oledDisplay.setText("Monitor", "initializing...", "");
|
||||
oledDisplay.setText("Sensor", "initializing...", "");
|
||||
|
||||
/** Init sensor SGP41 */
|
||||
if (sgp41Init() == false) {
|
||||
@ -778,27 +778,27 @@ static void openAirInit(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Attempt to detect PM sensors */
|
||||
/** Try to find the PMS on other difference port with S8 */
|
||||
if (fwMode == FW_MODE_O_1PST) {
|
||||
bool pmInitSuccess = false;
|
||||
if (serial0Available) {
|
||||
if (ag->pms5003t_1.begin(Serial0) == false) {
|
||||
configuration.hasSensorPMS1 = false;
|
||||
Serial.println("No PM sensor detected on Serial0");
|
||||
Serial.println("PMS1 sensor not found");
|
||||
} else {
|
||||
serial0Available = false;
|
||||
pmInitSuccess = true;
|
||||
Serial.println("Detected PM 1 on Serial0");
|
||||
Serial.println("Found PMS 1 on Serial0");
|
||||
}
|
||||
}
|
||||
if (pmInitSuccess == false) {
|
||||
if (serial1Available) {
|
||||
if (ag->pms5003t_1.begin(Serial1) == false) {
|
||||
configuration.hasSensorPMS1 = false;
|
||||
Serial.println("No PM sensor detected on Serial1");
|
||||
Serial.println("PMS1 sensor not found");
|
||||
} else {
|
||||
serial1Available = false;
|
||||
Serial.println("Detected PM 1 on Serial1");
|
||||
Serial.println("Found PMS 1 on Serial1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -806,15 +806,15 @@ static void openAirInit(void) {
|
||||
} else {
|
||||
if (ag->pms5003t_1.begin(Serial0) == false) {
|
||||
configuration.hasSensorPMS1 = false;
|
||||
Serial.println("No PM sensor detected on Serial0");
|
||||
Serial.println("PMS1 sensor not found");
|
||||
} else {
|
||||
Serial.println("Detected PM 1 on Serial0");
|
||||
Serial.println("Found PMS 1 on Serial0");
|
||||
}
|
||||
if (ag->pms5003t_2.begin(Serial1) == false) {
|
||||
configuration.hasSensorPMS2 = false;
|
||||
Serial.println("No PM sensor detected on Serial1");
|
||||
Serial.println("PMS2 sensor not found");
|
||||
} else {
|
||||
Serial.println("Detected PM 2 on Serial1");
|
||||
Serial.println("Found PMS 2 on Serial1");
|
||||
}
|
||||
|
||||
if (fwMode == FW_MODE_O_1PP) {
|
||||
|
@ -519,7 +519,7 @@ void OledDisplay::showRebooting(void) {
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
// setCentralText(20, "Firmware Update");
|
||||
setCentralText(40, "Rebooting...");
|
||||
setCentralText(40, "Reboot...");
|
||||
// setCentralText(60, String("Retry after 24h"));
|
||||
} while (DISP()->nextPage());
|
||||
} else if (ag->isBasic()) {
|
||||
|
@ -72,7 +72,7 @@ bool WifiConnector::connect(void) {
|
||||
WIFI()->setSaveParamsCallback([this]() { _wifiSaveParamCallback(); });
|
||||
WIFI()->setConfigPortalTimeoutCallback([this]() {_wifiTimeoutCallback();});
|
||||
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3() || ag->isBasic()) {
|
||||
disp.setText("Connecting to", "WiFi", "...");
|
||||
disp.setText("Connect to", "WiFi", "...");
|
||||
} else {
|
||||
logInfo("Connecting to WiFi...");
|
||||
}
|
||||
|
@ -2,48 +2,34 @@
|
||||
#include "../Main/BoardDef.h"
|
||||
|
||||
/**
|
||||
* @brief Initializes the sensor and attempts to read data.
|
||||
* @brief Init and check that sensor has connected
|
||||
*
|
||||
* @param stream UART stream
|
||||
* @return true Sucecss
|
||||
* @return false Failure
|
||||
*/
|
||||
bool PMSBase::begin(Stream *stream) {
|
||||
Serial.printf("initializing PM sensor\n");
|
||||
this->stream = stream;
|
||||
|
||||
failed = true;
|
||||
failCount = 0;
|
||||
lastRead = 0; // To read buffer on handle without wait after 1.5sec
|
||||
|
||||
// empty first
|
||||
int bytesCleared = 0;
|
||||
while (this->stream->read() != -1) {
|
||||
bytesCleared++;
|
||||
}
|
||||
Serial.printf("cleared %d byte(s)\n", bytesCleared);
|
||||
|
||||
// explicitly put the sensor into active mode, this seems to be be needed for the Cubic PM2009X
|
||||
Serial.printf("setting active mode\n");
|
||||
uint8_t activeModeCommand[] = { 0x42, 0x4D, 0xE1, 0x00, 0x01, 0x01, 0x71 };
|
||||
size_t bytesWritten = this->stream->write(activeModeCommand, sizeof(activeModeCommand));
|
||||
Serial.printf("%d byte(s) written\n", bytesWritten);
|
||||
this->stream->flush();
|
||||
|
||||
// Run and check sensor data for 4sec
|
||||
while (1) {
|
||||
handle();
|
||||
if (failed == false) {
|
||||
Serial.printf("PM sensor initialized\n");
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
delay(10);
|
||||
delay(1);
|
||||
uint32_t ms = (uint32_t)(millis() - lastRead);
|
||||
if (ms >= 4000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Serial.printf("PM sensor initialization failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
#define PMS_FAIL_COUNT_SET_INVALID 3
|
||||
|
||||
/**
|
||||
* Known to work with these sensors: Plantower PMS5003, Plantower PMS5003, Cubic PM2009X
|
||||
*/
|
||||
class PMSBase {
|
||||
public:
|
||||
bool begin(Stream *stream);
|
||||
|
@ -38,11 +38,14 @@ bool PMS5003::begin(HardwareSerial &serial) {
|
||||
PMS5003::PMS5003(BoardType def) : _boardDef(def) {}
|
||||
|
||||
/**
|
||||
* Initializes the sensor.
|
||||
* @brief Init sensor
|
||||
*
|
||||
* @return true Success
|
||||
* @return false Failure
|
||||
*/
|
||||
bool PMS5003::begin(void) {
|
||||
if (this->_isBegin) {
|
||||
AgLog("Already initialized, call end() then try again");
|
||||
AgLog("Initialized, call end() then try again");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user