Error while Connecting Arduino Mega 2560 and Sim900A with Blynk

Components used:
Arduino Mega 2560
Sim900A GSM Module.

The sketch im using is :

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


// 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 <BlynkSimpleSIM800.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "apn";
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);

WidgetMap myMap(V1);

void setup()
  // Debug console


  // Set GSM module baud rate

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

  // If you want to remove all points:

  int index = 1;
  float lat = 51.5074;
  float lon = 0.1278;
  myMap.location(index, lat, lon, "value");

void loop()

The problem is that I’m not able to connect to the Internet. The picture of SM is Attached Below…
Thanks in Advance.

The SM stuck at this.

Please format pasted code properly… I already fixed your post, as per Welcome Topic requirements…

Not Blynk related… Looks like you need to ask your ufone provider.

But I tried this ufone wih same gsm module with arduino Uno but this is not working with Arduino Mega.

  • with uno worked?

  • apn, user, pwd are correct?

  • the gsm shield has a powerful psu? it needs more power when turning on gprs communication

there is a debug sketch example in the arduino ide tinygsm library. there you can manually test at commands with the gsm module. try to turn on gprs with at commands and check if it works.

eventually you can try serial2 too.

Then perhaps you don’t have it properly wired to the Mega’s Serial1 port

but if he got valid answers in serial monitor debug, it should be wired correctly. like network name, etc

It worked properly :slight_smile:
But i need one more help from you guys is that when I’m connecting Gps module on serial2 its not responding…
Thanks in Advance

Serial monitor is connected to Serial (the USB port) … the actual GSM data connection is Serial1 (Pins 18,TX-19,RX), so possible to get as far as he has without actual Server connection, if RX/TX not properly wired, etc.

Serial2 would be pins 16,TX-17,RX

So what is the actual issue… not connecting to server with the GSM or not properly connecting to the GPS…?

BTW, neither is really a Blynk issue… but basic Serial Wiring 101.

true. but i mean that if the gsm serial is not properly wired, than can not communicate to the arduino the name of the network and the connection status.

so the arduino couldn’t pass that info to the serial monitor…

Finally i get connected to the internet and gps also gives the coordinates but the main issue is that sometimes gsm connected to net very frequently and works fine and sometimes it keeps try connecting and gives error… whats the issue?

as you can see the issue in SM

hm… there is a link there, pointing toward something called “docs”. maybe you should try to follow that link and read?