[SOLVED] Arduino or NodeMCU GPS tracking system on Map widget

hm, thats interesting. are you sure the blynk app on the phone has solid internet connection and receives the values every second?

you should put this line into void getcoordinates:
Blynk.virtualWrite(V5, millis() / 1000);

and create a display widget in blynk app on v5, set to push and check if the seconds are rising.

also, you could serial print the lat and long variables to serial monitor, to check what is actually sending to the app. or if you do not have tx rx pins free, you can send the coordinates as the millis, to wirtual pins, and see in the app. than on google maps you can verify if those coordinates are really in nigeria…

1 Like

Yes my devices is connected to blynk in device status showing Online.

I add Blynk.virtualWrite(V5, millis() / 1000); and set map widget to V5 but nothing happen :frowning:

this project make me crazy :cry:

than it means the values are not sent to blynk app. the v5 display widget in blynk app should change every second, showing the esp uptime.

but not map widget should be set to v5, rather you have to create a new display widget in your project!

@ErfanDL post your latest sketch that includes all the recommendations by @wanek

@wanek
@Costas

here is my code:

the value is show in value widget

    /*************************************************************
      Download latest Blynk library here:
        https://github.com/blynkkk/blynk-library/releases/latest

      Blynk is a platform with iOS and Android apps to control
      Arduino, Raspberry Pi and the likes over the Internet.
      You can easily build graphic interfaces for all your
      projects by simply dragging and dropping widgets.

        Downloads, docs, tutorials: http://www.blynk.cc
        Sketch generator:           http://examples.blynk.cc
        Blynk community:            http://community.blynk.cc
        Follow us:                  http://www.fb.com/blynkapp
                                    http://twitter.com/blynk_app

      Blynk library is licensed under MIT license
      This example code is in public domain.

     *************************************************************

      Output any data on Map widget!

      App project setup:
        Map widget on V1
     *************************************************************/

    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial


    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <TinyGPS++.h>
    #include <SoftwareSerial.h>

    static const int RXPin = 12, TXPin = 13;
    static const uint32_t GPSBaud = 9600;

    TinyGPSPlus gps;
    BlynkTimer timer;

    SoftwareSerial ss(RXPin, TXPin);

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "4bb191e6da5a438bb071ecca688732f3";

    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "MikroTik Home";
    char pass[] = "";
    char server[] = "192.168.1.104";

    WidgetMap myMap(V5);

    void setup()
    {
      // Debug console
      Serial.begin(9600);
      Blynk.begin(auth, ssid, pass, server);
      // You can also specify server:
      //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
      //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
      timer.setInterval(1000L, getCoordinates);
      Blynk.virtualWrite(V5, millis() / 1000);
      myMap.clear();
    }

    void getCoordinates()
    {
      float lat = (gps.location.lat(), 5);
      float lon = (gps.location.lng(), 4);

      myMap.location(1, lat, lon, "value");
    }

    void loop()
    {
      Blynk.run();
      timer.run();
    }

and what it gives you google maps, if you put the above coordinates ?
15.0 and 4.0

?

https://www.gps-coordinates.net/

you project is working perfectly. the problem is, that you do not get the proper coordinates! probably somehow you loosing the decimals of the floats. this is the problem.

1 Like

instead of this:

float lat = (gps.location.lat(), 5);
  float lon = (gps.location.lng(), 4);

  myMap.location(1, lat, lon, "value");

try this:

myMap.location(1, gps.location.lat(), gps.location.lng(), "value");

and report here what you see on the v5 display widget!

1 Like

