PMS5003 RX TX pin handling in PmsInit

This commit is contained in:
gururise 2020-04-08 10:22:32 -07:00
parent 8d1322984c
commit ffd5338150
1 changed files with 15 additions and 2 deletions

View File

@ -140,13 +140,26 @@ void PmsSecond(void) // Every second
void PmsInit(void) void PmsInit(void)
{ {
pms_type = 0; pms_type = 0;
if (pin[GPIO_PMS5003] < 99) { if ((pin[GPIO_PMS5003_RX] < 99) && (pin[GPIO_PMS5003_TX] < 99))
PmsSerial = new TasmotaSerial(pin[GPIO_PMS5003], -1, 1); {
PmsSerial = new TasmotaSerial(pin[GPIO_PMS5003_RX], pin[GPIO_PMS5003_TX], 1);
if (PmsSerial->begin(9600)) { if (PmsSerial->begin(9600)) {
if (PmsSerial->hardwareSerial()) { ClaimSerial(); } if (PmsSerial->hardwareSerial()) { ClaimSerial(); }
pms_type = 1; pms_type = 1;
} }
} }
else if ((pin[GPIO_PMS5003_RX] < 99))
{
PmsSerial = new TasmotaSerial(pin[GPIO_PMS5003_RX], -1, 1);
if (PmsSerial->begin(9600))
{
if (PmsSerial->hardwareSerial())
{
ClaimSerial();
}
pms_type = 1;
}
}
} }
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER