Can't stay connected to Blynk server

I’m trying to setup my GSM800 with blynk and arduino uno. I am able to connect to blynk briefly- the app on my phone even acknowledges that the device is connected. The problem is that after a few seconds the device goes offline and my serial monitor says Connecting to 45.55.96.146:80

21:56:24.936 -> Initializing modem…
21:56:34.488 -> [12591]
21:56:34.525 -> ___ __ __
21:56:34.561 -> / _ )/ /_ _____ / /__
21:56:34.561 -> / _ / / // / _ / '/
21:56:34.597 -> /
//_, /////_
21:56:34.633 -> /
__/ v0.6.1 on Arduino Uno
21:56:34.669 ->
21:56:34.669 -> [12684] Modem init…
21:56:34.921 -> [12997] Connecting to network…
21:56:48.836 -> [26927] Network: T-Mobile USA
21:56:48.872 -> [26928] Connecting to hologram …
21:57:06.391 -> [44434] Connected to GPRS
21:57:06.427 -> [44503] Connecting to blynk-cloud.com:80
21:57:10.104 -> [48164] Redirecting to 45.55.96.146:80
21:57:10.176 -> [48246] Connecting to 45.55.96.146:80
21:57:12.736 -> [50795] Ready (ping: 1364ms).
21:58:23.920 -> [121908] Connecting to 45.55.96.146:80
21:59:42.067 -> [199998] Connecting to 45.55.96.146:80
22:01:00.198 -> [278088] Connecting to 45.55.96.146:80
22:02:18.370 -> [356178] Connecting to 45.55.96.146:80
22:03:36.520 -> [434269] Connecting to 45.55.96.146:80
22:04:54.672 -> [512358] Connecting to 45.55.96.146:80

For right now I am just trying to use the basic blynk blink sketch. Have tried several baud rates, no luck. Any ideas?

#define BLYNK_PRINT Serial

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

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

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

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

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(9600);
  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);
}

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

Hey,

Not a pro at this but I had issues with delay before, try going through the following:

Use Blynk Timer:

and the next one describes how using delay causes connection breaks:

Thanks for the response, I do not have any delays in my code, I am using the basic blynk code…

If anyone has any ideas I would really apreiate your feedback, I have spent several days trying to get this to work and am about to give up :frowning:

Capture

I don’t have the same setup / hardware, but just have some hypothesis as follows:

Your code seems OK, so the issue might be:

  1. Your Network: T-Mobile USA or your SIM card (unlocked??). Did you try with another Mobile provider or SIM card?

  2. Your SoftwareSerial speed set at low speed of 9600. Try to change to other speed such as 38400

  • When using SoftwareSerial (on Uno, Nano, etc), the speed 115200 may not work. Try selecting 57600 , 38400 , or even lower - the one that works best for you. In some cases 9600 is unstable, but using 38400 helps, etc. Be sure to set correct TX/RX pins in the sketch. Please note that not every Arduino pin can serve as TX or RX pin. Read more about SoftSerial options and configuration here and here.`
  1. Try the better AltSoftSerial instead of SoftwareSerial
  1. Use only HardwareSerial at 115200 (modem connected to pin 0 (RX) and pin 1 (TX)).
  • In this case, you can’t use USB / Serial to debug.
  • Before connecting UNO to USB to upload firmware, remove modem.
  • After upload firmware to UNO, you have to remove UNO out of USB port, connect modem then test using external power supply.
  • You have to look at the Blynk APP to see if the modem is connected or not.
  • You have to modify your code as follows:
#define BLYNK_PRINT Serial

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

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

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

//HardwareSerial on UNO for modem, RX,TX => 0,1
TinyGsm modem(Serial);

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

  delay(10);

  // Set GSM module baud rate
 //SerialAT.begin(9600);
  // For modem now, try from 115200, gradually down to 9600 to see if any works
  Serial.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);
}

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

I don’t have the same hardware to test and I’m not sure if this will work. Please try.

Thanks for the response, I have tried all of your suggestions but it still will not work :frowning:

Capture

Blynk has three cloud servers around the globe - in New York, Frankfurt and Singapore - and your project exists on only one of them.
When you try to connect to your project via blynk-cloud.com the ISP’s DNS servers will normally want to take you to the geographically nearest server, but Blynk then does some clever stuff to take you to the correct server where your project lives. When this happens, you get the “Redirecting to …” message that you’re seeing in your screenshot.

The interesting thing is that 45.55.96.146 is the IP address for Blynk’s New York Server, so for some reason your mobile ISP is initially trying to connect to a different server and is being redirected.

Your Ping time is quite high at 676ms in this particular screenshot, and double that in your first post; and I guess that some of this may be due to the redirection process.
I think I’d try specifying 45.55.96.146 as the server in your Blynk.begin command and see if that helps. You might also want to specify the port of 8080 in case your mobile ISP is blocking port 80.

Pete.

1 Like

Pete,

Thank you for your response. I have tried your suggestion (screenshots below) but I am now getting an error in my serial monitor…

Here is where I specified the IP and port

image

Any ideas as to whats going on now?

Thanks!
Matthew

The strange characters are because the MCU is resetting. If you change your serial baud rate until these messages make sense, then use that as the serial baud rate in the sketch, you’ll be able to see both sets of messages in the serial monitor.

What happens if you put the IP address in this format “45.55.96.146” rather than specifying it as an IPAddress variable type?

Pete.