Hi, I am using the following hardware:
ESP32-S3 with Serial on the USB for diags. CDC enabled.
Sara Ublox R4 on Serial0
ESP Arduinio core was tested on both 2.0.11 and 3.0.0 - both have the same issue.
The following code is to attach WiFi and Cellular as a backup. It compiles fine with no warnings, attaches the WiFi and cellular secure clients just fine but resets the processor when the main loop is called. All that is in the loop is blynk.run();
Is anybody able to help to find out what goes on?
This is the crash log:
12:45:34.379 -> .[ 20305][V][WiFiGeneric.cpp:357] _arduino_event_cb(): STA Connected: SSID: WFH-Guest, BSSID: 68:13:24:d1:92:ca, Channel: 10, Auth: WPA_WPA2_PSK
12:45:34.415 -> [ 20307][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
12:45:34.448 -> [ 20354][V][WiFiGeneric.cpp:371] _arduino_event_cb(): STA Got New IP:192.168.8.113
12:45:34.448 -> [ 20354][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
12:45:34.448 -> [ 20357][D][WiFiGeneric.cpp:1102] _eventCallback(): STA IP: 192.168.8.113, MASK: 255.255.255.0, GW: 192.168.8.1
12:45:35.378 -> Connected to WFH-Guest
12:45:35.378 -> Wifi addedGSM addedConfig done.waited done.=========== After Setup Start ============
12:45:47.378 -> INTERNAL Memory Info:
12:45:47.378 -> ------------------------------------------
12:45:47.378 -> Total Size : 367048 B ( 358.4 KB)
12:45:47.378 -> Free Bytes : 275480 B ( 269.0 KB)
12:45:47.378 -> Allocated Bytes : 83648 B ( 81.7 KB)
12:45:47.378 -> Minimum Free Bytes: 272140 B ( 265.8 KB)
12:45:47.378 -> Largest Free Block: 262132 B ( 256.0 KB)
12:45:47.378 -> ------------------------------------------
12:45:47.378 -> GPIO Info:
12:45:47.432 -> ------------------------------------------
12:45:47.432 -> GPIO : BUS_TYPE[bus/unit][chan]
12:45:47.432 -> --------------------------------------
12:45:47.432 -> 2 : GPIO
12:45:47.432 -> 19 : USB_DM
12:45:47.432 -> 20 : USB_DP
12:45:47.432 -> 37 : GPIO
12:45:47.432 -> 38 : GPIO
12:45:47.432 -> 42 : GPIO
12:45:47.432 -> 43 : UART_TX[0]
12:45:47.432 -> 44 : UART_RX[0]
12:45:47.432 -> ============ After Setup End =============
12:45:47.448 -> [ 33351][V][ssl_client.cpp:323] stop_ssl_socket(): Cleaning SSL connection.
12:45:47.576 -> Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
12:45:47.576 ->
12:45:47.576 -> Core 1 register dump:
12:45:47.576 -> PC : 0x42003ecc PS : 0x00060930 A0 : 0x82003fab A1 : 0x3fcec010
12:45:47.576 -> A2 : 0x3fc99880 A3 : 0x00020f58 A4 : 0x00000000 A5 : 0x00008248
12:45:47.576 -> A6 : 0x00000000 A7 : 0x00008248 A8 : 0x82003e94 A9 : 0x3fcebff0
12:45:47.576 -> A10 : 0x00008248 A11 : 0x00000000 A12 : 0x00000830 A13 : 0x3fcf20c4
12:45:47.576 -> A14 : 0x3c0b1c09 A15 : 0x00000083 SAR : 0x0000000a EXCCAUSE: 0x0000001c
12:45:47.576 -> EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
12:45:47.576 ->
12:45:47.576 ->
12:45:47.576 -> Backtrace: 0x42003ec9:0x3fcec010 0x42003fa8:0x3fcec040 0x4209c551:0x3fcec060 0x4200498e:0x3fcec080 0x42004a40:0x3fcec0b0 0x4200f714:0x3fcec0d0
12:45:47.576 ->
12:45:47.576 ->
12:45:47.576 ->
12:45:47.576 ->
12:45:47.576 -> ELF file SHA256: 1bdffe5d30b383bf
12:45:47.576 ->
12:45:47.576 -> Rebooting...
and this is the code:
/*
Running on TLS 1.2 using mbedTLS
*/
/* Fill in information from Blynk Device Info here */
char apn[] = "hologram";
char user[] = "";
char gsmPass[] = "";
#define BLYNK_TEMPLATE_ID "<my template>"
#define BLYNK_TEMPLATE_NAME "<my template name>"
#define BLYNK_AUTH_TOKEN "<my auth>i"
//#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
//#define BLYNK_TINYGSM_YEALD
// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial
#define SerialAT Serial0
// Default heartbeat interval for GSM is 60
// #define BLYNK_HEARTBEAT 30
// Define the serial console for debug prints, if needed
#define TINY_GSM_DEBUG SerialMon
//#define DUMP_AT_COMMANDS
#define TINY_GSM_MODEM_SARAR4
//#define USE_SSL // this is for modem only.
#define M_RST 35
#define M_NET 36
#define M_RTS 37
#define M_CTS 38
#define M2_TXD 39
#define M2_RXD 40
#define M2_RTS 41
#define M2_CTS 42
#define M_PWR 2
#define rtsOn digitalWrite(M_RTS, LOW)
#define rtsOff digitalWrite(M_RTS, HIGH)
#define ctsOn digitalRead(M_CTS) == 0
#define ctsOff digitalRead(M_CTS) == 1
#define gsmIsOn digitalRead(M2_CTS) == 1
// Increase RX buffer if needed
#define TINY_GSM_RX_BUFFER 1024
int gsmIsOff(void);
void gsmPowerOff(void);
void gsmPowerOn(void);
void connectGPRS();
#include <BlynkMultiClient.h>
#include <TinyGsmClient.h>
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
TinyGsmClientSecure client(modem);
#include <WiFiClientSecure.h>
const char* ssid = "<my ssid>"; // your network SSID (name of wifi network)
const char* password = "<my WiFi pass>"; // your network password
// root ca cert for the wifi - Ublox cert loaded in manually and tested OK.
const char* blynk_root_ca= \
"-----BEGIN CERTIFICATE-----\n" \
"MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" \
"TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" \
"cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" \
"WhcNMzUwNjA0MTEwNDM4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LHYGmkgJykIrGF1XIpu+ILlaS/V9lZL\n" \
"ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ\n" \
"3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK\n" \
"NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n" \
"ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n" \
"TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n" \
"jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" \
"oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" \
"4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" \
"mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" \
"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" \
"-----END CERTIFICATE-----\n";
static WiFiClientSecure blynkWiFiClientSSL;
static TinyGsmClientSecure blynkGSMClientSSL;
void setup() {
pinMode(M_PWR, OUTPUT); //
pinMode(M_RTS, OUTPUT); //
pinMode(M_CTS, INPUT); //
pinMode(M2_CTS, INPUT); //
//Initialize serial and wait for port to open:
SerialMon.begin(115200);
delay(10);
SerialAT.begin(115200);
delay(10);
SerialMon.println ("Start.."); //Serial is usb, Serial 0 is the tx/rx
rtsOn;
SerialMon.println("Initializing modem..."); // this will ready the GSM modem and it should auto attach to GPRS if it can
if (!modem.restart()) {
gsmPowerOn();
modem.setPhoneFunctionality(15, true); // reset the modem.
}
connectGPRS();
SerialMon.print("Attempting to connect to SSID: ");
SerialMon.println(ssid);
WiFi.begin(ssid, password);
// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
SerialMon.print(".");
// wait 1 second for re-trying
delay(1000);
}
SerialMon.print("Connected to ");
SerialMon.println(ssid);
blynkWiFiClientSSL.setCACert(blynk_root_ca);
//blynkWiFiClientSSL.setCertificate(blynk_root_ca); // for client verification
//blynkWiFiClientSSL.setPrivateKey(blynk_root_ca); // for client verification
Blynk.addClient("WiFi", blynkWiFiClientSSL, 443);
SerialMon.print("Wifi added");
delay(1000);
Blynk.addClient("GSM", blynkGSMClientSSL, 443);
SerialMon.print("GSM added");
delay(1000);
Blynk.config(BLYNK_AUTH_TOKEN);
SerialMon.print("Config done.");
delay(10000);
SerialMon.print("waited done.");
}
void loop() {
Blynk.run();
}
void gsmPowerOn(void){
// if (gsmIsOn){
if (!modem.testAT (500)){
digitalWrite(M_PWR, HIGH); // sets the digital pin 13 on
delay(2000); // waits for a second
digitalWrite(M_PWR, LOW); // sets the digital pin 13 off
delay(2000); // waits for a second
}
}
void gsmPowerOff(void){
// if (gsmIsOn){
if (!modem.testAT (500)){
digitalWrite(M_PWR, HIGH); // sets the digital pin 13 on
delay(2000); // waits for a second
digitalWrite(M_PWR, LOW); // sets the digital pin 13 off
delay(2000); // waits for a second
}
}
int gsmIsOff(void){
while (Serial0.available() > 0){
Serial0.read();
}
Serial0.println("AT");
delay (500);
if (Serial0.available() == 0){
return (1);
}
else{
while (Serial0.available() > 0){
Serial0.read();
}
return (0);
}
}
void connectGPRS()
{
String modemInfo = modem.getModemInfo();
SerialMon.print("Modem Info: ");
SerialMon.println(modemInfo);
SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(1000);
return;
}
SerialMon.println(" success");
if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); }
// GPRS connection parameters are usually set after network registration
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, gsmPass)) {
SerialMon.println(" fail");
delay(1000);
return;
}
SerialMon.println(" success");
if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); }
}
Thanks for any input.
Brian.