Browse Source

replaced sensor library to be able to use DHT11

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
nano-5
Stephan Richter 1 month ago
parent
commit
c0ccaa4835
  1. 16
      Software/TempSender/TempSender.ino

16
Software/TempSender/TempSender.ino

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
// include the library code:
#include <SoftRS485.h>
#include <AM2302-Sensor.h>
#include <SimpleDHT.h>
// 0=Test
// 1=Flur
@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
#define ID 0
#define PROGRAM "TempSender"
#define SW_VERSION "1.3"
#define SW_VERSION "1.4"
#define HW_VERSION "2.0"
#define BTN_INT 2 // button interrupt pin
@ -41,14 +41,16 @@ @@ -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(){ @@ -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(){ @@ -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());
}
}

Loading…
Cancel
Save