Step 1: I would load NodeMCU on you ESP8266: https://github.com/nodemcu/nodemcu-firmware
Step 2: Connect to your home router or make an ap on one of your ESP and connect them... use the api: https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en over serial connection
Step 3: write a TCP server:
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload) //This payload will be send to your arduino over soft serial
conn:send("<h1> Hello, NodeMCU!!! </h1>")
end)
conn:on("sent",function(conn) conn:close() end)
end)
Step 4: write a TCP client:
suc = false;
function sendData( host, pathData )
suc = false;
print("GoSending!");
-- A simple http client
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload)
if(string.find(payload, "200 OK")~=nil) then
suc = true;
print("AllDone")
else
suc = false;
end
end)
conn:on("connection", function(c)
print("connected");
conn:send("GET /".. pathData .." HTTP/1.1\r\nHost: ".. host .."\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
conn:on("disconnection", function()
if(suc==false) then
print("ErrorSending")
end
end)
conn:on("reconnection", function() print("reconnection") end )
conn:connect(80,host)
end
Step 5: Connect your esp boards with software serial to the arduino
Step 6: write (from board 1) to softserial to esp1: sendData( hostIP, yourData)
Step: 7 Parse the Data on sofserial read on the second arduino
Step 8: DONE!
EDIT:
Ok more infos on step 6.
If you got your script running on your esp, you can call functions by sending the function name with parameters over your serial connection.
So, this is some example code for your ardoino if you got the script from above:
SoftwareSerial wifi(3, 2); // RX, TX
//at some time in your programm
//Build up your string that will be send over serial
String i1 = "sendData(\"ipFromTheServer\", \"send.php?d=";
String i2 = i1+dataToSend;
String i3 = i2 +"\");";
wifi.println(i3);
This will call the sendData function on you esp. this will call the send.php on a Server... you can put a server up on an other esp and call it (dont have to be a php page)
More infos on step 7.
the script on top will always print all incoming data. So you just have to read serial data on wifi:
if (wifi.available())
Serial.write(wifi.read()); //this will print all inc data to your arduino console (serial) parse this data!
Info: I've build this on my own... dont know if this is best practice :)