This is the code for GPS module using Nodemcu Esp8266 (Access Point)
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
const char* host = "GPS_NodeMCU";
const char* ssid = "GPS_BOT";
String latitude, longitude;
#define RXPIN 4
#define TXPIN 5
SoftwareSerial ss(RXPIN, TXPIN); // The serial connection to the GPS device
ESP8266WebServer server(80);
TinyGPSPlus gps;
void setup() {
Serial.begin(115200);
// Connecting WiFi
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid);
// Starting WEB-server
server.on ( "/", HTTP_handleRoot );
server.onNotFound ( HTTP_handleRoot );
server.begin();
}
void loop() {
server.handleClient();
delay(50);
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
latitude = "Latitude = " +(gps.location.lat(), 6);
longitude = "Longitude = " +(gps.location.lng(), 6);
}
}
}
void HTTP_handleRoot(void) {
server.send(200, "text/plain", latitude + "," + longitude);
if( server.hasArg("State") ){
Serial.println(server.arg("State"));
}
server.send(200,"text/html","" );
}
But my output is
How to get the value of latitude and longitude using a GPS module and display to the web. But in my case I can’t display the value. What I did wrong in my code?