The situation:
When hosting a wifi access point on my wemos d1 mini my phone is able to connect to it without problems. But I cannot get either of my two ESP32 units to connect to it.
The two ESP32s did work when setting them up as client and AP.
Also the ESP8266 network does show up on the ESP32 wifiscan example project:
scan start
scan done
23 networks found
1: 12345678 (-18)*
This is the code I use, goal is to use an HTTP Get to change the led state on the wemos (which works from my phone)
ESP8266 access point
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
/* Put your SSID & Password */
const char* ssid = "12345678"; // Enter SSID here
const char* password = "12345678"; //Enter Password here
/* Put IP Address details */
IPAddress local_ip(192, 168, 4, 1);
int ledPin = LED_BUILTIN;
ESP8266WebServer server(80);
bool ledState = false;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ledPin, HIGH);
WiFi.softAP(ssid, password);
delay(100);
server.on("/onled", handle_led1on);
server.onNotFound(handle_NotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
void handle_led1on() {
if (ledState) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
ledState = !ledState;
//Something to read on my phone's browser
server.send(200, "text/html", String(millis()));
}
void handle_NotFound() {
server.send(404, "text/plain", "Not found");
}
ESP32 client
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "12345678";
const char* password = "12345678";
void setup() {
Serial.begin(9600);
Serial.println("Connect to:");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println(WiFi.status());
}
Serial.println("IP:");
Serial.println(WiFi.localIP());
}
void loop() {
}
The client code above works fine when I change it to my 2.4G home network. But it doesn't want to work for the ESP8266 AP. It just keeps printing code 6 which is WL_DISCONNECTED.
Any ideas?
Update
My Robodyn ESP8266 can connect to the ESP32. Strange.