I’m not able to see more than 3 decimal places on the web console nor the app. I have made the settings of virtual pin to display 5 decimal places. Need help.
@ChethanMurthy Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Decimal latitude and longitude values range from -180 to +180 so defining a datastream with a minimum value of 0 and a maximum of 100 makes no sense.
Is there a reason why you aren’t using a Location type datastream for this?
Also, you’ve not really shared enough of your sketch because we can’t see the data types that you’ve declared for your Lat and Lon variables and your code shows you writing these values to V1 and V6 but your screenshot shows the setup for datastream V0
#include "TinyGPS++.h"
#include "SoftwareSerial.h"
#define BLYNK_TEMPLATE_ID "TMPL3_XM0d5wJ"
#define BLYNK_TEMPLATE_NAME "GPS Tracker"
#define BLYNK_AUTH_TOKEN "Ie5nyQsN-rnafgScWx0wsFCiSpPes305"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Router24GHz";
char pass[] = "2.4GHz*router";
char auth[] = "Ie5nyQsN-rnafgScWx0wsFCiSpPes305";
BlynkTimer timer;
SoftwareSerial serial_connection(4,5); //tx,rx
TinyGPSPlus gps;// GPS object to process the NMEA data
float Lat;
float Lon;
float latitude;
float longitude;
int hrs;
int mint;
void setup()
{
Serial.begin(115200); //This opens up communications to the Serial monitor in the Arduino IDE
serial_connection.begin(9600); //This opens up communications to the GPS
Serial.println("GPS Location Acquired"); //To show in the serial monitor that the sketch has started
Blynk.begin(auth, ssid, pass);
}
void loop()
{
while(serial_connection.available()) //While there are incoming characters from the GPS
{
gps.encode(serial_connection.read()); //This feeds the serial NMEA data into the library one char at a time
}
readGPS();
Blynk.run();
timer.run();
}
void readGPS()
{
if(gps.location.isUpdated()) //This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in
{
//Get the latest info from the gps object which it derived from the data sent by the GPS unit
Lat=gps.location.lat();
Lon=gps.location.lng();
//Serial.print("Satellite Count:");
//Serial.println(gps.satellites.value());
Serial.println("Latitude:");
Serial.println(Lat, 6);
Blynk.virtualWrite(V0,Lat);
Serial.println("Longitude:");
Serial.println(Lon, 6);
Blynk.virtualWrite(V1,Lon);
Blynk.virtualWrite(V6, Lon, Lat);
Serial.println(" ");
Serial.print(Lat,6);
Serial.print(",");
Serial.println(Lon,6);
Serial.println("");
delay(10000);
}
}
So, if you are using a Location datastream type for V6, rather than the Virtual Pin datastream type of the datastream you used in your screenshot then you’ll notice that it says this…
but instead you are using float variable types…
Other issues…
You shouldn’t be doing this…
instead you should do this…
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
You shouldn’t have this in your void loop…
or this in readGPS()…
Instead you should be using a BlynkTimer interval timer to call a function every 10 seconds to read your software serial input and send the results to Blynk and the serial monitor.
You also have some unused variables in your sketch, which are quite confusing (especially the latitude and longitude ones)…
Making the changes yourself will mean that you learn more about C++ programming, and you have the libraries installed and hardware available to do the testing - which I don’t.
Thanks a lot for all you inputs, I’m able to display 5 decimals on the web console.
I Chaged float to double and I’m rewriting the the time function using Blynk Timer.
Can I display more than 5 decimal places on the new blynk?
#include "TinyGPS++.h"
#include "SoftwareSerial.h"
#define BLYNK_TEMPLATE_ID "TMPL3_XM0d5wJ"
#define BLYNK_TEMPLATE_NAME "GPS Tracker"
#define BLYNK_AUTH_TOKEN "Ie5nyQsN-rnafgScWx0wsFCiSpPes305"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Router24GHz";
char pass[] = "2.4GHz*router";
BlynkTimer timer;
SoftwareSerial serial_connection(4,5); //tx,rx
TinyGPSPlus gps;// GPS object to process the NMEA data
double Lat;
double Lon;
void setup()
{
Serial.begin(115200); //This opens up communications to the Serial monitor in the Arduino IDE
serial_connection.begin(9600); //This opens up communications to the GPS
Serial.println("GPS Location Acquired"); //To show in the serial monitor that the sketch has started
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(10000L, checkGPS);
}
void loop()
{
while(serial_connection.available()) //While there are incoming characters from the GPS
{
gps.encode(serial_connection.read()); //This feeds the serial NMEA data into the library one char at a time
}
checkGPS();
Blynk.run();
timer.run();
}
void checkGPS()
{
if(gps.location.isUpdated()) //This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in
{
//Get the latest info from the gps object which it derived from the data sent by the GPS unit
Lat=gps.location.lat();
Lon=gps.location.lng();
//Serial.print("Satellite Count:");
//Serial.println(gps.satellites.value());
Serial.println("Latitude:");
Serial.println(Lat, 6);
Blynk.virtualWrite(V0,Lat);
Serial.println("Longitude:");
Serial.println(Lon, 6);
Blynk.virtualWrite(V1,Lon);
Blynk.virtualWrite(V6, Lon, Lat);
Serial.println(" ");
Serial.print(Lat,6);
Serial.print(",");
Serial.println(Lon,6);
Serial.println("");
}
}
I have changed the code with your directions but timer function isn’t working for 10 seconds, its working continously.