Merge branch 'nano-revision-2.1' into nano-revision-2.2
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
// include the library code:
|
// include the library code:
|
||||||
#include <SoftRS485.h>
|
#include <SoftRS485.h>
|
||||||
#include <AM2302-Sensor.h>
|
#include <SimpleDHT.h>
|
||||||
|
|
||||||
// 0=Test
|
// 0=Test
|
||||||
// 1=Flur
|
// 1=Flur
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#define ID 0
|
#define ID 0
|
||||||
#define PROGRAM "TempSender"
|
#define PROGRAM "TempSender"
|
||||||
#define SW_VERSION "1.3"
|
#define SW_VERSION "1.4"
|
||||||
#define HW_VERSION "2.2"
|
#define HW_VERSION "2.2"
|
||||||
|
|
||||||
#define BTN_INT 3 // button interrupt pin
|
#define BTN_INT 3 // button interrupt pin
|
||||||
@@ -41,14 +41,16 @@
|
|||||||
//#define LOG_TO_SERIAL
|
//#define LOG_TO_SERIAL
|
||||||
#define SEND_485
|
#define SEND_485
|
||||||
|
|
||||||
AM2302::AM2302_Sensor am2302{DHT_PIN};
|
SimpleDHT11 sensor(DHT_PIN);
|
||||||
|
|
||||||
boolean raw_states[8];
|
boolean raw_states[8];
|
||||||
boolean states[8];
|
boolean states[8];
|
||||||
unsigned long capacitor[8];
|
unsigned long capacitor[8];
|
||||||
unsigned long times[8];
|
unsigned long times[8];
|
||||||
unsigned long sensor_time = 0;
|
unsigned long sensor_time = 0;
|
||||||
|
byte temperature = 0;
|
||||||
|
byte humidity = 0;
|
||||||
|
int err = SimpleDHTErrSuccess;
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
for (int i=0; i<8;i++) {
|
for (int i=0; i<8;i++) {
|
||||||
@@ -57,7 +59,6 @@ void setup(){
|
|||||||
states[i] = LOW;
|
states[i] = LOW;
|
||||||
}
|
}
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
am2302.begin();
|
|
||||||
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
||||||
pinMode(BTN_INT,INPUT_PULLUP);
|
pinMode(BTN_INT,INPUT_PULLUP);
|
||||||
pinMode(14,INPUT_PULLUP);
|
pinMode(14,INPUT_PULLUP);
|
||||||
@@ -133,9 +134,8 @@ void loop(){
|
|||||||
|
|
||||||
if (now - sensor_time > PERIOD){
|
if (now - sensor_time > PERIOD){
|
||||||
sensor_time = now;
|
sensor_time = now;
|
||||||
auto status = am2302.read();
|
if ((err = sensor.read(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
|
||||||
if (status == 0){
|
String s = "{nano:"+String(ID)+",temp:"+String((int)temperature)+",humi:"+String((int)humidity)+"}";
|
||||||
String s = "{nano:"+String(ID)+",temp:"+String(am2302.get_Temperature())+",humi:"+String(am2302.get_Hunidity())+"}";
|
|
||||||
send485(s.c_str());
|
send485(s.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user