Can't connect our Maduino 4G LTE with GSM Module to Blynk

We are beginners and we’re trying this code we found on the web and we can’t establish connection between the device and Blynk it’s always offline. We already made a location type datastream using the V9 pin. The location it displays is in the ocean near Africa, which maybe because we can’t connect it to Blynk

Details:

  • Model: Maduino 4G LTE with GSM Module
  • Android/IOS
  • Blynk Server Region SGP1
#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

// Get your token or auth from your Blynk Device and copy here.
String token = "auth code here";
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;
    
  }
}



String conversion(String local, int i)
{
  String str_end;
  String str_init;
  if(local[0]=='0'){
      SerialUSB.print("local = 0\r\n");
      str_end = local.substring(3);
      str_init = local.substring(1,3);
      int val = str_init.toInt();
      double deci_val = str_end.toDouble();
      double new_value = val+(deci_val / 60);
      
      if(i == 1)
      {
        new_value = new_value * 10;
      }     

      String final_val = String(new_value,5);

      return final_val;
   }
  else if(local[0]!='0')
  {
      SerialUSB.print("local != 0\r\n");
      if(i == 0)
      {
        str_end = local.substring(2);
        str_init = local.substring(0,2);
      } 
      else if(i == 1)
      {
        str_end = local.substring(3);
        str_init = local.substring(0,3);
      }

      int val = str_init.toInt();
      double deci_val = str_end.toDouble(); 
      double new_value = val+(deci_val / 60); 
      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, 0);
    String lon = conversion(lon1, 1);

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

    // Important to set the correct blynk server for Philippines is sgp1
    // You can find the blynk server at lower right of blynk webpage
    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=0",3000,DEBUG);
  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);  
    }      
}

Your device will always appear offline when updating datastreams via the HTTP(S) API.

You are attempting to use the Batch update API, which is the wrong approach. If you read the documentation it shows two options for passing multiple parameters to a datastrem.
Read the part that says “To update Datastreams that have 2 values, for example Location Datastream, use this call:” at the bottom of this page…

Pete.