浏览代码

Changed to mean out of 10 reads

Thomas Chef 8 年之前
父节点
当前提交
23a039ba79
共有 1 个文件被更改,包括 10 次插入3 次删除
  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;