Home automation system with WeMos Mini D1, ESPDuino ESP-13, and a laptop

Good morning!

I am developing a home automation system using the following setup:

The WeMos board calls WiFi.softAP() and is responsible for creating a specific WiFi network for the controlled power outlets. This board also has a web server.

The ESPduino board (Keyestudio ESP-13 Shield) is coupled with an Arduino Uno and is responsible for toggling the power outlets. This board has a web server.

Each board gets its IP Address via WeMos board’s DHCP server.

Then I try to connect to the WeMos board and to the ESPduino board using Chrome.

The first works whereas the latter doesn’t.

I used Wireshark sniffing on the network, and the ARP packets are circulating when I try and navigate to the ESPDuino web server.

Code for the hotspots:

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

#define LCD_TIMEOUT      4000UL
#define HOTSPOT_TIMEOUT  10000L

char ssid[] = "Rainbow";
char pass[] = "myP@ssw0rd2";
int id = 1;
char name[] = "Lampada1";

ESP8266WebServer listener(80);
/*
This is the usual layout:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

The one below is when there is a ESP8266 shield
*/
//LiquidCrystal lcd(8, 9, 6, 5, 3, 2);

unsigned long lcdRefresh = 0;
unsigned long hotspotRefresh = 0;

void setup() {
  Serial.begin(115200);
  //lcd.begin(16, 2);
  //lcd.autoscroll();
  pinMode(A0, OUTPUT);
  digitalWrite(A0, LOW);

  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println(F("Where is the WiFi module? HALT"));
    //lcd.setCursor(0, 0);
    //lcd.print(F("System halted   "));
    while (true);
  }

  WiFi.disconnect();
  WiFi.begin(ssid, pass);
  
  //lcd.setCursor(0, 0);
  //lcd.print(F("Warming up      "));
  Serial.println("Warming up");
  delay(10000);

  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println(F("Could not find WiFi network! HALT"));
    while (true);
  }

  Serial.println("Connected!");

  listener.on("/", HTTP_GET, []() {
    String result = String(F("{\"state\": ")) + (digitalRead(A0) == LOW ? "off" : "on") + "\"}";
    listener.send(200, "application/json", result);
  });
  
  listener.on("/", HTTP_POST, []() {
    int state = digitalRead(A0);
    digitalWrite(A0, state = state == HIGH ? LOW : HIGH);
    String result = String(F("{\"state\": ")) + (digitalRead(A0) == LOW ? "off" : "on") + "\"}";
    listener.send(200, "application/json", result);
  });
  
  listener.begin();

  Serial.print("My IP address: ");
  Serial.println(WiFi.localIP());
  //lcd.setCursor(0, 0);
  //lcd.print(WiFi.localIP());
}

void loop() {
  listener.handleClient();
  //checkDisplay();
  //updateServer();
}

void updateServer() {
  if (millis() - hotspotRefresh > HOTSPOT_TIMEOUT || millis() < lcdRefresh) {
    hotspotRefresh = millis();
  } else {
    return;
  }

  //lcd.setCursor(0, 1);
  //lcd.print(F("Hotspot refresh!"));

  WiFiClient client;
  if (client.connect(WiFi.gatewayIP(), 80)) {
    client.print(F("PUT /hotspots/"));
    client.print(id);
    client.print(F("/"));
    client.print(name);
    client.print(F("/"));
    client.print(WiFi.localIP());
    client.println(F(" HTTP/1.1"));
    client.println(F("Connection: close"));
    client.println();
    client.stop();
  }
}

void checkDisplay() {
  if (millis() - lcdRefresh > LCD_TIMEOUT || millis() < lcdRefresh) {
    lcdRefresh = millis();
    //lcd.setCursor(0, 1);
    //lcd.print(F("                "));
  }
}