So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By hortplus
#73657 I'm using this script:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "LIDAR";
const char *password = "";

ESP8266WebServer server(80);

/* Just a little test message. Go to http://192.168.4.1 in a web browser
* connected to this access point to see it.
*/
void handleRoot() {

int size=1000;
char temp[size];

int sec = millis() / 1000;
int min = sec / 60;
int hr = min / 60;

snprintf ( temp, size,

"<html>\
<head>\
<title>MicroCloud</title>\
<style>\
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; font-size: 24pt; }\
</style>\
</head>\
<body>\
<h3>You are connected on MicroCloud #2!</h3>\
<p>Uptime: %02d:%02d:%02d</p>\
<form action='http://192.168.4.1' method='get'>\
F_name: <input type='text' name='fname'><br>\
<input type='submit' value='Submit'>\
</body>\
</html>",

hr, min % 60, sec % 60
);
server.send ( 200, "text/html", temp );

}


void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP_STA);
WiFi.softAP(ssid);

IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}

void loop() {
server.handleClient();
}

But I'm finding it unreliable. Sometimes you can connect with my phone and sometimes you can't. I change the phone WiFi to Lidar first.