Latitude and Longitude displaying incorrectly in Blynk

• Hardware model + communication type: LilyGO-T-SIM7000G, GSM.
• Blynk Library version: Latest.

Hello, I have a working project that displays temperature and gps coordinates. Everything is sending to Blynk correctly however the latitude and longitude values are showing two digits with no decimal points. Within the code I’m specifying to show 6 decimal points before sending as a string variable to a label widget. Also the strings, String test = String(my_lat,6) and String test2 = String(my_lng,6) within the code is displaying the correct decimal point when displayed on the serial monitor so is the problem within Blynk? This is the only thing holding me back from purchasing a plus subscription so I can use the map widget. Can someone let me know what parts I need to change or add?

#include <OneWire.h>
#include <DallasTemperature.h>
const int oneWireBus = 4;
OneWire oneWire(oneWireBus);
DallasTemperature sensors(&oneWire);

#define SerialMon Serial

// Set serial for AT commands (to the module)
// Use Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1

#define TINY_GSM_MODEM_SIM7000
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#define SerialAT Serial1
#define BLYNK_PRINT Serial
#define BLYNK_HEARTBEAT 30

#define BLYNK_TEMPLATE_ID "TMPLUOrzxykN"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN ""

// See all AT commands, if wanted
// #define DUMP_AT_COMMANDS

// set GSM PIN, if any
#define GSM_PIN ""

// Your GPRS credentials, if any

#include <SimpleTimer.h>
#include <TinyGsmClient.h>
#include <SPI.h>
#include <SD.h>
#include <Ticker.h>
#include <BlynkSimpleTinyGSM.h>
#include <Wire.h>

#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif


#define UART_BAUD           9600
#define PIN_DTR             25
#define PIN_TX              27
#define PIN_RX              26
#define PWR_PIN             4

#define SD_MISO             2
#define SD_MOSI             15
#define SD_SCLK             14
#define SD_CS               13
#define LED_PIN             12
#define I2C_SDA              21
#define I2C_SCL              22
#define SMS_TARGET  ""

bool smsSent = false;
float movingspeed = 10;
float my_lat;
float my_lng;
float speed;
float satellites;
String direction;

const char apn[]  = "h2g2";

const char user[] = "";
const char pass[] = "";
const char auth[] = "";
static const uint32_t GPSBaud = 9600;
WidgetMap myMap(V0);
BlynkTimer timer;
unsigned int move_index = 1;


void enableGPS(void)
{
    // Set SIM7000G GPIO4 LOW ,turn on GPS power
    // CMD:AT+SGPIO=0,4,1,1
    // Only in version 20200415 is there a function to control GPS power
    modem.sendAT("+SGPIO=0,4,1,1");
    if (modem.waitResponse(10000L) != 1) {
        DBG(" SGPIO=0,4,1,1 false ");
    }
    modem.enableGPS();


}

void disableGPS(void)
{
    // Set SIM7000G GPIO4 LOW ,turn off GPS power
    // CMD:AT+SGPIO=0,4,1,0
    // Only in version 20200415 is there a function to control GPS power
    modem.sendAT("+SGPIO=0,4,1,0");
    if (modem.waitResponse(10000L) != 1) {
        DBG(" SGPIO=0,4,1,0 false ");
    }
    modem.disableGPS();
}

void modemPowerOn()
{
    pinMode(PWR_PIN, OUTPUT);
    digitalWrite(PWR_PIN, LOW);
    delay(1000);    //Datasheet Ton mintues = 1S
    digitalWrite(PWR_PIN, HIGH);
}

void modemPowerOff()
{
    pinMode(PWR_PIN, OUTPUT);
    digitalWrite(PWR_PIN, LOW);
    delay(1500);    //Datasheet Ton mintues = 1.2S
    digitalWrite(PWR_PIN, HIGH);
}


void modemRestart()
{
    modemPowerOff();
    delay(1000);
    modemPowerOn();
}

