warn if battery < 2.6V
This commit is contained in:
parent
710b1a7f79
commit
d7750f81c9
1 changed files with 15 additions and 0 deletions
15
the-cup.ino
15
the-cup.ino
|
|
@ -19,6 +19,8 @@
|
||||||
#include <MFRC522DriverPinSimple.h>
|
#include <MFRC522DriverPinSimple.h>
|
||||||
#include <MFRC522Debug.h>
|
#include <MFRC522Debug.h>
|
||||||
|
|
||||||
|
#include "Adafruit_MAX1704X.h"
|
||||||
|
|
||||||
#define SS_PIN SDA
|
#define SS_PIN SDA
|
||||||
#define RC522_POWER_PIN 1
|
#define RC522_POWER_PIN 1
|
||||||
#define SLEEP_DURATION 1
|
#define SLEEP_DURATION 1
|
||||||
|
|
@ -31,6 +33,8 @@ MFRC522 reader{driver_1}; // Create MFRC522 instance.
|
||||||
|
|
||||||
RTC_DATA_ATTR int nbCycles = 0;
|
RTC_DATA_ATTR int nbCycles = 0;
|
||||||
|
|
||||||
|
Adafruit_MAX17048 lipo;
|
||||||
|
|
||||||
const char *rootCACertificate = R"string_literal(
|
const char *rootCACertificate = R"string_literal(
|
||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
||||||
|
|
@ -76,6 +80,8 @@ void setup() {
|
||||||
Serial.println(nbCycles++);
|
Serial.println(nbCycles++);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
measureBattery();
|
||||||
|
|
||||||
pinMode(RC522_POWER_PIN, OUTPUT);
|
pinMode(RC522_POWER_PIN, OUTPUT);
|
||||||
digitalWrite(RC522_POWER_PIN, HIGH);
|
digitalWrite(RC522_POWER_PIN, HIGH);
|
||||||
reader.PCD_Init(); // Init each MFRC522 card.
|
reader.PCD_Init(); // Init each MFRC522 card.
|
||||||
|
|
@ -97,6 +103,15 @@ void loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void measureBattery() {
|
||||||
|
if (nbCycles % 10) {
|
||||||
|
lipo.begin();
|
||||||
|
if (lipo.cellVoltage() < 2.6) {
|
||||||
|
displayError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void readCard(char reader_uid[]) {
|
void readCard(char reader_uid[]) {
|
||||||
reader.PICC_HaltA();
|
reader.PICC_HaltA();
|
||||||
reader.PCD_StopCrypto1();
|
reader.PCD_StopCrypto1();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue