From 7cefc9b76efa762772fbac412df992174cb42b07 Mon Sep 17 00:00:00 2001 From: Johann Weging Date: Sun, 27 May 2018 14:24:53 +0200 Subject: [PATCH] SDS0X1 add start and stop functions to idle the sensor --- sonoff/xsns_20_novasds.ino | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sonoff/xsns_20_novasds.ino b/sonoff/xsns_20_novasds.ino index 610e07427..c54297911 100644 --- a/sonoff/xsns_20_novasds.ino +++ b/sonoff/xsns_20_novasds.ino @@ -94,6 +94,26 @@ void NovaSdsInit() } } +void NovaSdsStart() +{ + AddLog_P(LOG_LEVEL_DEBUG, "SDS: start"); + const uint8_t novasds_start_cmd[] = {0xAA, 0xB4, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x06, 0xAB}; + NovaSdsSerial->write(novasds_start_cmd, sizeof(novasds_start_cmd)); + NovaSdsSerial->flush(); +} + +void NovaSdsStop() +{ + AddLog_P(LOG_LEVEL_DEBUG, "SDS: stop"); + const uint8_t novasds_stop_cmd[] = {0xAA, 0xB4, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x05, 0xAB}; + NovaSdsSerial->write(novasds_stop_cmd, sizeof(novasds_stop_cmd)); + NovaSdsSerial->flush(); + // drain any old data + while (NovaSdsSerial->available()) { + NovaSdsSerial->read(); + } +} + #ifdef USE_WEBSERVER const char HTTP_SDS0X1_SNS[] PROGMEM = "%s" "{s}SDS0X1 " D_ENVIRONMENTAL_CONCENTRATION " 2.5 " D_UNIT_MICROMETER "{m}%s " D_UNIT_MICROGRAM_PER_CUBIC_METER "{e}"