BLYNK
BLYNK.IO       πŸ“² GETTING STARTED       πŸ“— DOCS       ❓HELP CENTER       πŸ‘‰ SKETCH BUILDER

Arduino GSM1400 disconnecting

β€’ Arduino MKR 1400 GSM
β€’ Android 1.1.10(42)
β€’ fra1.blynk.cloud
β€’ Blynk Library 1.0.1

Hello,

I have some trouble with my device loosing connection.
it could stay connected for several days without problems, but after timing out/loosing connection i am having problems connecting again. it will stay connected from a couple of seconds to some minutes…

i need to restart/power cycle to get it going again, but now it it will not stay connected.

tried to change timer interval back and fouth, and changed from port 80 to 8080.
also tried two different simcards and ISP. cell coverage is also decent here.

Device powered with a 5V reg and a lipo.

//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPLnbY3UnYY"
#define BLYNK_DEVICE_NAME "Trykksensor"

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <MKRGSM.h>
#include <BlynkSimpleMKRGSM.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
float pressure;     //To store the barometric pressure (Pa)
float temperature;  //To store the temperature (oC)
float humidity;

GSMClient client;
GPRS gprs;
GSM gsmAccess;
BlynkTimer timer;

char auth[] = "Z5q0dNb3PRiNEmZoEIt0ONA2ZEBwvQrw";
char pin[] = "4013";
char apn[]  = "internet.public";
char user[] = "";
char pass[] = "";


void sendAnalog()
{
float sensorData =(float)analogRead(A1) * (6.00 / 1023.00);
Blynk.virtualWrite(V5,sensorData); //sending to Blynk
Serial.println(sensorData);
Serial.println();

int sensorValue = analogRead(ADC_BATTERY);
float voltage = sensorValue * (4.30 / 1023.00);
//float battery = (voltage-3.50)/0.70*100.00);
Blynk.virtualWrite(V7,voltage);
Serial.print(voltage);
Serial.println("V");
}


void ReadSensors()
{
  pressure = bme.readPressure();
  temperature = bme.readTemperature();
  humidity = bme.readHumidity ();

  Blynk.virtualWrite(V1, pressure/100);
  Blynk.virtualWrite(V2, temperature);
  Blynk.virtualWrite(V6, humidity);

  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" Β°C");

  Serial.print("Pressure = ");
  Serial.print(pressure/100);
  Serial.println(" kPa");

  Serial.print("Humidity = ");
  Serial.print(humidity);
  Serial.println(" %");

    Serial.println();
}    


void setup()
{
  //Debug console
  Serial.begin(9600);
  //"46.101.217.214", 8080); 
 
Blynk.begin(auth, gsmAccess, gprs, client, pin, apn, user, pass); 

timer.setInterval(2000L, ReadSensors);
timer.setInterval(2090L, sendAnalog);
 


  
Serial.println(F("BME280 test"));

    unsigned status;
    
    //default settings
    status = bme.begin();  
    //You can also pass in a Wire library object like &Wire2
    //status = bme.begin(0x76, &Wire2)
   if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }
    
    Serial.println("-- Default Test --");

    Serial.println();
}

void loop()
{
  //this start the blynk utilities and make run the iteration with the app
  Blynk.run();
  timer.run();
}




Here are some lines from the serial monitor

22:13:35.882 β†’ [14327] Connecting to internet.public …
22:13:38.204 β†’ [16656] Connected to GPRS
22:13:38.204 β†’ [16656] Connecting to blynk.cloud:80
22:13:39.039 β†’ [17501] <[1D|00|01|00] Z5q0dNb3PRiNEmZoEIt0ONA2ZEBwvQrw
22:13:39.316 β†’ [17795] >[00|00|01|00|C8]
22:13:39.316 β†’ [17796] Ready (ping: 268ms).
22:13:39.316 β†’ [17797] Free RAM: 26815
22:13:39.409 β†’ [17883] <[11|00|02|00|86]ver[00]1.0.0-beta.3[00]h-beat[00]60[00]buff-in[00]1024[00]dev[00]MKR GSM 1400[00]con[00]MKRGSM[00]fw-type[00]TMPLnbY3UnYY[00]build[00]Aug 20 2021 15:14:18[00]tmpl[00]TMPLnbY3UnYY[00]

