[Week 4 FYP2] Development of Easy Parking Finder System
Activity Title :
- Test code to enter the access point
- Study the type of class need to implement in this project
- Study the type of class need to implement in this project
Objective :
To enter the access point and make a web-page
To study the type of class used in this project.
To study the type of class used in this project.
·
Content :
i m done with working Nodemcu and sensor last week. so for this week i test a a code for creating web-page in the access point.
Code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
const char* ssid = "ssidperson"; // ssid
const char* password = "123456789";// password
//192.168.43.20
IPAddress ip(192, 168, 43, 23); //set static ip
IPAddress gateway(192, 168, 43, 1); //set getteway
IPAddress subnet(255, 255, 255, 0);//set subnet
String page = "";
double data;
ESP8266WebServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
// Connection to wireless network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
server.begin();
Serial.println("Server started");
// Print the IP address in serial monitor. It must be the same we entered above
Serial.print("Type this address in URL to connect: ");
Serial.print("http://");
Serial.println(ip);
Serial.println("/");
server.on("/", [](){
page = "<h1>Sensor to Node MCU Web Server</h1><h3>Voltage output:</h3> <h4>"+String(data)+"</h4>";
server.send(200, "text/html", page);
});
}
void loop() {
data = analogRead(A0);
delay(1000);
server.handleClient();
delay(1);
}
Code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
const char* ssid = "ssidperson"; // ssid
const char* password = "123456789";// password
//192.168.43.20
IPAddress ip(192, 168, 43, 23); //set static ip
IPAddress gateway(192, 168, 43, 1); //set getteway
IPAddress subnet(255, 255, 255, 0);//set subnet
String page = "";
double data;
ESP8266WebServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
// Connection to wireless network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
server.begin();
Serial.println("Server started");
// Print the IP address in serial monitor. It must be the same we entered above
Serial.print("Type this address in URL to connect: ");
Serial.print("http://");
Serial.println(ip);
Serial.println("/");
server.on("/", [](){
page = "<h1>Sensor to Node MCU Web Server</h1><h3>Voltage output:</h3> <h4>"+String(data)+"</h4>";
server.send(200, "text/html", page);
});
}
void loop() {
data = analogRead(A0);
delay(1000);
server.handleClient();
delay(1);
}
Result and Analysis:
As a result, the web-page is successfully create by using code in Nodemcu. i use Class C type for connect to Access point.
Conclusion:
As a
conclusion, code in Nodemcu can be compress and extract to create web-page when it power-up .

Comments
Post a Comment