void setup()
{
    // Set console baud rate
    SerialMon.begin(115200);
    sensors.begin();

    delay(10);
     

    // Set LED OFF
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, HIGH);

    modemPowerOn();

    SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);

    Serial.println("/**********************************************************/");
    Serial.println("To initialize the network test, please make sure your GPS");
    Serial.println("antenna has been connected to the GPS port on the board.");
    Serial.println("/**********************************************************/\n\n");

    delay(10000);
     String modemInfo = modem.getModemInfo();
  SerialMon.print("Modem: ");
  SerialMon.println(modemInfo);

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  SerialMon.print("Waiting for network...");
  if (!modem.waitForNetwork(240000L)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" OK");

  if (modem.isNetworkConnected()) {
    SerialMon.println("Network connected");
  }

  SerialMon.print(F("Connecting to APN: "));
  SerialMon.print(apn);
  if (!modem.gprsConnect(apn, user, pass)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" OK");
  //  ss.begin(GPSBaud);
  
  Blynk.begin(auth, modem, apn, user, pass);
  //timer.setInterval(5000L, checkGPS);
}

void GPS_STUFFS()
{
  if (!modem.testAT()) {
        Serial.println("Failed to restart modem, attempting to continue without restarting");
        modemRestart();
        return;
    }

    Serial.println("Start positioning . Make sure to locate outdoors.");
    Serial.println("The blue indicator light flashes to indicate positioning.");

    enableGPS();

     float lat,  lng;
      
     while(1) 
     {   
        if (modem.getGPS(&lat, &lng))
        {
            Serial.println("The location has been locked, the latitude and longitude are:");
            Serial.print("latitude:"); Serial.println(lat,6);
            Serial.print("longitude:"); Serial.println(lng,6);

            my_lat = lat;
            my_lng = lng; 

            digitalWrite(LED_PIN, !digitalRead(LED_PIN));
            break;
        }
        
        delay(2000); 
     }       
}

void get_temp()
{
  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);
  float temperatureF = sensors.getTempFByIndex(0); 
  Blynk.virtualWrite(V2, double(temperatureC));
  Blynk.virtualWrite(V1, double(temperatureF));
}
void log_gps()
{
  String test = String(my_lat,6);
  String test2 = String(my_lng,6);

  Serial.print(test);
  Serial.print(test2);
  
  Blynk.virtualWrite(V3, String(my_lat, 6));
  Blynk.virtualWrite(V5, String(my_lng, 6));
}

void loop()
{
  Blynk.run();
  timer.run();
  GPS_STUFFS();
  get_temp();
  log_gps();
}

How are your V3 and V5 datastreams configured?

Also, you should read this:

https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

Pete.

V3 and V5 datastream should be configured with max decimal points - but it’s 5 for now

Looks like in your set up V3 and V5 are either int data-streams, or double ones but without decimals

Must be on the top of your sketch, above anything.

You’re including the SimpleTimer library and using BlynkTimer and you’re not using it correctly, you can start by deleting this line

#include <SimpleTimer.h>

There’s no need to add it.
and use Interval timer in the void setup to call your functions, instead of put them in the void loop.

both are V3 and V5 are configured as strings in the datastream. However if I change the datatype to double latitude shows up correctly and longitude shows up as 0. If I switch longitude back to string it shows up as something like “-97”. It’s really werid and I’m not sure why longitude is reverting back to 0.

Gotcha I can fix that. But the timer woudln’t be the reason why the value is not showing up with 6 decimal points?

In the datastream I set them as strings and I’m sending datatype string within my code. No way to set decimal points with strings.

That’s right, but this is an error that you should fix.
also, string type datastream accept any value

What’s the sense in doing this?
Why create two variables called test and test1 then serial print them, but then not use the same variables when doing the Blynk.virtual Write?

Also, why are you using strings at all?

Pete.