vshymanskyy / TinyGSM

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

TinyGSM function (modem.gprsConnect(...)) reset Wemos D1 mini (ESP8266) - Soft WDT reset problem #783

Open Engine1992 opened 9 months ago

Engine1992 commented 9 months ago

[x] Question or request for help

Modem: SIM800L Main processor board: WEMOS D1 Mini (ESP8266) TinyGSM version: 0.11.7 Code:


 #define TINY_GSM_MODEM_SIM800
 #include <TinyGsmClient.h>
 #include <Firebase_ESP_Client.h>
 #include <Ultrasonic.h>
 #include <SoftwareSerial.h>

 // Provide the token generation process info.
 #include "addons/TokenHelper.h"
 // Provide the RTDB payload printing info and other helper functions.
 #include "addons/RTDBHelper.h"

 // Pin configuratuin for Ultrasonic Sensor
 #define TRIG_PIN D2
 #define ECHO_PIN D1
 float distance = 0;
 Ultrasonic ultrasonic(TRIG_PIN, ECHO_PIN);

 // Var for voltage metter
 int voltageValue;
 float voltage;

 // Insert Firebase project API Key
 #define API_KEY ""

 // Insert RTDB URL
 #define DATABASE_URL ""

 // Define Firebase Data object
 FirebaseData fbdo;

 FirebaseAuth auth;
 FirebaseConfig config;

 // Pin configuration for SIM800L
 SoftwareSerial SIM800L_Serial(12, 13, false, 128);

 // Your SIM card PIN
 #define SIM_PIN ""

 // APN settings for your mobile network provider
 #define GPRS_APN "internet"
 #define GPRS_LOGIN ""
 #define GPRS_PASSWORD ""

 TinyGsm modem(SIM800L_Serial);
 //TinyGsmClient client(modem);

 unsigned long sendDataPrevMillis = 0;
 int count = 0;
 bool signupOK = false;

 void setup() {
   Serial.begin(115200);
   delay(10);
   Serial.println("Started Serial");
   SIM800L_Serial.begin(115200);
   delay(3000); // Give SIM800L some time to initialize
   Serial.println("Started SIM800L Serial");
   // Unlock SIM card with PIN
   modem.simUnlock(SIM_PIN);
 }

 void loop() {

   distance = ultrasonic.read();
   voltageValue = analogRead(A0);
   voltage = voltageValue * (7.2 / 1023.0)*2;

   Serial.print("Distance: ");
   Serial.print(distance);
   Serial.println(" cm");

   Serial.print("Voltage: ");
   Serial.print(voltage);
   Serial.println(" V");

   //Send data through GPRS (SIM800L)
   sendDataThroughGPRS();
 }

 void sendDataThroughGPRS() {
   Serial.println("Connecting to GPRS");
   if (modem.gprsConnect(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)) {
   Serial.println("Connected to GPRS");
 }
}

Scenario, steps to reproduce

Expected result

I want to make SIM800L works with ESP8266 and finally sent data to Firebase via GPRS.

Actual result

Sensor readings work and are displayed in SERIAL. When I try to call the "modem.gprsConnect(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)" function, I get an error "Soft WDT reset":

I tried to use yield(); and delay(0); but not success.