Merge branch 'nano-revision-2.0' into nano-revision-2.1
This commit is contained in:
@@ -21,7 +21,7 @@ char c;
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println(PROGRAM);
|
Serial.println(PROGRAM);
|
||||||
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI,6000); // library initialization:
|
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI,4000); // library initialization:
|
||||||
send485(PROGRAM);
|
send485(PROGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#define ID 0
|
#define ID 0
|
||||||
#define HW_VERSION "2.1"
|
#define HW_VERSION "2.1"
|
||||||
#define PROGRAM "TempSender"
|
#define PROGRAM "TempSender"
|
||||||
#define SW_VERSION "1.5"
|
#define SW_VERSION "1.6"
|
||||||
|
|
||||||
#define BTN_INT 3 // button interrupt pin
|
#define BTN_INT 3 // button interrupt pin
|
||||||
#define Max485_RO 2 // read-output of Max485
|
#define Max485_RO 2 // read-output of Max485
|
||||||
@@ -34,7 +34,8 @@
|
|||||||
#define TRESHOLD 1024
|
#define TRESHOLD 1024
|
||||||
#define TRIGGER_LEVEL 200
|
#define TRIGGER_LEVEL 200
|
||||||
|
|
||||||
#define DHT_PIN 4
|
#define DHT1_PIN 4
|
||||||
|
#define DHT2_PIN 5
|
||||||
#define PERIOD 100000000 // 100s
|
#define PERIOD 100000000 // 100s
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
@@ -47,8 +48,10 @@ unsigned long capacitor[8];
|
|||||||
unsigned long times[8];
|
unsigned long times[8];
|
||||||
unsigned long sensor_time = 0;
|
unsigned long sensor_time = 0;
|
||||||
|
|
||||||
// these values are used for temperature processing
|
SimpleDHT22 sensor1(DHT1_PIN);
|
||||||
SimpleDHT22 sensor(DHT_PIN);
|
#ifdef DHT2_PIN
|
||||||
|
SimpleDHT22 sensor2(DHT2_PIN);
|
||||||
|
#endif
|
||||||
float temperature = 0;
|
float temperature = 0;
|
||||||
float humidity = 0;
|
float humidity = 0;
|
||||||
int err = SimpleDHTErrSuccess;
|
int err = SimpleDHTErrSuccess;
|
||||||
@@ -60,7 +63,7 @@ void setup(){
|
|||||||
states[i] = LOW;
|
states[i] = LOW;
|
||||||
}
|
}
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI,4000); // library initialization:
|
||||||
pinMode(BTN_INT,INPUT_PULLUP);
|
pinMode(BTN_INT,INPUT_PULLUP);
|
||||||
pinMode(14,INPUT_PULLUP);
|
pinMode(14,INPUT_PULLUP);
|
||||||
pinMode(15,INPUT_PULLUP);
|
pinMode(15,INPUT_PULLUP);
|
||||||
@@ -135,8 +138,17 @@ void loop(){
|
|||||||
|
|
||||||
if (now - sensor_time > PERIOD){
|
if (now - sensor_time > PERIOD){
|
||||||
sensor_time = now;
|
sensor_time = now;
|
||||||
if ((err = sensor.read2(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
|
String s = "{nano:"+String(ID);
|
||||||
String s = "{nano:"+String(ID)+",temp:"+String(temperature,1)+",humi:"+String(humidity,1)+"}";
|
if ((err = sensor1.read2(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
|
||||||
|
s += ",temp:"+String(temperature,1)+",humi:"+String(humidity,1);
|
||||||
|
}
|
||||||
|
#ifdef DHT2_PIN
|
||||||
|
if ((err = sensor2.read2(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
|
||||||
|
s += ",temp2:"+String(temperature,1)+",humi2:"+String(humidity,1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (s.length()>10){
|
||||||
|
s += "}";
|
||||||
send485(s.c_str());
|
send485(s.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user