abort() was called at PC 0x400e1e36 on core 1 in ESP32

1.1k Views Asked by At

I am working on a project called sound box. It will give audio feedback regarding the amount received. Here I am using

  1. ESP32 Dev Board
  2. SIM800L GSM Module with a 2G SIM card
  3. DF Player mini

It's working fine but the issue is that each time after the audio feedback esp32 getting reset showing error

abort() was called at PC 0x400e1e32 on core 0

Backtrace:0x40083699:0x3ffb26100x4008835d:0x3ffb2630 0x4008cfa5:0x3ffb2650 0x400e1e32:0x3ffb26d0 0x400d15ca:0x3ffb2770 0x400d1ece:0x3ffb27c0 0x400d2094:0x3ffb2800 0x400d3e9d:0x3ffb2820 

code:

// Please select the corresponding model

// #define SIM800L_IP5306_VERSION_20190610
#define SIM800L_AXP192_VERSION_20200327
// #define SIM800C_AXP192_VERSION_20200609
// #define SIM800L_IP5306_VERSION_20200811

// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial

// Define the serial console for debug prints, if needed
#define DUMP_AT_COMMANDS
#define TINY_GSM_DEBUG          SerialMon
#include<string.h>

// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800          // Modem is SIM800
#define TINY_GSM_RX_BUFFER      1024   // Set RX buffer to 1Kb
#include <TinyGsmClient.h>

//library for df_mini_player
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Set serial for AT commands (to the module)
#define SerialAT  Serial2
  
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif


char* msg = "+cmt: \"+919988774455\"";

//setting all required global variables.
char* lower = "";
char* response = "";
String res = "";

String final_amount = "";
int Prev_button = 26;

//added for df_mini_updated.
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
SoftwareSerial mySoftwareSerial(33, 25); // RX, TX

