top of page
Writer's pictureRamesh G

Web Server Based GPS Neo-6M

Updated: Jul 2, 2021

This tutorial, we will explore how to read GPS location data in simple local web server is created using NodeMCU and the location details are updated in that server webpage.


In this Current location in Goolge Maps by clicking on the link provided in the Local web page. GPS stands for Global Positioning System and it is used to find out location, altitude, speed, date and time in UTC.


GPS module takes some time to capture location details once it is powered on. NodeMCU starts webserver and waits for a client to get connected to the webserver. Once client is connected to the webserver, NodeMCU sends location details to connected client. The location details are displayed in a simple webpage designed using HTML.


Circuit Diagram:



Components Required:

  • NodeMCU ESP12

  • GPS6MV2 module (Neo 6M, u-bloxAG)

GPS Neo 6M

This is a complete GPS module that is based on the Ublox NEO 6M GPS. This unit uses the latest technology from Ublox to give the best possible positioning information and includes a larger built-in 25 x 25mm active GPS antenna with a UART TTL socket. A battery is also included so that you can obtain a GPS lock faster. This is an updated GPS module that can be used with ardupilot mega v2. This GPS module gives the best possible position information, allowing for better performance with your Ardupilot or other Multirotor control platform.

The Ublox GPS module has serial TTL output, it has four pins: TX, RX, VCC, and GND. You can download the u-centre software for configuring the GPS and changing the settings and much more. It is really good software (see link below).



Features:

  • 5Hz position update rate

  • Operating temperature range: -40 TO 85°CUART TTL socket

  • EEPROM to save configuration settings

  • Rechargeable battery for Backup

  • The cold start time of 38 s and Hot start time of 1 s

  • Supply voltage: 3.3 V

  • Configurable from 4800 Baud to 115200 Baud rates. (default 9600)

  • SuperSense ® Indoor GPS: -162 dBm tracking sensitivity

  • Support SBAS (WAAS, EGNOS, MSAS, GAGAN)

  • Separated 18X18mm GPS antenna


Getting Location Data from GPS:

The Module will transmit data in multiple strings at 9600 Baud Rate. If we use an UART terminal with 9600 Baud rate, we will see the data received by GPS.

GPS module sends the Real time tracking position data in NMEA format. NMEA format consist several sentences, in which four important sentences are given below. More detail about the NMEA sentence and its data format can be found here.

  • $GPGGA: Global Positioning System Fix Data

  • $GPGSV: GPS satellites in view

  • $GPGSA: GPS DOP and active satellites

  • $GPRMC: Recommended minimum specific GPS/Transit data

This is the data received by GPS when connected on 9600 baud rate.


Installing the ESP8266_Arduino_Library

Tiny GPS++ library : Download

In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.

After installing the required libraries, copy the following code to your Arduino IDE.

Subscribe and Download code.


Arduino Code


#include <TinyGPS++.h>

#include <SoftwareSerial.h>

#include <ESP8266WiFi.h>


TinyGPSPlus gps; // The TinyGPS++ object


//SoftwareSerial ss(4, 5); // WO LCD OK, GPS (TX,RX) to ESP8266 12E (D2,D1)The serial connection to the GPS device

// BOTH SERIAL WORKING FINE

SoftwareSerial ss(14, 12); //WITH LCD THIS OK GPS (TX,RX) to ESP8266 12E (D5,D6)The serial connection to the GPS device


//Replace with your network credentials

char ssid[] = "TP-Link_3200"; // yOUR ssid

char password[]="9500112137"; //yOUE wifI PASSWORD


float latitude , longitude;

int year , month , date, hour , minute , second;

String date_str , time_str , lat_str , lng_str;

int pm;


#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);



WiFiServer server(80);

void setup()

{

Serial.begin(115200);

ss.begin(9600);

lcd.init(); // initialize the lcd

// Print a message to the LCD.

lcd.backlight();

Serial.println();

Serial.print("Connecting to ");

Serial.println(ssid);


WiFi.begin(ssid, password);


while (WiFi.status() != WL_CONNECTED)

{

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println("WiFi connected");

lcd.setCursor(0,0);

lcd.print("WiFi connected");

server.begin();

Serial.println("Server started");


// Print the IP address

Serial.println(WiFi.localIP());

lcd.setCursor(0,1);

lcd.print(WiFi.localIP());

delay(5000);

lcd.clear();


}


void loop()

{


while (ss.available() > 0)

if (gps.encode(ss.read()))

{

if (gps.location.isValid())

{

latitude = gps.location.lat();

lat_str = String(latitude , 6);

longitude = gps.location.lng();

lng_str = String(longitude , 6);

}


if (gps.date.isValid())

{

date_str = "";

date = gps.date.day();

month = gps.date.month();

year = gps.date.year();


if (date < 10)

date_str = '0';

date_str += String(date);


date_str += " / ";


if (month < 10)

date_str += '0';

date_str += String(month);


date_str += " / ";


if (year < 10)

date_str += '0';

date_str += String(year);

}


if (gps.time.isValid())

{

time_str = "";

hour = gps.time.hour();

minute = gps.time.minute();

second = gps.time.second();


minute = (minute + 30);

if (minute > 59)

{

minute = minute - 60;

hour = hour + 1;

}

hour = (hour + 5) ;

if (hour > 23)

hour = hour - 24;


if (hour >= 12)

pm = 1;

else

pm = 0;


hour = hour % 12;


if (hour < 10)

time_str = '0';

time_str += String(hour);


time_str += " : ";


if (minute < 10)

time_str += '0';

time_str += String(minute);


time_str += " : ";


if (second < 10)

time_str += '0';

time_str += String(second);


if (pm == 1)

time_str += " PM ";

else

time_str += " AM ";


}


}

lcd.setCursor(0,0);

lcd.print("Latitude:");

lcd.print(gps.location.lat());

lcd.setCursor(0,1);

lcd.print("Longitude:");

lcd.print(longitude = gps.location.lng());

// Check if a client has connected

WiFiClient client = server.available();

if (!client)

{

return;

}


// Prepare the response

String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n <!DOCTYPE html> <html> <head> <title>GPS Node</title> <style>";

s += "a:link {text-decoration: none;}";

s += "table, th, td {border: 1px orange;} </style> </head> <body> <h1 style=";

s += "color:BLUE;font-size:300%;";

s += " ALIGN=CENTER> ESP8266 12E based GPS Location Finder</h1>";

s += "<p ALIGN=CENTER style=""color:BLUE;font-size:150%;""";

s += "> <b>Location Details</b></p> <table ALIGN=CENTER style=";

s += "width:50%";

s += "> <tr> <th>Latitude</th>";

s += "<td ALIGN=CENTER >";

s += lat_str;

s += "</td> </tr> <tr> <th>Longitude</th> <td ALIGN=CENTER >";

s += lng_str;

s += "</td> </tr> <tr> <th>Date</th> <td ALIGN=CENTER >";

s += date_str;

s += "</td></tr> <tr> <th>Time</th> <td ALIGN=CENTER >";

s += time_str;

s += "</td> </tr> </table> ";

if (gps.location.isValid())

{

s += "<p align=center><a style=""color:RED;font-size:125%;"" href=""http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=";

s += lat_str;

s += "+";

s += lng_str;

s += """ target=""_top"">Click here!</a> To Open Current Location in Google maps.</p>";

}


s += "</body> </html> \n";

client.print(s);

delay(100);


}



After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the ESP8266 board. Now it should print its IP address




109 views0 comments

Comentarios


bottom of page