22:13:39.502 β†’ BME280 test
22:13:39.642 β†’ – Default Test –
22:13:39.642 β†’
22:13:39.688 β†’ [18138] >[00|00|02|00|C8]
22:13:41.596 β†’ [20067] <[14|00|03|00|0D]vw[00]1[00]1011.679
22:13:41.736 β†’ [20179] <[14|00|04|00|0B]vw[00]2[00]25.370
22:13:41.827 β†’ [20291] <[14|00|05|00|0B]vw[00]6[00]40.983
22:13:41.874 β†’ Temperature = 25.37 Β°C
22:13:41.874 β†’ Pressure = 1011.68 kPa
22:13:41.874 β†’ Humidity = 40.98 %
22:13:41.874 β†’
22:13:42.013 β†’ [20471] <[14|00|06|00|0A]vw[00]5[00]0.147
22:13:42.013 β†’ 0.15
22:13:42.013 β†’
22:13:42.105 β†’ [20582] <[14|00|07|00|0A]vw[00]7[00]3.716
22:13:42.151 β†’ 3.72V
22:13:43.639 β†’ [22095] <[14|00|08|00|0D]vw[00]1[00]1011.666
22:13:43.733 β†’ [22209] <[14|00|09|00|0B]vw[00]2[00]25.350
22:13:43.875 β†’ [22322] <[14|00|0A|00|0B]vw[00]6[00]40.994
22:13:43.875 β†’ Temperature = 25.35 Β°C
22:13:43.875 β†’ Pressure = 1011.67 kPa
22:13:43.875 β†’ Humidity = 40.99 %
22:13:43.875 β†’
22:13:44.016 β†’ [22501] <[14|00|0B|00|0A]vw[00]5[00]0.141
22:13:44.060 β†’ 0.14
22:13:44.060 β†’
22:13:44.153 β†’ [22613] <[14|00|0C|00|0A]vw[00]7[00]3.762
22:13:44.153 β†’ 3.76V
22:14:04.966 β†’ Temperature = 25.34 Β°C
22:14:04.966 β†’ Pressure = 1011.66 kPa
22:14:04.966 β†’ Humidity = 41.02 %
22:14:05.014 β†’
22:14:05.014 β†’ 0.14
22:14:05.014 β†’
22:14:05.014 β†’ 3.86V
22:14:05.481 β†’ Temperature = 25.34 Β°C
22:14:05.481 β†’ Pressure = 1011.67 kPa
22:14:05.481 β†’ Humidity = 41.03 %
22:14:05.481 β†’
22:14:05.899 β†’ 0.14
22:14:05.899 β†’
22:14:05.899 β†’ 3.86V
22:14:07.514 β†’ Temperature = 25.33 Β°C
22:14:07.514 β†’ Pressure = 1011.64 kPa
22:14:07.514 β†’ Humidity = 41.04 %
22:14:07.514 β†’
22:14:07.930 β†’ 0.14
22:14:07.930 β†’
22:14:07.930 β†’ 3.86V
22:14:09.507 β†’ Temperature = 25.34 Β°C
22:14:09.507 β†’ Pressure = 1011.69 kPa
22:14:09.507 β†’ Humidity = 41.05 %
22:14:09.507 β†’
22:14:09.966 β†’ 0.13
22:14:09.966 β†’
22:14:09.966 β†’ 3.86V
22:14:09.966 β†’ [48457] Connecting to blynk.cloud:80

β€”power cycle or restartβ€”

