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

Ok, the problem is the syntax of your GPS library.

What does Serial Monitor show with this function:

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");
   Serial.print(gps.location.lat(), 6);
   Serial.print(F(","));
   Serial.print(gps.location.lng(), 6);
}
1 Like

So your GPS receiver is not providing the co-ordinates from the sketch you created.

Go back to the library you picked and find a sketch that works without Blynk.

Paste Serial Monitor when you have some coordinates and the sketch you used.

THEN we will think about Blynk.

2 Likes

@ErfanDL you missed the following line from your sketch:

ss.begin(GPSBaud);

Put it after
Serial.begin(9600);

Guess what the missing line does?

What does Serial Monitor show now?

1 Like

It either moves him to Nigeria, or it starts his GPSā€¦ either way it should place the two together at last :stuck_out_tongue_winking_eye:

2 Likes

Iā€™m do it and serial monitor: and in blynk again show nigeria

yesterday I used blow sket with my NodeMCU and UBLOX 7 GPS module and its worked perfectly

https://github.com/mkconer/ESP8266_GPS/blob/master/ESP8266_GPS_OLED_Youtube.ino

@Gunner earlier I was going to suggest that @ErfanDL moves to Nigeria and all his (GPS) problems would be solved :slight_smile:

5 Likes

Please do not mock me :sob:

Relax @ErfanDL You have asked for help and you are getting helpā€¦ Us regulars tend to joke a bit, but weā€™re not mocking you, just some levity about common (if not practical ;)) GPS solution ideas.

2 Likes

Forget Nigeria, forget the map, forget Blynk. The first thing you need from this sketch and almost every sketch you will create for the next 12 months is get accurate data from Serial Monitor.

What does SM show for this sketch:

// GPS.ino https://community.blynk.cc/t/arduino-or-nodemcu-gps-tracking-system-on-map-widget/15739/33

#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;
unsigned int move_index;

TinyGPSPlus gps;
BlynkTimer timer;

SoftwareSerial ss(RXPin, TXPin);
char auth[] = "4bb191e6da5a438bb071ecca688732f3";
char ssid[] = "MikroTik Home";
char pass[] = "";
char server[] = "192.168.1.104";

WidgetMap myMap(V5);

void setup()
{
  
  Serial.begin(115200); // Debug console
  Serial.println();
  ss.begin(GPSBaud);
  Blynk.begin(auth, ssid, pass, server);
  timer.setInterval(5000L, getCoordinates); // 5s not 1s intervals
}


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");
   Serial.print("LAT: ");
   Serial.println(gps.location.lat(), 6);
   Serial.print("LONG: ");
   Serial.println(gps.location.lng(), 6);
}

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

thanks. Please do not hesitate to help me out

No problemā€¦ my best adviceā€¦ listen to @Costas!! He is smart, but like me, prone to back away if his directions go unheeded.

1 Like

SM for this sketch (you might need to set GPSBaud at 9600):

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 12(rx) and 13(tx).
*/
static const int RXPin = 12, TXPin = 13;
static const uint32_t GPSBaud = 4800;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);

  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}
1 Like

gps location from serial monitor worked

Progress at last.

I only have GPS with my Smartphones but give me some time and I will Blynkify your working sketch.

1 Like

thank you so much. Iā€™m waiting :tulip: :tulip: :tulip:

Are you using 4800 or 9600 for the GPS baud?

1 Like

9600