Avg Voltage

This commit is contained in:
2021-07-01 13:14:59 +03:00
parent 9615b66a84
commit aa97029af7

View File

@@ -15,7 +15,7 @@
uint32_t cRun; uint32_t cRun;
int BATTERY_SENSE_PIN = A0; int BATTERY_SENSE_PIN = A0;
int sensorValue, batteryPcnt; int sensorValue, batteryPcnt;
float v, temp_out, hum_out; float v, temp_out, hum_out, v_out;
int oldBatteryPcnt = 0; int oldBatteryPcnt = 0;
void presentation(); void presentation();
@@ -75,22 +75,22 @@ void loop() {
// send(msgHum.set(hum, 1)); // send(msgHum.set(hum, 1));
} }
unsigned long battMV = hwCPUVoltage(); unsigned long battMV = hwCPUVoltage();
v = battMV / 1000.0; v_out += (battMV / 1000.0 - v_out) * 0.1;
//sensorValue = analogRead(BATTERY_SENSE_PIN); //sensorValue = analogRead(BATTERY_SENSE_PIN);
//v = sensorValue * 0.004659498; //v = sensorValue * 0.004659498;
//batteryPcnt = ((v-3.0) * 100) / 1.2; //batteryPcnt = ((v-3.0) * 100) / 1.2;
//sendBatteryLevel(batteryPcnt); //sendBatteryLevel(batteryPcnt);
if(nRun++ == 3){ if(nRun++ == 4){
sendData(msgTemp, temp_out, 1); sendData(msgTemp, temp_out, 1);
sendData(msgHum, hum_out, 1); sendData(msgHum, hum_out, 1);
sendData(msgVolts, v, 2); sendData(msgVolts, v_out, 2);
//send(msgVolts.set(v, 2)); //send(msgVolts.set(v, 2));
//Serial.println(F("Tm run")); Serial.println(millis() - t); //Serial.println(F("Tm run")); Serial.println(millis() - t);
sendData(msgMillis, ++cRun * TIME_SLEEP / 60000); sendData(msgMillis, ++cRun * TIME_SLEEP / 60000);
nRun = 0; nRun = 0;
} }
//send(msgMillis.set(cRun++)); //send(msgMillis.set(cRun++));
sleep((TIME_SLEEP / 4) - (millis() - t)); sleep((TIME_SLEEP / 5) - (millis() - t));
} }
void presentation() void presentation()