Issue and Errors with my SIM900 and arduino uno "modem cannot init"

Hello guys im using this code to communicate with the blynk apps via arduino uno and SIM900 but im getting an error and the modem cannot intitialize, i have tried the board to make a normall call to my personal number and its working fine but when it come to connection with blynk its giving me this error.

/* 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   "TMPL4N4u5ch6"

// Arduino MKR GSM 1400 uses U-blox modem

// 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[] = "jZX63-SFl_pJUsBObIyQlQFTT4UrybM-";

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

TinyGsm modem(SerialGSM);

void setup()
    pinMode(2, OUTPUT); // Initialise digital pin 2 as an output pin

BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
  if(param.asInt() == 1)
    // execute this code if the switch widget is now ON
    digitalWrite(2,HIGH);  // Set digital pin 2 HIGH
    // execute this code if the switch widget is now OFF
    digitalWrite(2,LOW);  // Set digital pin 2 LOW    
  // Debug console


  // Set GSM module baud rate

  pinMode(GSM_DTR, OUTPUT);
  digitalWrite(GSM_DTR, LOW);

  // Turn on the GSM module by triggering GSM_RESETN pin
  digitalWrite(GSM_RESETN, HIGH);
  digitalWrite(GSM_RESETN, LOW);


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

  // Unlock your SIM card with a PIN

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

void loop()
} ```

@keirone Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:

Copy and paste these if you can’t find the correct symbol on your keyboard.


1 Like

This code should be inside your void setup.


1 Like