#include <WiFi.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* apSsid = "TheCaptsWIFI";
const char* apPassword = "thesaltydog24";
void setup() {
delay(1000); // Add a delay to allow ESP8266 to initialize
Serial.begin(74880);
// Connect to the main Wi-Fi network using DHCP
Serial.println("Connecting to WiFi network...");
WiFi.begin(ssid, password);
// Wait for connection to be established
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
// Connected to the Wi-Fi network
Serial.println("Connected to WiFi network");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
// Create the Wi-Fi access point with the specified credentials
WiFi.softAP(apSsid, apPassword);
Serial.println("Created WiFi Access Point");
// Add an intermediate print statement to check if softAPgetStationNum() is causing issues
int numClients = WiFi.softAPgetStationNum();
Serial.print("Number of clients connected: ");
Serial.println(numClients);
}
void loop() {
// Add a delay before entering the loop
delay(1000);
}