Need Help with BLYNK 2.0 and SIM7600E Device Offline

We really need help on completing this project in 5 days. Please help us and it would very much appreciated.

Details :
• Maduino Zero 4G LTE with GPS Module
• iOS and Android
• Blynk server = SGP1
• I don’t have any idea about the blynk library since I am a new user.
• The code below is not mine, since I am just trying out the one I found in YouTube. I followed all and still the device appears offline in the mobile and web Blynk app.

#include <stdio.h>
#include <string.h>


#define DEBUG true
#define MODE_1A

#define DTR_PIN 9
#define RI_PIN 8

#define LTE_PWRKEY_PIN 5
#define LTE_RESET_PIN 6
#define LTE_FLIGHT_PIN 7

String token = "ADD YOU TOKEN HERE";
String from_usb = "";
String loc = "";
String longitude = "";
String lattitude = ""; 

//FUNCTION TO PASS AT COMMAND

String sendData(String command, const int timeout, boolean debug)
{
  String response = "";
  Serial1.println(command);

  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (Serial1.available())
    {
      char c = Serial1.read();
      response += c;
    }
  }
  if (debug)
  {
    SerialUSB.print(response);
  }
  return response;
}

//FUNCTION TO CHECK SIGNAL STRENGTH

int check_signal(void)
{
  while(1)
  {
    String sig = sendData("AT+CSQ",3000,DEBUG);
    int i=0;
    String strength;
    while(sig[i]!=':')i++;

    String loc_2 = sig.substring(i+2);

    i=0;
    while(loc_2[i]!=',')i++;

    strength = loc_2.substring(0,i);

    int strength_1 = strength.toInt();
    SerialUSB.println(strength_1);

    return strength_1;
  }
}

//FUNCTION TO GET LATITUDE AND LONGITUDE STRING

void gpsLocation(String local)
{
//  char* loc_2 = local;
//  int p=0;

  while(1)
  {
    int i=0;
    while(local[i]!=':')i++;

    String loc_2 = local.substring(i+2);

    i=0;
    while(loc_2[i]!=',')i++;

    lattitude = loc_2.substring(0,i);
    SerialUSB.println(lattitude);

    int j = i+3;
    int k = j;

    while(loc_2[k]!=',')k++;

    longitude = loc_2.substring(j,k);
    SerialUSB.println(longitude); 

    return;

  }
}

//CONVERSION OF GIVEN LATTITUDE FORMAT FROM NMEA TO PARSER

String conversion(String local)
{
  if(local[0]=='0'){
      String str_end = local.substring(3);

      String str_init = local.substring(1,3);

      int val = str_init.toInt();

      double deci_val = str_end.toDouble() ;

      double new_value = val+(deci_val / 60);
      SerialUSB.println(new_value);

      String final_val = String(new_value,5);

      return final_val;
   }
  else if(local[0]!='0')
  {
      String str_end = local.substring(2);

      String str_init = local.substring(0,2);

      int val = str_init.toInt();

      double deci_val = str_end.toDouble() ;

      double new_value = val+(deci_val / 60);
      SerialUSB.println(new_value);

      String final_val = String(new_value,5);

      return final_val;
  }
}

//FUNCTION TO PASS LOCATION IN BLYNK API

void map_loc(String lat1,String lon1)
{
    String lat = conversion(lat1);
    String lon = conversion(lon1);

    SerialUSB.print("lattitude = ");SerialUSB.println(lat);
    SerialUSB.print("longitude = ");SerialUSB.println(lon);

    String http_str = "AT+HTTPPARA=\"URL\",\"https://sgp1.blynk.cloud/external/api/batch/update?token=" + token + "&V9=" + lon + "&V9=" + lat + "\"\r\n";
    SerialUSB.println(http_str);
    sendData("AT+HTTPINIT\r\n", 3000, DEBUG);
    sendData(http_str, 3000, DEBUG);
    sendData("AT+HTTPACTION=0\r\n", 3000, DEBUG);
    sendData("AT+HTTPTERM\r\n", 3000, DEBUG);
}

