Hallo zusammen,
ich wende mich an euch, da ich gerade an einer Stelle nicht weiterkomme und meine Test leider nicht erfolgreich waren.
Ich möchte gerne einen ESP32 aus dem Deepsleep mittels einem 3x4 Keypad Matrix aufwachen lassen.
Meine aktuelle Idee ist es, dies mittels meinem "External WakeUp (EXT0)" zu realisieren.
Bei einem Push-Button klappt das auch ohne Probleme, aber ein Keypad ist ja anders aufgebaut.
Habt ihr eine Idee, wie ich vorgehen könnte? Mir fehlt leider ein bisschen das technische Verständnis dazu.
Anbei noch zwei Sketche, ggf. für euch hilfreich...
Vielen Dank für eure Hilfe!
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { A4, A5, A14, A13 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { A17, A16, A10 };
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin A12
void setup()
{
pinMode(ledpin,OUTPUT);
digitalWrite(ledpin, HIGH);
delay(2000);
digitalWrite(ledpin,LOW);
Serial.begin(115200);
}
void loop()
{
char key = kpd.getKey();
if(key) // Check for a valid key.
{
switch (key)
{
case '*':
digitalWrite(ledpin, LOW);
break;
case '#':
digitalWrite(ledpin, HIGH);
break;
default:
Serial.println(key);
}
}
}
RTC_DATA_ATTR int bootCount = 0;
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason() {
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
Serial.println("");
Serial.println("");
Serial.println("");
Serial.println("EXT0 Test");
switch (wakeup_reason)
{
case 1 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
case 2 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case 3 : Serial.println("Wakeup caused by timer"); break;
case 4 : Serial.println("Wakeup caused by touchpad"); break;
case 5 : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.println("Wakeup was not caused by deep sleep"); break;
}
}
void setup() {
Serial.begin(115200);
delay(50); //Take some time to open up the Serial Monitor
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
//Print the wakeup reason for ESP32
print_wakeup_reason();
/*
First we configure the wake up source
We set our ESP32 to wake up for an external trigger.
There are two types for ESP32, ext0 and ext1 .
ext0 uses RTC_IO to wakeup thus requires RTC peripherals
to be on while ext1 uses RTC Controller so doesnt need
peripherals to be powered on.
Note that using internal pullups/pulldowns also requires
RTC peripherals to be turned on.
*/
Serial.println(esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, 1)); //1 = High, 0 = Low
//Go to sleep now
Serial.println("Going to sleep now");
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void loop() {
//This is not going to be called
}