vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.93k stars 715 forks source link

ESP32 SIM Card SIM800L T-Call V1.4 - Guru Meditation #537

Closed MaurizioBognolo closed 3 years ago

MaurizioBognolo commented 3 years ago

[x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module

[ ] Bug or problem compiling the library [ ] Bug or issue with library functionality (ie, sending data over TCP/IP) [X] Question or request for help

What are you working with?

Modem: SIM800L Main processor board: ESP32 SIM Card SIM800L T-Call V1.4 TinyGSM version: 0.10.9 Code: // Your GPRS credentials (leave empty, if not needed) const char apn[] = "provider"; const char gprsUser[] = ""; // GPRS User const char gprsPass[] = ""; // GPRS Password

// SIM card PIN (leave empty, if not defined) const char simPIN[] = "";

// Server details // The server variable can be just a domain name or it can have a subdomain. It depends on the service you are using const char server[] = "example.com"; // domain name: example.com, maker.ifttt.com, etc const char resource[] = "/post-data.php"; // resource path, for example: /post-data.php const int port = 80; // server port number

// apiKeyValue String apiKeyValue = "";

// Attivo il debug

define DUMP_AT_COMMANDS

// Attivo debug TinyGSM

define TINY_GSM_DEBUG SerialMon

// VALORI FAKE di TEST

define FAKE_WEIGHT 10.5

// TTGO T-Call pins

define MODEM_RST 5

define MODEM_PWKEY 4

define MODEM_POWER_ON 23

define MODEM_TX 27

define MODEM_RX 26

define I2C_SDA 21

define I2C_SCL 22

// BME280 pins

define I2C_SDA_2 18

define I2C_SCL_2 19

// Set serial for debug console (to Serial Monitor, default speed 115200)

define SerialMon Serial

// Set serial for AT commands (to SIM800 module)

define SerialAT Serial1

// Configure TinyGSM library

define TINY_GSM_MODEM_SIM800 // Modem is SIM800

define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb

// Define the serial console for debug prints, if needed

define DUMP_AT_COMMANDS

include

include

ifdef DUMP_AT_COMMANDS

include

StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);

else

TinyGsm modem(SerialAT);

endif

// I2C for SIM800 (to keep it running when powered from battery) TwoWire I2CPower = TwoWire(0);

// TinyGSM Client for Internet connection TinyGsmClient client(modem);

define uS_TO_S_FACTOR 1000000UL / Conversion factor for micro seconds to seconds /

define TIME_TO_SLEEP 3600 / Time ESP32 will go to sleep (in seconds) 3600 seconds = 1 hour /

define IP5306_ADDR 0x75

define IP5306_REG_SYS_CTL0 0x00

