How to make reset procedure on SIM800L?

I have successfully connect my arduino to thinger.io server by SIM800L. I am facing problem now, after about 24 hour send data, my SIM800L seems stuck and failed to reconnect to send data, it must be reset manually

i want to make reset procedure to SIM800L by giving digitalWrite ‘LOW’ to reset PIN
How can i do that? Is there any variable that contain boolean or something value if the module failed to reconnect?

Hello @arimukhlas,

I suppose that you are using thinger.h library and a code based in our ArduinoTinyGSM.ino example.
In this case, you can retrieve the connection status with this code:

// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_M590

// uncomment line for debug
// #define _DEBUG_

// Can be installed from Library Manager or https://github.com/vshymanskyy/TinyGSM
#include <TinyGsmClient.h>
#include <ThingerTinyGSM.h>



#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"

// use your own APN config
#define APN_NAME "your_apn_name"
#define APN_USER "your_apn_user"
#define APN_PSWD "your_apn_password"

// set your cad pin (optional)
#define CARD_PIN ""

class ClientListener : public ThingerTinyGSM{
  public:
      ClientListener(const char* user, const char* device, const char* device_credential, Stream&serial) : 
        ThingerTinyGSM(user, device, device_credential,Serial1){}
  protected:
    virtual void thinger_state_listener(THINGER_STATE state){
      // call current implementation (debug)
      ThingerTinyGSM::thinger_state_listener(state);
      switch(state){
         case NETWORK_CONNECT_ERROR:
         //place your reset signal here!!
          break;
       
         default:

          break;
      }
  }
};

ClientListener thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL,Serial1);

void setup() {
  // uncomment line for debug
  // Serial.begin(115200);

  // Serial for AT commands (can be higher with HW Serial, or even lower in SW Serial)
  Serial1.begin(57600);

  // set APN (you can remove user and password from call if your apn does not require them)
  thing.setAPN(APN_NAME, APN_USER, APN_PSWD);

  // set PIN (optional)
  // thing.setPIN(CARD_PIN);

  // resource input example (i.e, controlling a digitalPin);
  pinMode(LED_BUILTIN, OUTPUT);
  thing["led"] << digitalPin(LED_BUILTIN);

  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> outputValue(millis());

  // more details at http://docs.thinger.io/arduino/
}

void loop() {
  thing.handle();
} 

Then if you want to do something more advanced, for example, blink your led while connecting to the network, here you have all possible states:

    switch(state){
        case NETWORK_CONNECTING:
            break;
        case NETWORK_CONNECTED:
            break;
        case NETWORK_CONNECT_ERROR:
            break;
        case SOCKET_CONNECTING:
            break;
        case SOCKET_CONNECTED:
            break;
        case SOCKET_CONNECTION_ERROR:
            break;
        case SOCKET_DISCONNECTED:
            break;
        case SOCKET_TIMEOUT:
            break;
        case THINGER_AUTHENTICATING:
            break;
        case THINGER_AUTHENTICATED:
            break;
        case THINGER_AUTH_FAILED:
            break;
        case THINGER_STOP_REQUEST:
            break;
    }

Hope it helps!

1 Like

Thanks, I will try your suggestion… You have given me new hope!!

