GPS Tracker using ESP8266

We will use the following components:

  • NodeMCU (it has a built-in ESP8266)
  • GPS receiver (you can use the Ublox NEO-6M GPS Module)
  • A few cables
  • Power source
  • A smartphone (for the Blynk)

To make the connection, follow the pin configurations with NodeMCU and the GPS receiver:

NodeMCU

GPS receiver

D1

TX

D2

RX

GND

GND

VCC

3V

 

See the following circuit for clarification:

  1. Now, connect the NodeMCU to the computer and open the Arduino application to program the NodeMCU. Before uploading the code, let's open our Blynk app.
  2. Create a new project, as we discussed in Chapter 3, Preparing Your Drone for Flying.
  3. Remember the authentication code sent to the email address you registered with the app; this will be needed later. In my case, I have set my project name as MY GPS TRACKER, device type as NodeMCU, and connection type WiFi, as follows:
  1. To see the real-time location in text value, add two text fields with Labeled Value.
  2. For latitude, set the pin type Virtual and pin V1:
  1. For longitude, select pin type Virtual and pin V2, as follows. You may change the color of the text by tapping the circular color icon:
  1. Now, add the map from the widget menu and select pin type to be Virtual and number to be V0:
  1. The Blynk application will need your permission to use your phone's GPS. You may see the following if the location service is turned off:
  1. We may need to see how many satellites there are, so select a Display Value or Labeled Value to the screen with Virtual pin and V3 configuration. Our visual should look like the following:
  1. Now we need to code for the NodeMCU. We need to include the following libraries in our code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
  1. To add these libraries, you need to download the libraries and install them to your Arduino software. To install the libraries, go to Sketch | Include Library | Add .zip Library and select the folder you can download from https://github.com/blynkkk/blynk-library/releases/download/v0.5.0/Blynk_Release_v0.5.0.zip and  https://github.com/SOFTowaha/FollowMeDrone/blob/master/TinyGPS-master.zip.
  2. After installing the libraries, let's declare some variables, as follows:
#define BLYNK_PRINT Serial //for defining the Blynk Serial
static const int RX = 4, TX = 5;
static const uint32_t GPSBaud = 9600;
  1. Form the pinout of the NodeMCU, you can see that pin 4 is actually D2 and pin 5 is D1. We declared the GPS baud rate to be 9600. If this speed does not work with your GPS, then choose a lower baud rate such as half of 9600.
  2. Now, create an object for the TinyGPS:
TinyGPSPlus mygps;
  1. Since we have added a virtual pin V0 for our map, we need to define it:
WidgetMap myMap(V0);
  1. To start communicating, we need to pass the TX and RX value to the SoftwareSerial:
SoftwareSerial test_GPS(RX, TX);
  1. The Blynk timer and the number of satellites should be declared too:
BlynkTimer timer;
float noofsats;
  1. For the authentication and the Wi-Fi connection part, add the following lines:
char auth[] = "********"; //This key can be found on your email
char ssid[] = "********"; //Your WiFi name
char pass[] = "********"; //Your WiFi Password
  1. Now, we will write our void setup() function. Inside the function, we will start our Blynk connection and check the GPS. In the void loop() function, we will display the latitude, longitude, and number of satellites in the Blynk. The full code can be found at https://github.com/SOFTowaha/FollowMeDrone/blob/master/GPS_Blynk.ino.
  1. Now, upload the code to the NodeMCU after connecting it to the computer.

You can see some information on the Serial Monitor of the Arduino software. To see the real-time data only, start the project from the Blynk application and you will see your location in the Blynk:

You can add the same technique to your Follow Me drone and control it from your Blynk application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.149.242