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"
#define BLYNK_DEVICE_NAME "MKR1400"


// Arduino MKR GSM 1400 uses U-blox modem
#define TINY_GSM_MODEM_UBLOX

// 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[]  = "vodafone.com.qa";
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
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(2,LOW);  // Set digital pin 2 LOW    
  }
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set GSM module baud rate
  SerialGSM.begin(115200);

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

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

  delay(1000);

  // 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);
}

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

@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.

Pete.

1 Like

This code should be inside your void setup.

Pete.

1 Like