Hi jtrinc26, after i tried your suggestion, got an error :

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\mukhlas\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\mukhlas\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\mukhlas\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10810 -build-path C:\Users\mukhlas\AppData\Local\Temp\arduino_build_788702 -warnings=none -build-cache C:\Users\mukhlas\AppData\Local\Temp\arduino_cache_454787 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\mukhlas\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\mukhlas\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\mukhlas\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10810 -build-path C:\Users\mukhlas\AppData\Local\Temp\arduino_build_788702 -warnings=none -build-cache C:\Users\mukhlas\AppData\Local\Temp\arduino_cache_454787 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino
Using board 'mega' from platform in folder: C:\Program
Using core 'arduino' from platform in folder: C:\Program
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp" -o nul
Alternatives for TinyGsmClient.h: [TinyGSM@0.7.9]
ResolveLibrary(TinyGsmClient.h)
  -> candidates: [TinyGSM@0.7.9]
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\TinyGSM\\src" "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp" -o nul
Alternatives for ThingerTinyGSM.h: [thinger.io@2.9.2]
ResolveLibrary(ThingerTinyGSM.h)
  -> candidates: [thinger.io@2.9.2]
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\TinyGSM\\src" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\thinger.io\\src" "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp" -o nul
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\TinyGSM\\src" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\thinger.io\\src" "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp" -o "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\TinyGSM\\src" "-IC:\\Users\\mukhlas\\Documents\\Arduino\\libraries\\thinger.io\\src" "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp" -o "C:\\Users\\mukhlas\\AppData\\Local\\Temp\\arduino_build_788702\\sketch\\ArduinoTinyGSM.ino.cpp.o"
ArduinoTinyGSM:34:91: error: 'Serial1' is not a type

       ClientListener(const char* user, const char* device, const char* device_credential, Serial1) :

                                                                                           ^~~~~~~

ArduinoTinyGSM:20:18: error: expected identifier before string constant

 #define USERNAME "your_user_name"

                  ^

C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino:51:22: note: in expansion of macro 'USERNAME'

 ClientListener thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL,Serial1);

                      ^~~~~~~~

ArduinoTinyGSM:20:18: error: expected ',' or '...' before string constant

 #define USERNAME "your_user_name"

                  ^

C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino:51:22: note: in expansion of macro 'USERNAME'

 ClientListener thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL,Serial1);

                      ^~~~~~~~

ArduinoTinyGSM:78:1: error: expected '}' at end of input

 }

 ^

C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino: In member function 'void ClientListener::setup()':

ArduinoTinyGSM:61:3: error: invalid use of member function 'ClientListener ClientListener::thing(int)' (did you forget the '()' ?)

   thing.setAPN(APN_NAME, APN_USER, APN_PSWD);

   ^~~~~

ArduinoTinyGSM:61:3: error: invalid use of member function 'ClientListener ClientListener::thing(int)' (did you forget the '()' ?)

ArduinoTinyGSM:68:14: error: invalid types '<unresolved overloaded function type>[const char [4]]' for array subscript

   thing["led"] << digitalPin(LED_BUILTIN);

              ^

ArduinoTinyGSM:71:17: error: invalid types '<unresolved overloaded function type>[const char [7]]' for array subscript

   thing["millis"] >> outputValue(millis());

                 ^

C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino: In member function 'void ClientListener::loop()':

ArduinoTinyGSM:77:3: error: invalid use of member function 'ClientListener ClientListener::thing(int)' (did you forget the '()' ?)

   thing.handle();

   ^~~~~

ArduinoTinyGSM:77:3: error: invalid use of member function 'ClientListener ClientListener::thing(int)' (did you forget the '()' ?)

C:\Users\mukhlas\AppData\Local\Temp\arduino_modified_sketch_748490\ArduinoTinyGSM.ino: At global scope:

ArduinoTinyGSM:78:1: error: expected unqualified-id at end of input

 }

 ^

Multiple libraries were found for "TinyGsmClient.h"
 Used: C:\Users\mukhlas\Documents\Arduino\libraries\TinyGSM
Multiple libraries were found for "ThingerTinyGSM.h"
 Used: C:\Users\mukhlas\Documents\Arduino\libraries\thinger.io
Using library TinyGSM at version 0.7.9 in folder: C:\Users\mukhlas\Documents\Arduino\libraries\TinyGSM 
Using library thinger.io at version 2.9.2 in folder: C:\Users\mukhlas\Documents\Arduino\libraries\thinger.io 
exit status 1
'Serial1' is not a type

what is the meaning of the error? Big Thanks

UPS!! it was a little mistake in my code, now it is fixed. Hope it works well!!