Xinyuan-LilyGO / LilyGo-T-Call-SIM800

https://www.aliexpress.com/item/33045221960.html
482 stars 239 forks source link

SIM800 Ring Output produces unexpected interrupts #144

Closed Paulsburg closed 3 years ago

Paulsburg commented 3 years ago

Hi Folk, I am using the Lilygo TTGO T-Call-SIM800 version 4.

I want to wakeup the esp32 from sleep by producing an interrupt from the SIM800 ringline, connected to GPIO 33 of the esp32.

Unfortunately, some microseconds after going sleep, the esp 32 is wakeup by an RST IO Event on pin 33. If I use another pin, i.e. pin12 with a switch, its running very well.

Background: I want to wakeup the esp32 by sending an SMS to the SIM800L and hope the ringline will be pulled down by the SIM800L. The pin 33 has no external pullup resistor, but I tried it with 12k to 3V3 with no change in the behavior.

pinMode(SIM800ringPin, INPUT); gpio_pullup_en(SIM800ringPin); gpio_pulldown_dis(SIM800ringPin);

Serial.println("Status SIM800ringPin: " + String(digitalRead(SIM800ringPin)));

esp_sleep_enable_ext0_wakeup(SIM800ringPin, 0);

esp_sleep_enable_timer_wakeup(30 * uS_TO_S_FACTOR); // diese Routine weckt den ESP32 nach xy sec wakeup_reason = esp_sleep_get_wakeup_cause(); switch(wakeup_reason){ // ------------------------------------------------------------------------------------------------------------------------------- case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; // ------------------------------------------------------------------------------------------------------------------------------- case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; // ------------------------------------------------------------------------------------------------------------------------------- case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break; // ------------------------------------------------------------------------------------------------------------------------------- case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break; case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break; // ------------------------------------------------------------------------------------------------------------------------------- default : Serial.printf("Wakeup was caused by POWER_ON or RESET: %d\n",wakeup_reason); break; // ------------------------------------------------------------------------------------------------------------------------------- } // Ende SWITCH

Serial.printf("deep_sleep_start()");
esp_deep_sleep_start();

Serial.println("ERROR: This will never be printed");
Paulsburg commented 3 years ago

... and here you can find the concerning serial output:

11:31:30.017 -> Status SIM800ringPin: 1 11:31:30.017 -> Wakeup caused by external signal using RTC_IO 11:31:30.017 -> deep_sleep_start()ets Jun 8 2016 00:22:57 11:31:30.057 -> 11:31:30.057 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) 11:31:30.057 -> configsip: 0, SPIWP:0xee 11:31:30.057 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 11:31:30.057 -> mode:DIO, clock div:1 11:31:30.057 -> load:0x3fff0018,len:4 11:31:30.057 -> load:0x3fff001c,len:1216 11:31:30.057 -> ho 0 tail 12 room 4 11:31:30.057 -> load:0x40078000,len:10944 11:31:30.057 -> load:0x40080400,len:6388 11:31:30.057 -> entry 0x400806b4 11:31:31.177 -> 11:31:31.177 -> 11:31:31.177 -> 11:31:31.177 -> 11:

Paulsburg commented 3 years ago

and for a complete documentation, here is the definition of the esp32 pin I am using to detect the ring signal from SIM800L:

define SIM800ringPin GPIO_NUM_33 // Board TTGO T1 Vers. 1.4

LilyGO commented 3 years ago

In the following code, IO33 is awakened when low

include "esp_sleep.h"

void print_wakeup_reason(){ esp_sleep_wakeup_cause_t wakeup_reason;

wakeup_reason = esp_sleep_get_wakeup_cause();

switch(wakeup_reason) { case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break; case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break; case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break; default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break; } }

void setup(){ Serial.begin(115200); delay(1000); //Take some time to open up the Serial Monitor

//Print the wakeup reason for ESP32 print_wakeup_reason();

esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,0); //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(){ }