I’m do it but again show in nigeria :((((((

    /*************************************************************
      Download latest Blynk library here:
        https://github.com/blynkkk/blynk-library/releases/latest

      Blynk is a platform with iOS and Android apps to control
      Arduino, Raspberry Pi and the likes over the Internet.
      You can easily build graphic interfaces for all your
      projects by simply dragging and dropping widgets.

        Downloads, docs, tutorials: http://www.blynk.cc
        Sketch generator:           http://examples.blynk.cc
        Blynk community:            http://community.blynk.cc
        Follow us:                  http://www.fb.com/blynkapp
                                    http://twitter.com/blynk_app

      Blynk library is licensed under MIT license
      This example code is in public domain.

     *************************************************************

      Output any data on Map widget!

      App project setup:
        Map widget on V1
     *************************************************************/

    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial


    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <TinyGPS++.h>
    #include <SoftwareSerial.h>

    static const int RXPin = 12, TXPin = 13;
    static const uint32_t GPSBaud = 9600;

    TinyGPSPlus gps;
    BlynkTimer timer;

    SoftwareSerial ss(RXPin, TXPin);

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "4bb191e6da5a438bb071ecca688732f3";

    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "MikroTik Home";
    char pass[] = "";
    char server[] = "192.168.1.104";

    WidgetMap myMap(V5);

    void setup()
    {
      // Debug console
      Serial.begin(9600);
      Blynk.begin(auth, ssid, pass, server);
      // You can also specify server:
      //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
      //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
      timer.setInterval(1000L, getCoordinates);
      Blynk.virtualWrite(V5, millis() / 1000);
      myMap.clear();
    }

    void getCoordinates()
    {
    myMap.location(1, gps.location.lat(), gps.location.lng(), "value");
    }

    void loop()
    {
      Blynk.run();
      timer.run();
    }

you are loosing the decimals after lat / long somehow. i do not know the cause, but i think this is the problem.

1 Like

Do you know Who is in this forum can help me?

@ErfanDL Map widget syntax:

myMap.location(index, lat, lon, "value");

“value” is “Home”, “Iran”, “Work” or some generic term like “GPS_Loc” but not “value”. The syntax is just showing you that you need a String for the GPS place name.

I believe V5 is your map so you can’t send millis() to it and it is no good sending millis() in setup.

Comment that line out in setup()

Create a display on V6 for millis().

Create another 2 display widgets, V7 LAT and V8 LONG

Then replace your getCoordinates() function with this:

unsigned int move_index;

    void getCoordinates()
    {
      Blynk.virtualWrite(V6, millis() / 1000);
      move_index++;
      float lat = (gps.location.lat(), 5);
      float lon = (gps.location.lng(), 4);
      Serial.println(V7, String(lat, 5);
      Serial.println(V8, String(lon, 4);
      
      myMap.location(move_index, lat, lon, "Iran");
    }

Then paste your amended sketch again. plus Serial Monitor and details of what you see in your Blynk project.

1 Like

thanks for reply. I adding your code but when compiling I got error expected ')' before ';' token the error in line 76 Serial.println(V8, String(lon, 4);

    /*************************************************************
      Download latest Blynk library here:
        https://github.com/blynkkk/blynk-library/releases/latest

      Blynk is a platform with iOS and Android apps to control
      Arduino, Raspberry Pi and the likes over the Internet.
      You can easily build graphic interfaces for all your
      projects by simply dragging and dropping widgets.

        Downloads, docs, tutorials: http://www.blynk.cc
        Sketch generator:           http://examples.blynk.cc
        Blynk community:            http://community.blynk.cc
        Follow us:                  http://www.fb.com/blynkapp
                                    http://twitter.com/blynk_app

      Blynk library is licensed under MIT license
      This example code is in public domain.

     *************************************************************

      Output any data on Map widget!

      App project setup:
        Map widget on V1
     *************************************************************/

    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial


    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <TinyGPS++.h>
    #include <SoftwareSerial.h>

    static const int RXPin = 12, TXPin = 13;
    static const uint32_t GPSBaud = 9600;

    TinyGPSPlus gps;
    BlynkTimer timer;

    SoftwareSerial ss(RXPin, TXPin);

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "4bb191e6da5a438bb071ecca688732f3";

    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "MikroTik Home";
    char pass[] = "";
    char server[] = "192.168.1.104";

    WidgetMap myMap(V5);

    void setup()
    {
      // Debug console
      Serial.begin(9600);
      Blynk.begin(auth, ssid, pass, server);
      // You can also specify server:
      //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
      //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
      timer.setInterval(1000L, getCoordinates);
    }

    unsigned int move_index;

    void getCoordinates()
    {
       Blynk.virtualWrite(V6, millis() / 1000);
       move_index++;
       float lat = (gps.location.lat(), 5);
       float lon = (gps.location.lng(), 4);
       Serial.println(V7, String(lat, 5);
       Serial.println(V8, String(lon, 4);

       myMap.location(move_index, lat, lon, "Iran");
    }

    void loop()
    {
      Blynk.run();
      timer.run();
    }
   Serial.println(V7, String(lat, 5));
   Serial.println(V8, String(lon, 4));
1 Like

I changed it now got error in line 76
exit status 1
no matching function for call to ‘HardwareSerial::println(int, String)’

void getCoordinates()
{
   Blynk.virtualWrite(V6, millis() / 1000);
   move_index++;
   float latitude = (gps.location.lat(), 5);
   float longitude = (gps.location.lng(), 4);
   Serial.println(String(latitude, 5));
   Serial.println(String(longitude, 4));
   Blynk.virtualWrite(V7, String(latitude, 5));
   Blynk.virtualWrite(V8, String(latitude, 4));
   myMap.location(move_index, latitude, longitude, "Iran");
}

This compiles.

1 Like

thanks for all help but again show location in nigeria :cry:
I think it’s a bug with blynk app

I have used the Map widget in my projects and it’s not a bug !!!

What does Serial Monitor give you?

What do you see on V6, V7 and V8?

2 Likes

Change the function to:

void getCoordinates()
{
   Blynk.virtualWrite(V6, millis() / 1000);
   move_index++;
   float latitude = (gps.location.lat(), 6);
   float longitude = (gps.location.lng(), 6);
   Serial.println(latitude, 6);
   Serial.println(longitude, 6);
   Blynk.virtualWrite(V7, latitude);
   Blynk.virtualWrite(V8, longitude);
   myMap.location(move_index, latitude, longitude, "Iran");
}

But then paste Serial Monitor as well as screenshot of project.

1 Like

You must also include the map widget in your project and tied to V5. I can’t see the map of Nigeria in your last screenshot.

1 Like