From 3a39d3b4a342bc2f63ea711965734e22e849e5e0 Mon Sep 17 00:00:00 2001 From: Denis Denisov Date: Thu, 25 Dec 2025 09:39:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B0=D1=85=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=20=D0=B4=D0=B0=D1=82=D1=87=D0=B8=D0=BA=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B0=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D1=83=20=D0=BD=D0=B0=D0=B2=D0=B5=D1=80=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thermo_sensor_v2.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thermo_sensor_v2.ino b/thermo_sensor_v2.ino index 809a46b..70879eb 100644 --- a/thermo_sensor_v2.ino +++ b/thermo_sensor_v2.ino @@ -21,6 +21,7 @@ IPAddress subnet(MY_NET); ModbusIP mb; DHT dht(DHTPIN, DHTTYPE); char id[64]; +bool dht_read_error = false; #define REGISTER_CURRENT_TEMP 0 #define REGISTER_CURRENT_HUM 1 @@ -35,6 +36,7 @@ unsigned long current = 0; Modbus::ResultCode OnModbusRequest(Modbus::FunctionCode fc, const Modbus::RequestData data) { last_poll = current; + if (dht_read_error) return Modbus::EX_ILLEGAL_VALUE; return Modbus::EX_SUCCESS; } @@ -81,6 +83,8 @@ void UpdateDHTData() float t = dht.readTemperature(); cur_hum = (int)(h * 100); cur_t = (int)(t * 100); + if (cur_t == 2147483647 && cur_hum == 2147483647) dht_read_error = true; + else dht_read_error = false; } unsigned long last_read = 0;