From aa97029af7a102de94821229dcf3080db4d684e2 Mon Sep 17 00:00:00 2001 From: lexa Date: Thu, 1 Jul 2021 13:14:59 +0300 Subject: [PATCH] Avg Voltage --- ExtSens/src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ExtSens/src/main.cpp b/ExtSens/src/main.cpp index e751a45..e84a47e 100644 --- a/ExtSens/src/main.cpp +++ b/ExtSens/src/main.cpp @@ -15,7 +15,7 @@ uint32_t cRun; int BATTERY_SENSE_PIN = A0; int sensorValue, batteryPcnt; -float v, temp_out, hum_out; +float v, temp_out, hum_out, v_out; int oldBatteryPcnt = 0; void presentation(); @@ -75,22 +75,22 @@ void loop() { // send(msgHum.set(hum, 1)); } unsigned long battMV = hwCPUVoltage(); - v = battMV / 1000.0; + v_out += (battMV / 1000.0 - v_out) * 0.1; //sensorValue = analogRead(BATTERY_SENSE_PIN); //v = sensorValue * 0.004659498; //batteryPcnt = ((v-3.0) * 100) / 1.2; //sendBatteryLevel(batteryPcnt); - if(nRun++ == 3){ + if(nRun++ == 4){ sendData(msgTemp, temp_out, 1); sendData(msgHum, hum_out, 1); - sendData(msgVolts, v, 2); + sendData(msgVolts, v_out, 2); //send(msgVolts.set(v, 2)); //Serial.println(F("Tm run")); Serial.println(millis() - t); sendData(msgMillis, ++cRun * TIME_SLEEP / 60000); nRun = 0; } //send(msgMillis.set(cRun++)); - sleep((TIME_SLEEP / 4) - (millis() - t)); + sleep((TIME_SLEEP / 5) - (millis() - t)); } void presentation()