voltage pin changed

This commit is contained in:
2023-10-31 19:48:05 +01:00
parent 9c4b1d4913
commit 4cb90a145f
3 changed files with 20 additions and 58 deletions

View File

@@ -67,6 +67,8 @@ uint8_t buttontoignore = 0;
uint32_t lastVoltage = 0;
uint loopCounter = 0;
const int startDelay = 250;
String lastUid = "";
@@ -97,9 +99,9 @@ const long sleepDelay = 30000;
*/
//const long sleepMessageDelay = 1798000;
const long sleepMessageDelay = 22000;
const long sleepMessageDelay = 1798000;
// wait until deep sleep:1800000
const long sleepDelay = 25000;
const long sleepDelay = 1800000;
#endif

View File

@@ -31,9 +31,11 @@
#define CS_SDCARD 22
#define BAT_VOLTAGE_PIN 13
#define BAT_VOLTAGE_PIN 35
#define RFID_LOOP_INTERVAL 25
#define RFID_LOOP_INTERVAL 30
#define VOLTAGE_LOOP_INTERVAL 5000
#include "globals.h"
#include "WebContent.h"
@@ -53,8 +55,6 @@ Audio audio;
uint volume = 7;
uint rfid_loop = RFID_LOOP_INTERVAL;
AsyncWebServer server(80);
DNSServer dns;
@@ -110,6 +110,8 @@ void deactivateRFID()
uint32_t getBatteryVoltageMv() {
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
Serial.print("Battery Voltage: ");
Serial.println(voltage*2);
return voltage*2;//*2 because of the voltage divider.
}
@@ -456,9 +458,6 @@ void setup()
lastVoltage = getBatteryVoltageMv();
Serial.print("Battery Voltage in mV: ");
Serial.println(lastVoltage);
// first parameter is name of access point, second is the password
AsyncWiFiManager wifiManager(&server, &dns);
@@ -659,11 +658,10 @@ void loop()
Serial.println("Previous not yet implemented!");
}
rfid_loop--;
if (rfid_loop == 0)
if (loopCounter % RFID_LOOP_INTERVAL == 0)
{
rfid_loop = RFID_LOOP_INTERVAL;
deactivateSD();
activateRFID();
if (rfid.PICC_IsNewCardPresent())
@@ -672,6 +670,13 @@ void loop()
readRFID();
}
}
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0)
{
lastVoltage = getBatteryVoltageMv();
}
loopCounter++;
}
void loop2(void *parameter)