1

I am trying to do a small project with SIM800L with Wemos d1 mini. It is a DTMF based project. The problem here is, every time I make a call the d1 mini is getting reset. This is my first project with d1 mini. For the past few days I have googled, trying to find a solution. But I failed. I will be very grateful if you can provide the solution.

I am getting these errors in the serial monitor:

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v00043b40
~ld

I am using Arduino IDE. Version: 1.8.8

Here is my project code.

#include <SoftwareSerial.h>

#define rxPin D3
#define txPin D4
SoftwareSerial sim800L(rxPin, txPin);

#define RELAY_1 D7
#define RELAY_2 D8
boolean relay1_state = false;
boolean relay2_state = false;

//stores incomming data from sim800l
String buff;
String dtmf_cmd;
boolean is_call = false;
String ownerNumber = "xxxxxxxxxxxxxxx";

void setup()
{
  pinMode(RELAY_1, OUTPUT);
  pinMode(RELAY_2, OUTPUT);

  //Begin serial communication with (Serial Monitor)
  Serial.begin(115200);

  //Begin serial communication with (SIM800L)
  sim800L.begin(9600);
  Serial.println("Begin serial communication with (SIM800L)");
  delay(500);

  sim800L.println("AT"); //send AT
  delay(500);

  sim800L.println("AT+DDET=1"); //Enable DTMF
  delay(500);

  sim800L.println("AT+CLIP=1"); // Enable CallerID
  delay(500);
}

void loop()
{
  while (sim800L.available()) {
    buff = sim800L.readString();
    Serial.println("Raw: " + buff);

    if (is_call == true) {
      if (int index = buff.indexOf("+DTMF:") > -1 ) {
        index = buff.indexOf(":");
        dtmf_cmd = buff.substring(index + 1, buff.length());
        dtmf_cmd.trim();
        Serial.println("dtmf_cmd: " + dtmf_cmd);
        doAction();
      }
      if (buff.indexOf("NO CARRIER") > -1) {
        sim800L.println("ATH");
        is_call = false;
      }
    }
    if (buff.indexOf("RING") > -1) {

      // Now check the caller number
      if (buff.indexOf("+CLIP:")) {
        unsigned int index, index1;

        index = buff.indexOf("\"");
        index1 = buff.indexOf("\"", index + 1);

        String temp = buff.substring(index + 2, index1);
        temp.trim();

        if (ownerNumber == "+" + temp) {
          Serial.println("Number matched");
          delay(2000);
          sim800L.println("ATA");
          is_call = true;
        } else {
          Serial.println("Number not matched");
        }
      }
    }
  }


  while (Serial.available())  {
    sim800L.println(Serial.readString());
  }
}


void doAction() {
  if (dtmf_cmd == "1") {
    relay1_state = !relay1_state;
    digitalWrite(RELAY_1, relay1_state);
    if (relay1_state == true)
    {
      Serial.println("Relay 1 has been ON");
    }
    else
    {
      Serial.println("Relay 1 has been OFF");
    }
  }
  else if (dtmf_cmd == "2") {
    relay2_state = !relay2_state;
    digitalWrite(RELAY_2, relay2_state);
    if (relay2_state == true)
    {
      Serial.println("Relay 2 has been ON");
    }
    else
    {
      Serial.println("Relay 2 has been OFF");
    }
  }
}

The settings that the Arduino ID currently has

2
  • rst cause:4, is a watchdog reset. Add yield() inside your loop() to allow "breathing" at each loop. Commented Nov 22, 2022 at 10:38
  • I tried, nothing changed. Commented Nov 27, 2022 at 14:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.