From 2af24084f6a12980933eabb23d3bde41b8fd1a1f Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Sat, 27 Sep 2014 01:08:25 +0400 Subject: [PATCH 1/1] =?utf8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?utf8?q?=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0?= =?utf8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BF=D1=80=D0=B8=20?= =?utf8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B5=20=D1=81=20=D0=BF=D1=80?= =?utf8?q?=D0=BE=D0=B2=D0=BE=D0=B4=D0=BD=D1=8B=D0=BC=D0=B8=20=D0=B4=D0=B0?= =?utf8?q?=D1=82=D1=87=D0=B8=D0=BA=D0=B0=D0=BC=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Weather_WH2.ino | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Weather_WH2.ino b/Weather_WH2.ino index a1796cc..175721e 100644 --- a/Weather_WH2.ino +++ b/Weather_WH2.ino @@ -137,7 +137,18 @@ ISR(TIMER1_COMPA_vect) } void setup() { - + + Serial1.begin(115200); // Set the baud. + + // Wait for U-boot to finish startup. Consume all bytes until we are done. + do { + while (Serial1.available() > 0) { + Serial1.read(); + } + + delay(1000); + } while (Serial1.available()>0); + Serial1.begin(57600); Serial1.println(); Serial1.println("STATUS:STARTING"); @@ -166,6 +177,8 @@ unsigned long outdoor_interval = 45000; unsigned long previousIndoor = 0; unsigned long previousOutdoor = 0; +float temperature; +float pressure; void loop() { unsigned long now; @@ -211,7 +224,7 @@ void loop() { if ((unsigned long)(now - previousMillis) >= indoor_interval) { previousMillis = now; - + int chk = DHT.read11(DHT11PIN); if (chk==0) { @@ -223,16 +236,10 @@ void loop() { Serial1.print(",TEMPERATURE="); Serial1.print(DHT.temperature); - Serial1.println(); - Serial1.print("SENSOR:TYPE=BARO,"); - Serial1.print("PRESSURE="); - Serial1.print(bmp.readPressure()); - Serial1.print(",TEMPERATURE="); - Serial1.println(bmp.readTemperature()); - previousIndoor = now; digitalWrite(GREENPIN,HIGH); + } else { Serial1.println(); @@ -242,6 +249,15 @@ void loop() { } + pressure=bmp.readPressure(); + temperature=bmp.readTemperature(); + Serial1.println(); + Serial1.print("SENSOR:TYPE=BARO,"); + Serial1.print("PRESSURE="); + Serial1.print(pressure); + Serial1.print(",TEMPERATURE="); + Serial1.println(temperature); + } if ((unsigned long)(now - previousIndoor) > indoor_interval*10) { @@ -262,6 +278,7 @@ void loop() { } + } -- 2.34.1