Explorar o código

Changed to mean out of 10 reads

Thomas Chef %!s(int64=8) %!d(string=hai) anos
pai
achega
23a039ba79
Modificáronse 1 ficheiros con 10 adicións e 3 borrados
  1. 10 3
      repeater.ino

+ 10 - 3
repeater.ino

@@ -160,15 +160,22 @@ void loop() {
   
   if( now > previous_lux_time  ) {
       // Yes ! It's time to measure lux value
-      int32_t lux = readLuxSensor();
+      uint64_t luxm=0;
+      for(int i=1; i<=10; i++ ) {
+        int32_t lux_temp = readLuxSensor();
+        luxm += lux_temp;
+      }
+      luxm /= 10;      
+
+      uint32_t lux = (uint32_t) luxm;
       
       if( lux > 0xFFFF ) lux=0xFFFF;
       if( lux < 0 ) lux=0;
       
-      //Serial.println(lux);
+      Serial.println(lux);
       
       // Set next measure to 3 minutes +/- 20 sec
-      previous_lux_time = now + 170000 + (random(20)*1000);
+      previous_lux_time = now + 120000 + (random(20)*1000);
       
       txDataReady = 1;