Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/walidabazo/nodemcu-and-gps
GPS-Tracking-System Ublox NEO-7M (GPS) and NodeMcu
https://github.com/walidabazo/nodemcu-and-gps
esp32 esp8266 esp8266-arduino gps gps-coordinates gps-data gps-location gps-tracker gps-tracking nodemcu nodemcu-esp8266 ublox ublox-gps wifi
Last synced: 15 days ago
JSON representation
GPS-Tracking-System Ublox NEO-7M (GPS) and NodeMcu
- Host: GitHub
- URL: https://github.com/walidabazo/nodemcu-and-gps
- Owner: walidabazo
- Created: 2022-07-17T21:39:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T10:53:13.000Z (over 2 years ago)
- Last Synced: 2024-11-11T12:43:58.234Z (2 months ago)
- Topics: esp32, esp8266, esp8266-arduino, gps, gps-coordinates, gps-data, gps-location, gps-tracker, gps-tracking, nodemcu, nodemcu-esp8266, ublox, ublox-gps, wifi
- Homepage:
- Size: 8.79 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NodeMcu-and-GPS
GPS-Tracking-System Ublox NEO-7M (GPS) and NodeMcu[![Watch the video](https://img.youtube.com/vi/2r4RtjqSsXw/0.jpg)](https://youtu.be/2r4RtjqSsXw)
#include // library for GPS module
#include
#includeTinyGPSPlus gps; // The TinyGPS++ object
#define rxGPS D5
#define txGPS D6
//SoftwareSerial ss(rxGPS, txGPS); // The serial connection to the GPS device
SoftwareSerial ss(rxGPS,txGPS);
const char* ssid = "Wifi Name"; //ssid of your wifi
const char* password = "Password"; //password of your wifi
float latitude , longitude;
int year , month , date, hour , minute , second;
String date_str , time_str , lat_str , lng_str;
int pm;
WiFiServer server(80);
void setup()
{
Serial.begin(115200);
ss.begin(9600);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password); //connecting to wifi
while (WiFi.status() != WL_CONNECTED)// while wifi not connected
{
delay(500);
Serial.print("."); //print "...."
}
Serial.println("");
Serial.println("WiFi connected");
server.begin();
Serial.println("Server started");
Serial.println(WiFi.localIP()); // Print the IP address
}void loop()
{
while (ss.available() > 0) //while data is available
if (gps.encode(ss.read())) //read gps data
{
if (gps.location.isValid()) //check whether gps location is valid
{
latitude = gps.location.lat();
lat_str = String(latitude , 6); // latitude location is stored in a string
longitude = gps.location.lng();
lng_str = String(longitude , 6); //longitude location is stored in a string
}
if (gps.date.isValid()) //check whether gps date is valid
{
date_str = "";
date = gps.date.day();
month = gps.date.month();
year = gps.date.year();
if (date < 10)
date_str = '0';
date_str += String(date);// values of date,month and year are stored in a string
date_str += " / ";if (month < 10)
date_str += '0';
date_str += String(month); // values of date,month and year are stored in a string
date_str += " / ";
if (year < 10)
date_str += '0';
date_str += String(year); // values of date,month and year are stored in a string
}
if (gps.time.isValid()) //check whether gps time is valid
{
time_str = "";
hour = gps.time.hour();
minute = gps.time.minute();
second = gps.time.second();
minute = (minute + 30); // converting to IST
if (minute > 59)
{
minute = minute - 60;
hour = hour + 1;
}
hour = (hour + 5) ;
if (hour > 23)
hour = hour - 24; // converting to IST
if (hour >= 12) // checking whether AM or PM
pm = 1;
else
pm = 0;
hour = hour % 12;
if (hour < 10)
time_str = '0';
time_str += String(hour); //values of hour,minute and time are stored in a string
time_str += " : ";
if (minute < 10)
time_str += '0';
time_str += String(minute); //values of hour,minute and time are stored in a string
time_str += " : ";
if (second < 10)
time_str += '0';
time_str += String(second); //values of hour,minute and time are stored in a string
if (pm == 1)
time_str += " PM ";
else
time_str += " AM ";
}
}
WiFiClient client = server.available(); // Check if a client has connected
if (!client)
{
return;
}
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n GPS DATA ";
s += "a:link {background-color: YELLOW;text-decoration: none;}";
s += "table, th, tdGPS DATA
";
s += "Location Details
Latitude";
s += "";
s += lat_str;
s += " Longitude ";
s += lng_str;
s += " Date ";
s += date_str;
s += " Time ";
s += time_str;
s += " ";
s += " ";client.print(s); // all the values are send to the webpage
delay(100);
}