Sim800L cannot Init error

I am trying to connect my Arduino Uno with a SIm800L to Blynk but I get a Cannot init error.
I have tested with the AT command and the GSM module is connected correctly, my code is below

// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM800

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "capgroup";
char user[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1

// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(2, 3); // RX, TX

TinyGsm modem(SerialAT);

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{

  // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
  if (String("Marco") == param.asStr()) {
    terminal.println("You said: 'Marco'") ;
    terminal.println("I said: 'Polo'") ;
  } else {

    // Send it back
    terminal.print("You said:");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
  }

  // Ensure everything is sent
  terminal.flush();
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(115200);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  //modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);

  // Clear the terminal content
  terminal.clear();

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println(F("-------------"));
  terminal.println(F("Type 'Marco' and get a reply, or type"));
  terminal.println(F("anything else and get it printed back."));
  terminal.flush();
}

void loop()
{
  Blynk.run();
}

Please edit your post and add triple backticks ( ``` ) before and after your sketch.

Why do you have comments for raising the Internet connection in your code?

Internet connection modem raises?

  mySerial.println("AT");               // Sending an AT command
  updateSerial();
  mySerial.println("AT+CSQ");           // Signal quality test, value range 0-31, 31 is best
  updateSerial();
  mySerial.println("AT+CCID");          // Reading SIM card information
  updateSerial();
  mySerial.println("AT+CREG?");         // Network Registration Check
  updateSerial();

I am not sure what you mean

@Deanr you were given triple backticks to copy/paste by @John93, but you chose to use differnet characters instead.

Please edit your post again and this time use the correct characters.
Note also that the triple backticks have to be on a line of their own, immediately above and below the sketch.

Pete.

You should read this, especially the part about the maximum baud rates that you can successfully achieve with SoftwareSerial on an Uno…

You should also be careful about how you power the SIM800, as they can draw quite a lot of power in transmit mode.

Pete.

Hi Peter

I have changed the baud rate to 9600 but I still have an issue, I am powering it through a Buck Boost module to ensure it has enough power to operate.
Do you have some sample code for the Sim800L and the Arduino Uno?

How did you achieve that?

Pete.

I changed it in the code
But it doesnt work

I’d suggest that you re-read the topic I linked you to.
You can’t simply change the communication rate in the sketch, you also need to tell your SIM800 module to use the same baud rate, which will need to be done via an AT command.

Pete.

Ok thanks but do you have a sample code to use

You can try this

What’s wrong with the code you are using?

Pete.

I have managed to get the Sim800l working with the below code but now I get a login timeout when connecting to blynk.cloud:80

/************************************************************************************
 * Created By: Tauseef Ahmad
 * Created On: December 29, 2021
 * 
 * Tutorial: https://youtu.be/qrxuAezlDyA
 *
 * ****************************************************************************
 * Download Resources
 * **************************************************************************** 
 *  Download latest Blynk library here:
 *  https://github.com/blynkkk/blynk-library/releases/latest
 * **************************************************************************** 
 *  DHT-sensor-library
 *  https://github.com/adafruit/DHT-sensor-library
 * ****************************************************************************
 *  Attention! Please check out TinyGSM guide:
 *  https://tiny.cc/tinygsm-readme
 *  Change GPRS apm, user, pass, and Blynk auth token to run :)
 *  Feel free to apply it to any other example. It's simple!
 **********************************************************************************/

//-----------------------------------------------------------------------
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
//-----------------------------------------------------------------------
/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "******"
#define BLYNK_DEVICE_NAME "*****"
#define BLYNK_AUTH_TOKEN "******"
//-----------------------------------------------------------------------
// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE
//-----------------------------------------------------------------------
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30
//-----------------------------------------------------------------------
#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//-----------------------------------------------------------------------
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
//-----------------------------------------------------------------------
// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "internet";
char user[] = "";
char pass[] = "";
//-----------------------------------------------------------------------
// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1
//-----------------------------------------------------------------------
// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(2, 3); // RX, TX
TinyGsm modem(SerialAT);
//-----------------------------------------------------------------------
#include <DHT.h>
#define DHT11_PIN 4
#define DHTTYPE DHT11
DHT dht(DHT11_PIN, DHTTYPE);
//-----------------------------------------------------------------------
BlynkTimer timer;
#define INTERVAL 1000L
//-----------------------------------------------------------------------



/************************************************************************************
 *  This function sends Arduino's up time every second to Virtual Pin.
 *  In the app, Widget's reading frequency should be set to PUSH. This means
 *  that you define how often to send data to Blynk App.
 **********************************************************************************/
void SendDhtData()
{
  //-----------------------------------------------------------------------
  //Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  //-----------------------------------------------------------------------
  //Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  //-----------------------------------------------------------------------
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  //-----------------------------------------------------------------------
  //Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);
  //-----------------------------------------------------------------------
  Serial.print("Temperature: ");
  Serial.println(t);
  Serial.print("Humidity: ");
  Serial.println(h);
  Serial.println("------------------------------------------");
  //-----------------------------------------------------------------------
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
  //-----------------------------------------------------------------------
}


/************************************************************************************
 *  setup() function
 **********************************************************************************/
void setup()
{
  //-----------------------------------------------------------
  // Debug console
  Serial.begin(115200);
  delay(10);
  //-----------------------------------------------------------
  // Set GSM module baud rate
  SerialAT.begin(9600);
  //SerialAT.begin(9600,SWSERIAL_8N1,D3,D4);
  delay(3000);
  //-----------------------------------------------------------
  dht.begin();
  //-----------------------------------------------------------
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  //modem.restart();
  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");
  //-----------------------------------------------------------
  Blynk.begin(auth, modem, apn, user, pass);
  //-----------------------------------------------------------
  // Setup a function to be called every second
  timer.setInterval(INTERVAL, SendDhtData);
  //-----------------------------------------------------------  
}


/************************************************************************************
 *  loop() function
 **********************************************************************************/
void loop()
{
  Blynk.run();
  timer.run();
}

Are you using Blynk Legacy, or the new Blynk IoT ?

Your original sketch was for Blynk Legacy.

What version of the Blynk library are you using?

What exactly do you see in your serial monitor (copy and paste the text and use triple backticks again).

Pete.

I am using Blynk IOT cloud

[3018] Modem init...
[3222] Connecting to network...
[3314] Network: VodaCom
[3314] Connecting to lte.vodacom.za ...
[8931] Connected to GPRS
[9003] Connecting to blynk-cloud.com:8080
[10523] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[16629] Login timeout
[16713] Connecting to blynk-cloud.com:8080
[17627] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[23732] Login timeout
[23816] Connecting to blynk-cloud.com:8080
[24726] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[29865] Connecting to blynk-cloud.com:8080
[30804] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[36909] Login timeout
[36993] Connecting to blynk-cloud.com:8080
[37911] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[44017] Login timeout
[44101] Connecting to blynk-cloud.com:8080
[45051] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[50192] Connecting to blynk-cloud.com:8080
[51130] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[57234] Login timeout
[57318] Connecting to blynk-cloud.com:8080
[58109] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[63288] Connecting to blynk-cloud.com:8080
[64074] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[70180] Login timeout
[70265] Connecting to blynk-cloud.com:8080
[71095] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[77200] Login timeout
[77284] Connecting to blynk-cloud.com:8080
[78313] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi
[83452] Connecting to blynk-cloud.com:8080
[84358] <[1D|00|01|00] OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi

I am running Blynk 1.0.1 and TinyGSM 0.11.5

Okay, you need to be clearer with your communication if you want sensible feedback.

The serial output you’ve just provided wasn’t produced with the latest code you posted. It may have been produced with your original sketch, which is designed for Blynk Legacy, but I have my doubts.

Pete.

This is the code I am using now with the login timeout error

 * Created By: Tauseef Ahmad
 * Created On: December 29, 2021
 * 
 * Tutorial: https://youtu.be/qrxuAezlDyA
 *
 * ****************************************************************************
 * Download Resources
 * **************************************************************************** 
 *  Download latest Blynk library here:
 *  https://github.com/blynkkk/blynk-library/releases/latest
 * **************************************************************************** 
 *  DHT-sensor-library
 *  https://github.com/adafruit/DHT-sensor-library
 * ****************************************************************************
 *  Attention! Please check out TinyGSM guide:
 *  https://tiny.cc/tinygsm-readme
 *  Change GPRS apm, user, pass, and Blynk auth token to run :)
 *  Feel free to apply it to any other example. It's simple!
 **********************************************************************************/

//-----------------------------------------------------------------------
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
//-----------------------------------------------------------------------
/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "TMPLrKAvPedF"
#define BLYNK_DEVICE_NAME "Dev 2 GSM"
#define BLYNK_AUTH_TOKEN "OTQ0an_SSlPvkE6r7fZU46h2IZx0mxPi"
//-----------------------------------------------------------------------
// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE
//-----------------------------------------------------------------------
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30
//-----------------------------------------------------------------------
#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//-----------------------------------------------------------------------
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
//-----------------------------------------------------------------------
// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "lte.vodacom.za";
char user[] = "";
char pass[] = "";
//-----------------------------------------------------------------------
// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1
//-----------------------------------------------------------------------
// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(2, 3); // RX, TX
TinyGsm modem(SerialAT);
//-----------------------------------------------------------------------
#include <DHT.h>
#define DHT11_PIN 4
#define DHTTYPE DHT11
DHT dht(DHT11_PIN, DHTTYPE);
//-----------------------------------------------------------------------
BlynkTimer timer;
#define INTERVAL 1000L
//-----------------------------------------------------------------------



/************************************************************************************
 *  This function sends Arduino's up time every second to Virtual Pin.
 *  In the app, Widget's reading frequency should be set to PUSH. This means
 *  that you define how often to send data to Blynk App.
 **********************************************************************************/
void SendDhtData()
{
  //-----------------------------------------------------------------------
  //Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  //-----------------------------------------------------------------------
  //Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  //-----------------------------------------------------------------------
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  //-----------------------------------------------------------------------
  //Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);
  //-----------------------------------------------------------------------
  Serial.print("Temperature: ");
  Serial.println(t);
  Serial.print("Humidity: ");
  Serial.println(h);
  Serial.println("------------------------------------------");
  //-----------------------------------------------------------------------
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);
  //-----------------------------------------------------------------------
}


/************************************************************************************
 *  setup() function
 **********************************************************************************/
void setup()
{
  //-----------------------------------------------------------
  // Debug console
  Serial.begin(115200);
  delay(10);
  //-----------------------------------------------------------
  // Set GSM module baud rate
  SerialAT.begin(9600);
  //SerialAT.begin(9600,SWSERIAL_8N1,D3,D4);
  delay(3000);
  //-----------------------------------------------------------
  dht.begin();
  //-----------------------------------------------------------
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  //modem.restart();
  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");
  //-----------------------------------------------------------
Blynk.begin(auth, modem, apn, user, pass, "blynk-cloud.com", 8080);
  //-----------------------------------------------------------
  // Setup a function to be called every second
  timer.setInterval(INTERVAL, SendDhtData);
  //-----------------------------------------------------------  
}


/************************************************************************************
 *  loop() function
 **********************************************************************************/
void loop()
{
  Blynk.run();
  timer.run();
}

These need to be the first lines of code in your sketch…

Pete.