From 67118f5c8f2c7232f83d40d63ba93494a28609b9 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 23 Dec 2023 09:32:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=87=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/S8/S8.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/sensors/S8/S8.cpp b/src/modules/sensors/S8/S8.cpp index ce721103..c600809a 100644 --- a/src/modules/sensors/S8/S8.cpp +++ b/src/modules/sensors/S8/S8.cpp @@ -6,12 +6,14 @@ #define R_LEN 7 #define C_LEN 8 -byte cmd_s8[8] = {0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5}; -//byte abc_s8[8] = {0xFE, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xA1, 0xC3}; + class S8co : public IoTItem { private: + byte cmd_s8[8] = {0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5}; + //byte abc_s8[8] = {0xFE, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xA1, 0xC3}; + SoftwareSerial* s8Serial; unsigned int _s8_co2; @@ -24,6 +26,11 @@ class S8co : public IoTItem { byte _response_s8[7] = {0, 0, 0, 0, 0, 0, 0}; void s8Request(byte cmd[]) { + if (!s8Serial) { + SerialPrint("E", "Sensor S8_uart", "Serial not found!"); + return; + } + while(!s8Serial->available()) { s8Serial->write(cmd, C_LEN); delay(50); @@ -45,7 +52,7 @@ class S8co : public IoTItem { _response_s8[i] = s8Serial->read(); } - s8Serial->end(); + //s8Serial->end(); } void co2_measure() {