power rfid only when not sleeping

This commit is contained in:
Christophe Robillard 2025-12-22 21:10:34 +01:00
parent 5f6a52f6a2
commit c6c70dca76

View file

@ -21,6 +21,7 @@
#define LED_PIN LED_BUILTIN #define LED_PIN LED_BUILTIN
#define SS_PIN SDA #define SS_PIN SDA
#define RC522_POWER_PIN 1
#define SLEEP_DURATION 1 #define SLEEP_DURATION 1
#define RGB_BRIGHTNESS 4 // Change neopixel brightness (max 255) #define RGB_BRIGHTNESS 4 // Change neopixel brightness (max 255)
@ -74,6 +75,8 @@ void setup() {
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
pinMode(RC522_POWER_PIN, OUTPUT);
digitalWrite(RC522_POWER_PIN, HIGH);
reader.PCD_Init(); // Init each MFRC522 card. reader.PCD_Init(); // Init each MFRC522 card.
} }
@ -85,6 +88,7 @@ void loop() {
} }
else { else {
delay(200); delay(200);
digitalWrite(RC522_POWER_PIN, LOW);
ESP.deepSleep(SLEEP_DURATION * 1000000); ESP.deepSleep(SLEEP_DURATION * 1000000);
} }
} }