The current firmware rev633 has two flows for sensor auto detecting, Honeywell flow and Sensirion flow. It is because the UART re-init or changing the speed and parameters don't works fine in the ESP32.
The current method is:
bool Sensors::pmSensorInit(int pms_type, int pms_rx, int pms_tx) {
// set UART for autodetection sensors (Honeywell, Plantower, Panasonic)
if (pms_type <= 1) {
DEBUG("-->[PMSENSOR] detecting PM sensor..");
Serial2.begin(9600, SERIAL_8N1, pms_rx, pms_tx);
}
// set UART for autodetection Sensirion sensor
else if (pms_type == Sensirion) {
DEBUG("-->[PMSENSOR] detecting Sensirion sensor..");
Serial2.begin(115200);
}
// starting auto detection loop
_serial = &Serial2;
int try_sensor_init = 0;
while (!pmSensorAutoDetect(pms_type) && try_sensor_init++ < 2);
}
The idea is only have one Serial.begin(), and change the params for each detection in run time.
Summary
The current firmware rev633 has two flows for sensor auto detecting, Honeywell flow and Sensirion flow. It is because the UART re-init or changing the speed and parameters don't works fine in the ESP32.
The current method is:
The idea is only have one
Serial.begin()
, and change the params for each detection in run time.source