diff --git a/Software/TempSender/TempSender.ino b/Software/TempSender/TempSender.ino index 1f27ed3..58bb346 100644 --- a/Software/TempSender/TempSender.ino +++ b/Software/TempSender/TempSender.ino @@ -10,7 +10,7 @@ // include the library code: #include -#include +#include // 0=Test // 1=Flur @@ -22,7 +22,7 @@ #define ID 0 #define PROGRAM "TempSender" -#define SW_VERSION "1.3" +#define SW_VERSION "1.4" #define HW_VERSION "2.2" #define BTN_INT 3 // button interrupt pin @@ -41,14 +41,16 @@ //#define LOG_TO_SERIAL #define SEND_485 -AM2302::AM2302_Sensor am2302{DHT_PIN}; +SimpleDHT11 sensor(DHT_PIN); boolean raw_states[8]; boolean states[8]; unsigned long capacitor[8]; unsigned long times[8]; unsigned long sensor_time = 0; - +byte temperature = 0; +byte humidity = 0; +int err = SimpleDHTErrSuccess; void setup(){ for (int i=0; i<8;i++) { @@ -57,7 +59,6 @@ void setup(){ states[i] = LOW; } Serial.begin(115200); - am2302.begin(); init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization: pinMode(BTN_INT,INPUT_PULLUP); pinMode(14,INPUT_PULLUP); @@ -133,9 +134,8 @@ void loop(){ if (now - sensor_time > PERIOD){ sensor_time = now; - auto status = am2302.read(); - if (status == 0){ - String s = "{nano:"+String(ID)+",temp:"+String(am2302.get_Temperature())+",humi:"+String(am2302.get_Hunidity())+"}"; + if ((err = sensor.read(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) { + String s = "{nano:"+String(ID)+",temp:"+String((int)temperature)+",humi:"+String((int)humidity)+"}"; send485(s.c_str()); } }