void setup()
{
  pinMode(21, OUTPUT);//led high after network connection.
  digitalWrite(21, LOW);
  
  pinMode(26,INPUT);//previous button..
  
  // Set console baud rate
  SerialMon.begin(9600);
  SerialAT.begin(9600);
  mySoftwareSerial.begin(9600); 
  delay(100);

  if (!myDFPlayer.begin(mySoftwareSerial,true,false)) {  //Use mySoftwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while (true);
  }

  //initializing df_mini_player.
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.volume(25);  //Set volume value. From 0 to 30 

  //  power on command.
  myDFPlayer.play(1);
  delay(4000);
      
  SerialMon.println("Initializing modem...");SerialMon.println("Waiting for network...");
      
  if (!modem.waitForNetwork(600000L, true)) {
    delay(10000);
    return;
  }

  if (modem.isNetworkConnected())
  {
    digitalWrite(21, HIGH);
    delay(1500);
    myDFPlayer.play(2);// Network connected voice command.
    delay(1500);

    SerialMon.println("Network connected");
  }
  SerialAT.println("AT"); //Once the handshake test is successful, it will back to OK
  updateSerial();
  SerialAT.println("AT+CMGF=1"); // Configuring TEXT mode
  updateSerial();
  SerialAT.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
  
}
void loop()
{
  if (myDFPlayer.available())
  {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
  updateSerial();
}

void updateSerial()
{
  int x = 0;
  delay(500);
  while (!SerialAT.available())
  {
    // repeat last amount.
    if (digitalRead(Prev_button) == LOW)
      voice_commands(final_amount);
    delay(100);
  }
  
  // res stores the entire message 
  while (SerialAT.available())
  {
    char add = SerialAT.read();
    res = res + add;
    delay(1);
  }

  if (1) {
    response = &res[0];
    //------------------------------------------------- Converting every character of the String in lower form
    const int length = strlen( response ); // get the length of the text
    lower = ( char* )malloc( length + 1 ); // allocate 'length' bytes + 1 (for null terminator) and cast to char*
    lower[ length ] = 0; // set the last byte to a null terminator
    //------------------------------------------------- copy all character bytes to the new buffer using tolower
    for ( int i = 0; i < length; i++ )
    {
      lower[ i ] = tolower( response[ i ] );
    }
    Serial.print("whole Msg - "); Serial.println(lower);
    Serial.println("\n");

// check for rs || rs. and paytm QR code registered mobile number.
    if (strstr(lower, "rs") &&  strstr(lower, "+919988774455")) {
      //Serial.print("Our Msg - "); Serial.println(lower);
      CheckWordInString_rs(lower);
    }

    if (strstr(lower, "rs.") && strstr(lower, "++919988774455")) {
      CheckWordInString_rsDot(lower);
    }
    response = "";
    res = "";
    lower = "";

  }
}


int CheckWordInString_rs(char source[100]) {

 // Serial.print("Source message - "); Serial.println(source);

  if (1) {

    int i = 0, s = 0;
    
    while (lower[i] != 'r' || lower[i + 1] != 's')i++; //checks the position of rs and stores the position of r in variable i.

    //string slicing form i+3 position.
    String result = (String)lower;
    result = result.substring(i + 3);
    Serial.print("Substring - "); Serial.println(result);
    
    i = 0;// loop stores the position of first space in substring.
    while (result[i] != ' ' )i++;
    delay(100);
    
    // string slicing to store final_amount
    final_amount = result.substring(0, i);
    Serial.print("Final Amount - "); Serial.println(final_amount);
  
    voice_commands(final_amount); //Voice function called.
  }
}

int CheckWordInString_rsDot(char source[100]) {

 // Serial.print("Source Message - "); Serial.println(source);

  if (1) {

    int i = 0, s = 0;
    while (lower[i] != 'r' || lower[i + 1] != 's' || lower[i + 2] != '.')i++;
    delay(100);

    String result = (String)lower;
    result = result.substring(i + 4);
    Serial.print("Second");
    Serial.print("Substring -"); Serial.println(result);

    i = 0;
    while (result[i] != ' ' )i++;
          
    String   final_amount = result.substring(0, i);
    Serial.print("Final Amount - "); Serial.println(final_amount);

    voice_commands(final_amount);

  }
  return 1;
}

void voice_commands(String amount) {

  const char * float_amount = amount.c_str();
  int amount_int = amount.toInt();
  String amt_conversion = (String)amount_int;
  int amount_len = amt_conversion.length();
  Serial.println("amount_int");
  Serial.println(amount_int);

  if (amount_int !=0){
  delay(2000);  
  myDFPlayer.play(3); // Amount Received Voice note
  delay(1500);
  myDFPlayer.play(6);
  delay(1500);
  }
  if(amount_int == 0){
  delay(2000);  
  myDFPlayer.play(3); // Amount Received Voice note
  delay(1500);
  }
//if amount is less than and equal to 20.
  if (amount_int <= 280) {

    myDFPlayer.playMp3Folder(amount_int); //play specific mp3 in SD:/MP3/amount_int.mp3; File Name(0~65535)
    delay(1500);
    Serial.println(amount_int);
  }


  //loop to extract decimal value from amount...
  if(strstr(float_amount, ".")){
     
    int i=0;
    while(amount[i] != '.')i++;

       String sliced_amount = amount.substring(i+1);
       int decimal_value = sliced_amount.toInt();
       String amt_conversion = (String)decimal_value;
       int decimal_len = amt_conversion.length();
       

     Serial.println(decimal_len);
     Serial.println(decimal_value);

       // voice command for (and) is stored at 65000..
       if(amount_int != 0){
        myDFPlayer.play(5);
        delay(1500);
       }
     
      if(decimal_value <= 280){

        myDFPlayer.playMp3Folder(decimal_value);
        delay(1500);
        Serial.println(decimal_value);
        }
      }
        // voice command for paise is stored at 64000..
        myDFPlayer.play(4);
        delay(1500);


//    //end command placed at 61000.
//    myDFPlayer.playMp3Folder(61000); //play specific mp3 in SD:/MP3/amount_int.mp3; File Name(0~65535)
//    delay(2000);
}


void printDetail(uint8_t type, int value)//function to handle different errors of df_mini_player
{
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}
1

There are 1 best solutions below

1
ninjamakaron On

You can turn

Backtrace:0x40083699:0x3ffb26100x4008835d:0x3ffb2630 0x4008cfa5:0x3ffb2650 0x400e1e32:0x3ffb26d0 0x400d15ca:0x3ffb2770 0x400d1ece:0x3ffb27c0 0x400d2094:0x3ffb2800 0x400d3e9d:0x3ffb2820

into the specific code line with the espressif's xtensa-esp32-elf-addr2line

That could give you a better idea about the problem you are trying to solve. More information here