GSM goes offline

I have been mucking about with GSM option. Thanks to Peter’s guidance I was able to get the proper modem (SIM5320A) recognized .
The issue I am having now is that I can get the connection established, but then it drops and goes offline in about 20secs.

From the serial monitor:
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.6.1 on Arduino Mega

[3130] Modem init…
[3213] Connecting to network…
[7199] Network: Koodo
[7199] Connecting to sp.koodo.com
[10439] Connected to GPRS
[10477] Connecting to blynk-cloud.com:80
[12770] <[1D|00|01|00] S_8fixM1Ipdzfg2wdAfDvCPhhNRDxsat

/* Comment this out to disable prints and save space */#define BLYNK_DEBUG // Optional, this enables lots of prints
#define BLYNK_DEBUG // Optional, this enables lots of prints

#define BLYNK_PRINT Serial

//#define TINY_GSM_MODEM_SIM800
#define TINY_GSM_MODEM_SIM5320 

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

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

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

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// 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 myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V0, millis() / 1000);
  Blynk.virtualWrite(V2, HIGH);
}

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

  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.init();

  // 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(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

nobody has any ideas on how to investigate this further or a solution???

Have you tried a SIM card on a different network?

Pete?

hi Pete, yes. I’ve tried 2 different SIM cards both on separate providers (Telus and Rogers) here in Canada. The last one i tried was out of my phone, so I know it works, the first was a “pay as you go data” so I suspected there might be something iffy, so I went with a SIM I knew worked.
Apparently I’m supposed to see a “ping” response when it connects successfully to blynk-cloud.com ??

Although this sounds like a logical conclusion, it’s not.
Your phone uses the SIM for different types of communication, even when running the Blynk app, the Blynk communication uses different ports and protocols to an Arduino with a GSM shield.
The topic below is about a different scenario, but demonstrates the issue:

Yes, with debug turned on (as you have in your code) the next line you should see after your auth code is sent to the server is:
[timestamp] >[00|00|01|00|C8]

This means “Blynk success”
See here for more info:

As you’re not seeing this, it means that the connection request from the Arduino isn’t being seen by the server, or the response from the server isn’t being seen by the Arduino. My guess is the first, that the server isn’t seeing the connection request at all.

I think you should try some different SIM cards. Try begging, borrowing or stealing them from friends, family or random strangers in the street until you’ve either found one that works, or convinced yourself that this isn’t the issue.
I think that there’s little point in trying multiple SIMS from the same company, or from a subsidiary company. This table on Wikipedia shows the parent companies that you should aim to try, and you’ve already tried the first two…

Pete.

Pete, as usual you are a wealth of information and insight, saying thank you sometimes doesn’t seem enough.
I’ll try the SIM from my work phone (which is on the Bell network) so that should wrap up testing on all 3 providers…however , the wrinkle in this is the very last part of the Wiki article " sometime they share each others network…" Is indeed true. In Canada, they do indeed share the same physical network, due to government Roaming regulations which allows consumers broader coverage and lower costs. So, if I have a “Bell SIM” and I live in Western Canada, Bell doesn’t have any tower infrastructure out here so they typically use Telus and vise versa out East… Sorry, I’ve digressed from the main issue but it was only to provide background that might impact the assumption that the 3 providers operate totally independent from each other in functionality.

I will read and research the other material you referenced and see where that leads me.

Thank you very much again for your thorough research and assistance!
Rob

Hey Rob, you’re welcome.

I’m afraid that I don’t have any idea where the data packets are blocked by some mobile ISPs, although my gut feeling is that this blocking occurs when they enter the ISPs data centre - so mast sharing may not actually be an issue.

I’ve never use mobile comms for Blynk, and even if I did I’m not sure I would have any more insight into these issues, but it is an area that I’d like to learn more about.

Please keep us updated on your findings, but don’t expect us to bail you out when you start mugging random strangers for their SIM cards!

Pete.

well, turns out it is something in the 5320 class that isn’t quite right…
I tried all 3 SIM cards (3 different providers) and all had the same results as previous.
Once I changed the physical modem and settings to SIM800 ( utilizing the same SIM cards previous) all worked perfectly. Connected to the Blynk cloud server and was able to control everything properly.
[12400] Modem init…
[12464] Connecting to network…
[19633] Network: Rogers Wireless
[19633] Connecting to rogers-core-appl1.apn …
[27774] Connected to GPRS
[27785] Connecting to blynk-cloud.com:80
[28499] <[1D|00|01|00] DuyrJ5LuYMjHx2i_XN8gjHcu79RuZkmo
[28987] >[00|00|01|00|C8]
[28988] Ready (ping: 469ms).
[28989] Free RAM: 7107
[28990] >[14|00|01|00|08]
[28992] >pm[00]4[00]out
[29056] <[11|00|02|00]gver[00]0.6.1[00]h-beat[00]60[00]buff-in[00]1024[00]dev[00]Arduino Mega[00]cpu[00]ATmega2560[00]con[00]SIM800[00]build[00]Mar 7 2020 07:44:22[00]
[29495] >[00|00|02|00|C8]

So either the modem is defective or the library or 5320 class has an error.
I’ll still try to connect manually through AT commands to get to the bottom of it, but this is all very new to me and I’m still trying to understand the process.
I did find an AT Command Tester that supports Standard and SIMCOM modules so I can delve deeper into testing further to see whats going on.

1 Like

well, the modem isn’t defective as I was able to piece together the manual AT commands that are necessary ( they differ from the 800L) for the 5320A to connect and tried them manually. I was able to establish a TCP connection and get an IP address. So that only leaves the library and 5320 class within as the culprit.

It might be best to raise this as an issue on the TinyGSM Github page:

Pete.

will do Pete! thank you again!!

1 Like