Code for the Access-point
Code: Select all
#include <WiFi.h>
const char* ssid = "ESP32-Access-Point";
const char* password = "SyedAhmedAli";
WiFiServer server(80);
void setup() {
Serial.begin(115200);
Serial.println("Setting AP (Access Point)…");
WiFi.softAP(ssid, password);
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(IP);
Serial.print("MAC address: ");
Serial.println(WiFi.softAPmacAddress());
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
if (client)
{ Serial.println("New Client.");
while (client.connected())
{
Serial.println(client.connected());
Serial.println("Client connected.");
Serial.println("");
}
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}[/Codebox][/Codebox]
Code: Select all
#include <WiFi.h>
#include <SPI.h>
const char* ssid = "ESP32-Access-Point";
const char* password = "SyedAhmedAli";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
scanNetworks();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
}
void loop() {
}
void scanNetworks() {
// scan for nearby networks:
Serial.println("** Scan Networks **");
byte numSsid = WiFi.scanNetworks();
// print the list of networks seen:
Serial.print("SSID List:");
Serial.println(numSsid);
// print the network number and name for each network found:
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
Serial.print(thisNet);
Serial.print(") Network: ");
Serial.println(WiFi.SSID(thisNet));
}
}