bool setPowerBoostKeepOn(int en){ I2CPower.beginTransmission(IP5306_ADDR); I2CPower.write(IP5306_REG_SYS_CTL0); if (en) { I2CPower.write(0x37); // Set bit1: 1 enable 0 disable boost keep on } else { I2CPower.write(0x35); // 0x37 is default reg value } return I2CPower.endTransmission() == 0; }

void setup() { // Set serial monitor debugging window baud rate to 115200 SerialMon.begin(115200);

// Start I2C communication I2CPower.begin(I2C_SDA, I2C_SCL, 400000);

// Keep power when running from battery bool isOk = setPowerBoostKeepOn(1); SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL"));

// Set modem reset, enable, power pins pinMode(MODEM_PWKEY, OUTPUT); pinMode(MODEM_RST, OUTPUT); pinMode(MODEM_POWER_ON, OUTPUT); digitalWrite(MODEM_PWKEY, LOW); digitalWrite(MODEM_RST, HIGH); digitalWrite(MODEM_POWER_ON, HIGH);

// Set GSM module baud rate and UART pins SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX, false); //added false as described on documentation delay(3000);

// Restart SIM800 module, it takes quite some time // To skip it, call init() instead of restart() SerialMon.println("Initializing modem..."); modem.restart(); // use modem.init() if you don't need the complete restart

// Unlock your SIM card with a PIN if needed if (strlen(simPIN) && modem.getSimStatus() != 3 ) { modem.simUnlock(simPIN); }

// Memorizzo il codice IMEI del modem GSM apiKeyValue = modem.getIMEI(); Serial.println("Modem GSM codice IMEI: " + apiKeyValue);

// Configure the wake up source as timer wake up
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); }

void loop() { SerialMon.print("Connecting to APN: "); SerialMon.print(apn); if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { SerialMon.println(" fail"); } else { SerialMon.println(" OK");

SerialMon.print("Connecting to ");
SerialMon.print(server);
if (!client.connect(server, port)) {
  SerialMon.println(" fail");
}
else {
  SerialMon.println(" OK");

  // Making an HTTP POST request
  SerialMon.println("Performing HTTP POST request...");
  // Prepare your HTTP POST request data (Temperature in Celsius degrees)
  //

  // You can comment the httpRequestData variable above data for testing proposes
  String httpRequestData = "scale_key="+ apiKeyValue + "&weight=12&ti=35&hi=70&te=14&he=80";

  client.print(String("POST ") + resource + " HTTP/1.1\r\n");
  client.print(String("Host: ") + server + "\r\n");
  client.println("Connection: close");
  client.println("Content-Type: application/x-www-form-urlencoded");
  client.print("Content-Length: ");
  client.println(httpRequestData.length());
  client.println();
  client.println(httpRequestData);

  unsigned long timeout = millis();
  while (client.connected() && millis() - timeout < 10000L) {
    // Print available data (HTTP response from server)
    while (client.available()) {
      char c = client.read();
      SerialMon.print(c);
      timeout = millis();
    }
  }
  SerialMon.println();

  // Close client and disconnect
  client.stop();
  SerialMon.println(F("Server disconnected"));
  modem.gprsDisconnect();
  SerialMon.println(F("GPRS disconnected"));
}

} // Put ESP32 into deep sleep mode (with timer wake up) esp_deep_sleep_start(); }

Scenario, steps to reproduce

Power on board with just compiled code.

Expected result

I expect a connection to an internet server and data send. Some times it work. I can't understand why sometimes works and several times it doesn't work. I try with different power supply methods but nothing change. Change antenna without any result. It lalways resets when try to connect to internet and exit with Guru Meditation. Sometime it reboots automatically for 2 or 3 times then stop. Other times it freezes and not reset.

Actual result

First boot

Call Ready Guru Meditation Error: Core panic'ed (Interrupt wdt timeout on CPU1) Core register dump: PC 0x40088a0 PS 0x00060034 A0 0x8008bf A1 0x3fbd0
A2 0x3fb058 A3 0x3f0fe A4 0x3fb06c A5 0x3fbb0
A6 0x3fbb8 A7 0x00000001 A8 0x3fb7c A9 0x00000040
A10 0x00000004 A11 0x3fb7b A12 0x8008c8b A13 0x3fbb0
A14 0x00000008 A15 0x00000001 SAR 0x00000019 EXCCAUSE 0x00000006
EXCVADDR 0x00000000 LBEG 0x400891a LEND 0x400891b ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮R Backtrace:0x40088a0:0x3fbd00x4008bf:0x3fbd00x4008da:0x3fbd00x4008d5a0x00000000

ore register dump: PC 0x400f1e PS 0x00060b4 A0 0x800e652 A1 0x3fb130
A2 0x00000000 A3 0x00000001 A4 0x00000000 A5 0x00000001
A6 0x00060d0 A7 0x00000000 A8 0x800ed6 A9 0x3fb100
A10 0x00000000 A11 0x40086488 A12 0x00060d0 A13 0x3fb7d
A14 0x00000002 A15 0x3fbc8 SAR 0x00000000 EXCCAUSE 0x00000006
EXCVADDR 0x00000000 LBEG 0x00000000 LEND 0x00000000 LCOUNT 0x00000000

ELF file SHA256: 0000000000000000

Backtrace:0x400f1e:0x3fb1300x400e64f0x3fb150 0x4008c7a0x3fb170 0x4008a15:0x3fb190

Rebooting...

Second reboot

SMS Ready Guru Meditation Error: Core panic'ed (Interrupt wdt timeout on CPU1) Core register dump: PC 0x40088a0 PS 0x00060034 A0 0x8008bf A1 0x3fbd0
A2 0x3fb058 A3 0x3f0fe A4 0x3fb06c A5 0x3fbb0
A6 0x3fbb8 A7 0x00000001 A8 0x3fb7c A9 0x00000040
A10 0x00000000 A11 0x3fb060 A12 0x8���������������������������������������������������������������������������������������������������������� A15 0x00000001 SAR 0x00000019 EXCCAUSE 0x00000006
EXCVADDR 0x00000000 LBEG 0x400891a LEND 0x400891b LCOUNT 0xffff

ELF file SHA256: 0000000000000000

Backtrace:0x40088a0:0x3fbd00x4008bf:0x3fbd00x4008da:0x3fbd00x4008d5a0x00000000

ore register dump: PC 0x400f1e PS 0x00060b4 A0 0x800e652 A1 0x3fb130
A2 0x00000000 A3 0x00000001 A4 0x00000000 A5 0x00000001
A6 0x00060d0 A7 0x00000000 A8 0x800ed6 A9 0x3fb100
A10 0x00000000 A11 0x40086488 A12 0x00060d0 A13 0x3fb7d
A14 0x00000002 A15 0x3fbc8 SAR 0x00000000 EXCCAUSE 0x00000006
EXCVADDR 0x00000000 LBEG 0x00000000 LEND 0x00000000 LCOUNT 0x00000000

ELF file SHA256: 0000000000000000

Debug and AT command log

First Boot otained after a reset

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 [D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled IP5306 KeepOn OK Initializing modem... AT ⸮AT ⸮AT

OK AT&W

OK AT+CFUN=0

OK AT+CFUN=1,1

OK [7488] ### TinyGSM Version: 0.10.9 [7488] ### TinyGSM Compiled Module: TinyGsmClientSIM800 AT ⸮⸮AT

OK ATE0

OK AT+CMEE=2

OK AT+GMM

SIMCOM_SIM800L

OK [7799] ### Modem: SIMCOM SIM800L [7799] ### Modem: SIMCOM SIM800L AT+CLTS=1

OK AT+CBATCHK=1

OK AT+CPIN?

+CME ERROR: CFUN state is 0 or 4 AT+CPIN?

RDY

+CFUN: 1

+CPIN: READY

+CPIN: READY

OK AT+GSN

86737205xxxxxxx

OK Modem GSM codice IMEI: 86737205xxxxxxx Connecting to APN: internet.coopvoce.itAT+CIPSHUT

SHUT OK AT+CGATT=0

OK AT+SAPBR=3,1,"Contype","GPRS"

OK AT+SAPBR=3,1,"APN","internet.coopvoce.it"

OK AT+CGDCONT=1,"IP","internet.coopvoce.it"

+CME ERROR: operation not allowed AT+CGACT=1,1

+CME ERROR: operation not allowed AT+SAPBR=1,1

Result second reboot

ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 [D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled IP5306 KeepOn OK Initializing modem... AT

OK AT&W

OK AT+CFUN=0

OK AT+CFUN=1,1

OK [6887] ### TinyGSM Version: 0.10.9 [6887] ### TinyGSM Compiled Module: TinyGsmClientSIM800 AT ⸮AT ⸮ OK ATE0

OK AT+CMEE=2

OK AT+GMM

SIMCOM_SIM800L

OK [7200] ### Modem: SIMCOM SIM800L [7200] ### Modem: SIMCOM SIM800L AT+CLTS=1

OK AT+CBATCHK=1

OK AT+CPIN?

+CME ERROR: CFUN state is 0 or 4 AT+CPIN?

RDY

+CFUN: 1

+CME ERROR: SIM busy AT+CPIN?

+CPIN: READY

+CPIN: READY

OK AT+GSN

86737205xxxxxxx

OK Modem GSM codice IMEI: 86737205xxxxxxx Connecting to APN: internet.coopvoce.itAT+CIPSHUT

SHUT OK AT+CGATT=0

OK AT+SAPBR=3,1,"Contype","GPRS"

OK AT+SAPBR=3,1,"APN","internet.coopvoce.it"

OK AT+CGDCONT=1,"IP","internet.coopvoce.it"

OK AT+CGACT=1,1

Call Ready

SMS Ready

ClemensGruber commented 3 years ago

Is this also happening with the TTGO T-Call demo sketch on https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/tree/master/examples/Arduino_TinyGSM ?

The T-Call has a power management chip on board see https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/blob/master/examples/Arduino_TinyGSM/utilities.h sections for AXP192 or IP5306 -- there are tow different versions of the T-Call with this different chips. So you have to use the T-Call exampe sketch or implement the right power management (that drives the SIM800 also) in your code version!

MaurizioBognolo commented 3 years ago

Is this also happening with the TTGO T-Call demo sketch on https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/tree/master/examples/Arduino_TinyGSM ?

The T-Call has a power management chip on board see https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/blob/master/examples/Arduino_TinyGSM/utilities.h sections for AXP192 or IP5306 -- there are tow different versions of the T-Call with this different chips. So you have to use the T-Call exampe sketch or implement the right power management (that drives the SIM800 also) in your code version!

Thank you for your quick end precious answer. Now I have done some test with the TTGO T-Call demo sketch and it works correctly, so i think there is a problem in my software. Now I'll compare my sketch with the example one and I'll find the bug. I'll keep you informed.