GPS Tracker

by Gaurav Rathi in Circuits > Arduino

4608 Views, 18 Favorites, 0 Comments

GPS Tracker

IMG-20200708-WA0007_edited.jpg

Hey Guys in this video we will make a GPS tracker using Esp 8266 (nodemcu) and a neo 6m GPS module so let's get started

Supplies

Nodemcu
Jumpers
Neo 6m GPS module
Power bank

Wiring

IMG_20200706_195637.jpg
Connect the
RX pin of GPS module to D1 pin of nodemcu board

TX pin of GPS module to D2 pin of nodemcu

Vcc pin to 3.3volts

Gnd pin to Gnd

Blynk Iot App

Screenshot_20200706-201047.png
Install the blynk app https://play.google.com/store/apps/details?id=cc.blynk&hl=en_US

Add 2 labeled value display and name the 1 value as Latitude and select the pin v1
And name the second value as Longitude and select pin v2
And now add 3 value display and name the first one as satellite and select the pin v4
And now name the second one as speed and select pin v3
And now name the 3rd one as Direction and select the pin v5
And now add a map and select pin v0
And now select push to 1 second to every widget and create it

Code

Screenshot_20200706-221149_edited.jpg
An auth token will be send to your email account copy the token and paste it in the code and also edit and enter your WiFi ssid and password to the code and upload it!!
The code is


//Realtime GPS Tracker with Nodemcu ESP8266
#include
#include
#define BLYNK_PRINT Serial
#include
#include

static const int RXPin = 4, TXPin = 5; // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS
static const uint32_t GPSBaud = 9600; //if Baud rate 9600 didn't work in your case then use 4800

TinyGPSPlus gps; // The TinyGPS++ object
WidgetMap myMap(V0); // V0 for virtual pin of Map Widget

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

BlynkTimer timer;

float spd; //Variable to store the speed
float sats; //Variable to store no. of satellites response
String bearing; //Variable to store orientation or direction of GPS

char auth[] = "--------------------"; //Your Project authentication key
char ssid[] = "-------"; // Name of your network (HotSpot or Router name)
char pass[] = "-------"; // Corresponding Password

//unsigned int move_index; // moving index, to be used later
unsigned int move_index = 1; // fixed location for now


void setup()
{
Serial.begin(115200);
Serial.println();
ss.begin(GPSBaud);
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, checkGPS); // every 5s check if GPS is connected, only really needs to be done once
}

void checkGPS(){
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
Blynk.virtualWrite(V4, "GPS ERROR"); // Value Display widget on V4 if GPS not detected
}
}

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

void displayInfo()
{
if (gps.location.isValid() )
{
float latitude = (gps.location.lat()); //Storing the Lat. and Lon.
float longitude = (gps.location.lng());

Serial.print("LAT: ");
Serial.println(latitude, 6); // float to x decimal places
Serial.print("LONG: ");
Serial.println(longitude, 6);
Blynk.virtualWrite(V1, String(latitude, 6));
Blynk.virtualWrite(V2, String(longitude, 6));
myMap.location(move_index, latitude, longitude, "GPS_Location");
spd = gps.speed.kmph(); //get speed
Blynk.virtualWrite(V3, spd);

sats = gps.satellites.value(); //get number of satellites
Blynk.virtualWrite(V4, sats);

bearing = TinyGPSPlus::cardinal(gps.course.value()); // get the direction
Blynk.virtualWrite(V5, bearing);
}

Serial.println();
}

Presentation

IMG_20200706_195915.jpg
IMG_20200706_195929.jpg
Take a empty box place the whole system in to it and now connect the powerbank to the Nodemcu board

IMG_20200706_195929.jpg
All done !!