Merge branch 'master' of mjesec.ffzg.hr:/git/Arduino
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 9 May 2019 07:47:17 +0000 (09:47 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 9 May 2019 07:47:17 +0000 (09:47 +0200)
rpi_promini/rpi_promini.ino

index 38d318d..cfaa948 100644 (file)
@@ -40,7 +40,7 @@ DallasTemperature sensors(&oneWire);
 int int_0 = 300; // ms
 int int_1 = 900; // ms
 int wait  = 2000; // ms
-int repeat = 20; // times (5 times seem a little low for sensors which are more than 10m away)
+int repeat = 5; // times (5 times seem a little low for sensors which are more than 10m away)
 
 void send_315(char *code) {
   Serial.print("send 315Mhz ");
@@ -114,11 +114,13 @@ unsigned long time = millis();
 void loop() {
   if ( millis() - time > 2000 ) {
     float t = dht.getTemperature();
-    if ( dht.getStatus() == 0 )
+    float delta_t = abs(t - temp_avg.getAverage());
+    if ( dht.getStatus() == 0 && delta_t < 10 )
       temp_avg.addValue( t );
     else dht22_errors++;
     float h = dht.getHumidity();
-    if ( dht.getStatus() == 0 )
+    float delta_h = abs(h - hum_avg.getAverage());
+    if ( dht.getStatus() == 0 && delta_h < 10 )
       hum_avg.addValue( h );
     else dht22_errors++;
     time = millis();