Guten Tag.
Der ESP sendet seine Daten auf den PC, aber nicht zum Smartphone. Dort bekomme ich einen Time out.
Ist das ein bekanntes Problem oder liegt es an meiner Blödheit?
Ich kann mich zwar auf dem ESP anmelden, aber keine Seite
Wie gesagt, am PC zeigt er mir die Seite an.
Ich verwende ein Samsung S23.
Ich glaube nicht, dass es am code liegt, aber zur Vollständigkeit:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#define bLed 2
//===============================================================
// config AP
//===============================================================
const char *ssid = "Elfmeter"; //SSID for AP
const char *password = "1234567890"; //PW for AP
String myPage;
bool ledStatus=HIGH;
IPAddress ap_local_IP(192,168,4,1); //IP for AP
IPAddress ap_gateway(192,168,4,2); //Gateway for AP
IPAddress ap_subnet(255,255,255,0); //Subnet for AP
ESP8266WebServer server(80); //open server
//===============================================================
// Function for Webserver
//===============================================================
void handleRoot(void); //root Page
void handleData(void); //send data from esp to server
//===============================================================
// Variables
//===============================================================
double counter_uebergabe = 0; //double example to send to server
int measureInterval = 8000 ; //*100 ms; //update interval for counter_uebergabe
int timer1 = 0; //counter timer for update
int counter = 1; //counter for add to counter_uebergabe
//===============================================================
// for first call go to main page
// Functions will executed when open IP in browser
//===============================================================
void handleRoot()
{
server.send(200, "text/html", myPage); //Hauptseite aufrufen
ledStatus=HIGH;
}
void AddP(String tx)
{
myPage += tx;
}
void CreateWebSite()
{
myPage="";
AddP("<!DOCTYPE html>\n");
AddP("<html>");
AddP("<head>");
AddP("<title>ESP8266</title>");
AddP("<style>");
AddP("</style>");
AddP("</head>");
AddP("<body>");
AddP("<a>Lassst mich zurueck</a>");
if(ledStatus)
{
AddP("<button onclick=\"location.href='/medOn'\" type=\"button\">\n");
AddP("Mach das Licht an</button>");
}
else
{
AddP("<button onclick=\"location.href='/medOff'\" type=\"button\">\n");
AddP("ausschalten</button>");
}
AddP("</body>");
AddP("</html>");
}
//===============================================================
// send data to webserver via json
//===============================================================
void handleData(){
}
//===============================================================
// Accesspoint start
//===============================================================
void setupAP(void) {
delay(100);
WiFi.mode(WIFI_STA); //wifi mode
WiFi.disconnect(); //if connected send disconnect
delay(1000);
Serial.println("Setting soft-AP ... ");
WiFi.softAPConfig(ap_local_IP, ap_gateway, ap_subnet); //config AP
WiFi.softAP(ssid, password); //start AP
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP()); //print IP from AP
server.on("/", handleRoot);
server.on("/medOn", handleLedOff);
server.on("/medOff", handleLedOn);
//here you can add more pagees
server.begin();
Serial.println("Server started");
}
void handleLedOff()
{
digitalWrite(bLed,LOW);
Serial.println("Kommando Aus");
ledStatus=false;
CreateWebSite();
server.send(200, "text/html", myPage); //Hauptseite aufrufen
myPage="";
}
void handleLedOn()
{
Serial.println("Kommando Ein");
digitalWrite(bLed,HIGH);
ledStatus=true;
CreateWebSite();
server.send(200, "text/html", myPage); //Hauptseite aufrufen
myPage="";
}
void setup()
{
delay(1000);
Serial.begin(115200);
pinMode(bLed,OUTPUT);
setupAP();
delay(500);
CreateWebSite();
server.begin();
}
void loop()
{
server.handleClient(); // check for HTTP-Request
delay(100);
}