22:52:28.079 β†’ [14331] Connecting to internet.public …
22:52:30.598 β†’ [16860] Connected to GPRS
22:52:30.598 β†’ [16860] Connecting to 46.101.217.214:8080
22:52:31.346 β†’ [17622] Ready (ping: 290ms).
22:52:31.533 β†’ BME280 test
22:52:31.673 β†’ – Default Test –
22:52:31.673 β†’
22:52:33.911 β†’ Temperature = 25.42 Β°C
22:52:33.911 β†’ Pressure = 1012.01 kPa
22:52:33.911 β†’ Humidity = 39.69 %
22:52:33.911 β†’
22:52:34.096 β†’ 0.14
22:52:34.096 β†’
22:52:34.189 β†’ 3.75V
22:52:35.913 β†’ Temperature = 25.43 Β°C
22:52:35.913 β†’ Pressure = 1012.05 kPa
22:52:35.913 β†’ Humidity = 39.68 %
22:52:35.913 β†’
22:52:36.101 β†’ 0.14
22:52:36.101 β†’
22:52:36.195 β†’ 3.88V
22:52:37.872 β†’ Temperature = 25.42 Β°C
22:52:37.872 β†’ Pressure = 1011.99 kPa
22:52:37.872 β†’ Humidity = 39.68 %
22:52:37.872 β†’
22:52:38.058 β†’ 0.14
22:52:38.058 β†’
22:52:38.152 β†’ 3.87V
22:52:39.923 β†’ Temperature = 25.42 Β°C
22:52:39.923 β†’ Pressure = 1012.03 kPa
22:52:39.923 β†’ Humidity = 39.70 %
22:52:39.923 β†’
22:52:40.063 β†’ 0.13
22:52:40.063 β†’
22:52:40.202 β†’ 3.88V
22:52:41.878 β†’ Temperature = 25.42 Β°C
22:52:41.878 β†’ Pressure = 1012.04 kPa
22:52:41.878 β†’ Humidity = 39.71 %
22:52:41.878 β†’
22:52:42.113 β†’ 0.14
22:52:42.113 β†’
22:52:42.207 β†’ 3.76V
22:52:43.886 β†’ Temperature = 25.42 Β°C
22:52:43.886 β†’ Pressure = 1012.02 kPa
22:52:43.886 β†’ Humidity = 39.69 %
22:52:43.886 β†’
22:52:44.211 β†’ 0.14
22:52:44.211 β†’
22:52:44.304 β†’ 3.77V
22:52:45.940 β†’ Temperature = 25.42 Β°C
22:52:45.940 β†’ Pressure = 1012.00 kPa
22:52:45.940 β†’ Humidity = 39.69 %
22:52:45.940 β†’
22:52:46.312 β†’ 0.13
22:52:46.312 β†’
22:52:46.406 β†’ 3.75V
22:52:47.856 β†’ Temperature = 25.42 Β°C
22:52:47.856 β†’ Pressure = 1012.00 kPa
22:52:47.856 β†’ Humidity = 39.68 %
22:52:47.856 β†’
22:52:48.368 β†’ 0.15
22:52:48.368 β†’
22:52:48.507 β†’ 3.82V
22:52:49.910 β†’ Temperature = 25.42 Β°C
22:52:49.910 β†’ Pressure = 1011.99 kPa
22:52:49.910 β†’ Humidity = 39.67 %
22:52:49.910 β†’
22:52:50.469 β†’ 0.13
22:52:50.469 β†’
22:52:50.608 β†’ 3.76V
22:52:51.867 β†’ Temperature = 25.42 Β°C
22:52:51.867 β†’ Pressure = 1012.03 kPa
22:52:51.867 β†’ Humidity = 39.67 %
22:52:51.867 β†’
22:52:52.568 β†’ 0.15
22:52:52.568 β†’
22:52:52.708 β†’ 3.73V
22:52:53.878 β†’ Temperature = 25.42 Β°C
22:52:53.878 β†’ Pressure = 1012.02 kPa
22:52:53.878 β†’ Humidity = 39.67 %
22:52:53.878 β†’
22:52:54.678 β†’ 0.14
22:52:54.678 β†’
22:52:54.771 β†’ 3.73V
22:52:55.846 β†’ Temperature = 25.43 Β°C
22:52:55.846 β†’ Pressure = 1012.00 kPa
22:52:55.846 β†’ Humidity = 39.67 %
22:52:55.846 β†’
22:52:56.778 β†’ 0.14
22:52:56.778 β†’
22:52:56.871 β†’ 3.75V
22:52:57.900 β†’ Temperature = 25.42 Β°C
22:52:57.900 β†’ Pressure = 1011.99 kPa
22:52:57.900 β†’ Humidity = 39.67 %
22:52:57.900 β†’
22:52:58.784 β†’ 0.18
22:52:58.784 β†’
22:52:58.923 β†’ 3.76V
22:52:59.853 β†’ Temperature = 25.43 Β°C
22:52:59.853 β†’ Pressure = 1012.00 kPa
22:52:59.853 β†’ Humidity = 39.67 %
22:52:59.853 β†’
22:53:19.916 β†’ Temperature = 25.43 Β°C
22:53:19.916 β†’ Pressure = 1012.04 kPa
22:53:19.916 β†’ Humidity = 39.68 %
22:53:19.916 β†’
22:53:19.916 β†’ 0.15
22:53:19.916 β†’
22:53:19.916 β†’ 3.88V
22:53:21.456 β†’ Temperature = 25.43 Β°C
22:53:21.456 β†’ Pressure = 1012.03 kPa
22:53:21.456 β†’ Humidity = 39.68 %
22:53:21.456 β†’
22:53:21.640 β†’ 0.14
22:53:21.640 β†’
22:53:21.640 β†’ 3.88V
22:53:23.458 β†’ Temperature = 25.43 Β°C
22:53:23.458 β†’ Pressure = 1012.04 kPa
22:53:23.458 β†’ Humidity = 39.68 %
22:53:23.458 β†’
22:53:23.739 β†’ 0.15
22:53:23.739 β†’
22:53:23.739 β†’ 3.88V
22:53:24.907 β†’ [71247] Connecting to 46.101.217.214:8080

I did try the same sketch on a MKR NB1500, with almost the same result.

any ideas?

22:00:55.061 β†’ [2663704] Heartbeat timeout
22:01:05.068 β†’ Temperature = 24.16 Β°C
22:01:05.068 β†’ Pressure = 1002.69 kPa
22:01:05.068 β†’ Humidity = 47.34 %
22:01:05.068 β†’
22:01:05.068 β†’ 2.31
22:01:05.068 β†’
22:01:05.068 β†’ 4.12V
22:01:05.068 β†’ [2673732] Connecting to 46.101.217.214:8080