ESP8266 softAP webserver with GPS is not working.
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Settings in IDE
- Module: Nodemcu
- Upload Using: SERIAL
- Upload Speed: 9600
### Problem Description
When I launching only ESP8266WebServer with softAP mode, it works fine.
(I could see the webpage I made.)
When I checking only gps data with TinyGPS library, it works fine.
But When I add reading gps data function to my webserver routine, it doesn't work.
``
```cpp
#include
#include
#include
#include
#include
//server setting
const char* ssid = "uuuu";
const char* password = "123456789";
ESP8266WebServer server(80);
//GPS setting
#define RXPIN 14
#define TXPIN 12
#define GPSBAUD 9600
TinyGPS gps;
SoftwareSerial ss(TXPIN, RXPIN);
float flat=0, flon=0;
String strDate = "";
void handleRoot() {
server.send(200, "text/html", prepareHtmlPage());
}
String prepareHtmlPage()
{
String htmlPage =
String("") +
"" +
"\r\n" +
"\r\n"+
"body {margin: 0;font-family: Arial, Helvetica, sans-serif;}\r\n"+
".topnav {overflow: hidden;background-color: #333;}\r\n"+
".topnav a {float: left;color: #f2f2f2;text-align: center;padding: 14px 16px;text-decoration: none;font-size: 17px;}\r\n"+
".topnav a:hover {background-color: #ddd;color: black;}\r\n"+
"\r\n"+
"
"
"\r\n"+
"function status1()\r\n"+
"{var str = '<h3>current : sss </h3>'\r\n;"+
"str += '<h3> Lat, Lon : dsd </h3>'\r\n;" +
//"{var str = '<h3>current : " + strDate + "</h3>'\r\n;"+
//"str += '<h3> Lat, Lon : " + flat + ", " + flon + "</h3>'\r\n;" +
"document.getElementById('btm').style.display='block'\r\n"+
"document.getElementById('content').innerHTML = str; }\r\n"+
"function about()\r\n"+
"{var str = '<h2>water</h2>';\r\n"+
"str += '<p> xxxx : xxxx </p>';str += '<p> HP : xxxxxx </p>';\r\n"+
"document.getElementById('btm').style.display='none'\r\n"+
"document.getElementById('content').innerHTML = str;}\r\n"+
"\r\n"+
"\r\n" +
"\r\n";
Serial.println(htmlPage);
return htmlPage;
}
void setup() {
// put your setup code here, to run once:
delay(10);
Serial.begin(115200);
//ss.begin(GPSBAUD);
Serial.println("Initializing Soft AP Config mode...");
IPAddress Ip(192, 168, 20, 1);
IPAddress NMask(255, 255, 255, 0);
WiFi.softAPConfig(Ip, Ip, NMask);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
// put your main code here, to run repeatedly:
server.handleClient();
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
//Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}
if (newData)
{
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print(" LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
}
gps.stats(&chars, &sentences, &failed);
if (chars == 0)
Serial.println("** No characters received from GPS: check wiring **");
}
```
And then.
1. I couldn't find wifi in my wifi list in laptop.
2. I could check normal GPS data.
So When I comment line below "server.handleClient();", I could find nodeMCU wifi and open
web page what I made.
I think this problem related with SoftwareSerial and handclient().
I'm not sure...
Please help me.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.