void setup(){
  SerialUSB.begin(115200);
  //while (!SerialUSB)
//  {
    ; // wait for Arduino serial Monitor port to connect
//  }

  delay(100);

  Serial1.begin(115200);

  //INITIALIZING GSM MODULE

  pinMode(LTE_RESET_PIN, OUTPUT);
  digitalWrite(LTE_RESET_PIN, LOW);

  pinMode(LTE_PWRKEY_PIN, OUTPUT);
  digitalWrite(LTE_RESET_PIN, LOW);
  delay(100);
  digitalWrite(LTE_PWRKEY_PIN, HIGH);
  delay(2000);
  digitalWrite(LTE_PWRKEY_PIN, LOW);

  pinMode(LTE_FLIGHT_PIN, OUTPUT);
  digitalWrite(LTE_FLIGHT_PIN, LOW); //Normal Mode
  // digitalWrite(LTE_FLIGHT_PIN, HIGH);//Flight Mode

  SerialUSB.println("Maduino Zero 4G Test Start!");



  SerialUSB.println(sendData("AT+CGMM\r\n", 3000, DEBUG));
  sendData("AT+CPIN?\r\n",3000,DEBUG);

  sendData("AT+COPS?\r\n",3000,DEBUG);

  sendData("AT+CNUM\r\n",3000,DEBUG);

  //INITIALIZING GPS MODULE

  sendData("AT+CGPS=1",3000,DEBUG);
  delay(60000);


}

void loop(){

    //CHECKING SIGNAL STRENGTH

    if(check_signal()>=10)
    {
      loc = sendData("AT+CGPSINFO\r\n",3000,DEBUG);
      gpsLocation(loc);
      if(lattitude!=""&& longitude!="")
      {
        map_loc(lattitude,longitude);
      }
      delay(5000);  
    }    
}


You don’t have any blynk functions in your sketch. I’d suggest that you start by searching the forum.

Your sketch uses the HTTP(S) REST API to push values to Blynk.
When you use this method your device will always appear offline.

Devices only appear online when you establish an always on connection via the Blynk library and maintain that connection via the use of Blynk.run(); in the void loop (along with very little else).

I’d suggest that you stick with your current system, unless having the device appear offline is a deal breaker.

What type of Blynk subscription do you have, and what type of datastream have you set-up for V9 ?

Pete.

Hi Good Day!

So I think we shall just stick with our current system, the only thing that prevents us from completing this project is that there are no updates on the Maps that we have in our mobile phone which is included in the Blynk app. We have the Plus subscription and the datastream that we are using is the String Data Stream 1 V9. We can see from the data stream that it is updating from time to time, but the visuals on the map is not updating.

Thank you in advance.
RJ

It’s difficult yo advise without more info, but I would have expected you to be using a Location datastream.

Are you trying to display the results in the app dashboard or the web dashboard - or both?

Pete.

Hello.

Yes we are using a Location Datastream. We are trying to display the results in the app dashboard, since we also have setup a Map in the Blynk application itself.

I have also attached what we are seeing on the datastream at this moment.

Thank you so much.

RJ

It can’t be both!

Pete.

Can we ask for an advice where we can see a live update on the map that we have on the Blynk app?

Thank you.

RJ

I can’t help unless you give straight answers to my questions, which you aren’t doing at the moment.

I suspect, from the limited information that you’ve provided, that you are using a Virtual datastream rather than a Location datastream.

Pete.

Hello.

Sorry for the confusion that I have made. To clear things up, we are using String Data Stream V9 which is configured in the mobile application. We are not sure if it is a location one or a virtual one since it only shows string data stream. We just followed what we are instructed in the video, but we can’t make it appear on the map in the blynk app.

Thank you so much.
RJ

Follow up - We are using a Virtual Data Stream.

Thanks
RJ

I’d suggest that you delete that datastream and create a new one, with Location type and choose pin V9 as as the pin, then see what happens.

Pete.

Hello.

May I ask if we will create a new datastream in the mobile app? When adding maps on the Blynk app, I can’t find the Location Type, but able to choose pin V9 as the pin.

Thanks for your help.
RJ

I always create my datastreams in the web console.
It’s possible that the Location datastream type is only available to Pro users, in which case it will have “Upgrade” next to it.

Pete.

Hello.

Thank you for your suggestion. I was able to monitor the location now in the maps.

Thanks a lot.
RJ

1 Like