voltage pin changed

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

View File

@ -41,53 +41,8 @@ RST -> 33
``` ```
#### Registers #### RFID Chip Registers
```
Writing 0x7F to the "ComIEnReg" means the following:
Bit 7: IRqInv=0 - Interrupts are active high
Bit 6: TxIEn=1 - Transmitter interrupt is enabled
Bit 5: RxIEn=1 - Receive interrupt is enabled
Bit 4: IdleIEn=1 - Idle interrupt is enabled
Bit 3: HiAlertIEn=1 - "High Alert" interrupt is enabled
Bit 2: LoAlertIEn=1 - "Low Alert" interrupt is enabled
Bit 1: ErrIEn=1 - Error interrupt is enabled
Bit 0: TimerIEn=1 - Timer interrupt is enabled
The bits in the register "ComIrqReg" have the following meaning:
Bit 7: Set1 - when written as 1, a bit value of 1 in bits 6-0 of the byte written set the corresponding register bit; when written as 0, bits 6-0 clear the corresponding register bit
Bit 6: TxIRq - Set when the last bit of Tx data has been sent
Bit 5: RxIRq - Set when the receiver detects the end of a valid data stream
Bit 4: IdleIRq - Set when the CommandReg changes the command field to the idle command
Bit 3: HiAlertIRq - Set when the Status1 register HiAlert bit is set
Bit 2: LoAlertIRq - Set when the Status1 register LoAlert bit is set
Bit 1: ErrIRq - Set when any bit in ErrorReg gets set
Bit 0: TimerIRq - Set when the TCounterValReg decrements to zero
Writing 0x14 to the "DivIEnReg" has the following meaning:
Bit 7: IRQPushPull=0 - IRQ is an open-drain output pin
Bit 6: reserved=0 - no known effect
Bit 5: reserved=0 - effect unknown
Bit 4: MfinActEn=1 - Allow the MFIN active interrupt request to trigger IRQ
Bit 3: reserved=0 - boundedly undefined
Bit 2: CRCIEn=1 - Permit the "DivIrqReg" bit CRCIRq to trigger IRQ
Bit 1: reserved=0 - do not set to 1 on pain of nothing
Bit 0: reserved=0 - has no purpose other than to confuse
The register "DivIrqReg" corresponds to "DivIrqEn", and has the following bit definitions:
Bit 7: Set2 - when written as 1, a bit value of 1 in bits 6-0 of the byte written set the corresponding register bit; when written as 0, bits 6-0 clear the corresponding register bit
Bit 6: reserved - don't ask
Bit 5: reserved - don't tell
Bit 4: MfinActIRq - MFIN is active
Bit 3: reserved - just leave it at zero and back away slowly
Bit 2: CRCIRq - when 1, the CalcCRC command is active and all data is processed
Bit 1: reserved - nothing to see here
Bit 0: reserved - are you feeling lucky, punk?
```
Interrupt method was not working because it seems reading a card does not trigger one. Interrupt method was not working because it seems reading a card does not trigger one.
See https://arduino.stackexchange.com/a/76285 and https://github.com/miguelbalboa/rfid/blob/master/examples/MinimalInterrupt/MinimalInterrupt.ino See https://arduino.stackexchange.com/a/76285 and https://github.com/miguelbalboa/rfid/blob/master/examples/MinimalInterrupt/MinimalInterrupt.ino

View File

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

View File

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