here is the code for one esp working at 100%:
#include <ESP8266WiFi.h>
#include <Stepper.h>
IPAddress ip(192, 168, 137, 10);
IPAddress gateway(192, 168, 137, 1);
IPAddress subnet(255, 255, 255, 0);
const char* ssid = "Adalberto";
const char* password = "12345678";
int dirpin = 12; // Direction Pin
int steppin = 13; // Stepping Pin
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
// prepare GPIO12, 13
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
digitalWrite(12, 13);
// Connect to WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_AP_STA);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while (!client.available()) {
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
// Match the request
int val;
int i;
if (req.indexOf("/gpio/1/A") != -1)
val = 1;
digitalWrite(dirpin, HIGH);
delay(1000);
for (i = 0; i < 5720; i++)
digitalWrite(steppin, LOW);
delayMicroseconds(100);
digitalWrite(steppin, HIGH);
delayMicroseconds(100);
digitalWrite(dirpin, LOW);
delay(2000);
for (i = 0; i < 5720; i++)
digitalWrite(steppin, LOW);
delayMicroseconds(100);
digitalWrite(steppin, HIGH);
delayMicroseconds(100);
if (req.indexOf("/gpio/1/A") != -1)
val = 0;
else {
Serial.println("invalid request");
client.stop();
return;
}
// Set GPIO 12 and 13 according to the request
digitalWrite(12, val);
digitalWrite(13, val);
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
s += (val) ? "high" : "low";
s += "</html>\n";
// Send the response to the client
client.print(s);
delay(1);
Serial.println("Client disonnected");
}