X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/e4e1557426f8e5ca10ca616140528939d86426cd..042de91dcd2c71ef304c1119d2e15caba47e2c8f:/Weather_WH2.ino?ds=inline diff --git a/Weather_WH2.ino b/Weather_WH2.ino index 0977862..a61dbff 100644 --- a/Weather_WH2.ino +++ b/Weather_WH2.ino @@ -17,7 +17,7 @@ BMP085 bmp; // Humidity sensor at pin 4 #define DHT11PIN 5 - +int sensorPin = 0; #define DEBUG // LED pins @@ -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,9 +177,12 @@ unsigned long outdoor_interval = 45000; unsigned long previousIndoor = 0; unsigned long previousOutdoor = 0; +float temperature; +float pressure; void loop() { unsigned long now; + int gas = 0; byte i; now = millis(); @@ -211,7 +225,7 @@ void loop() { if ((unsigned long)(now - previousMillis) >= indoor_interval) { previousMillis = now; - + int chk = DHT.read11(DHT11PIN); if (chk==0) { @@ -223,13 +237,6 @@ 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); @@ -243,6 +250,19 @@ 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); + + gas = analogRead(sensorPin); // Получаем значения из датчика + Serial1.print("SENSOR:TYPE=GAS,VALUE="); + Serial1.println(gas); // Пишем в серийный порт + } if ((unsigned long)(now - previousIndoor) > indoor_interval*10) {