ESP to ESP communication
Posted: Wed Dec 23, 2015 7:28 pm
For this example I used to node mcu boards.
The button that is connected to the gpio 0 is used to control the on board led on the other unit.
There is a bit of a delay between holding down the button and the light turning on or off.
The controller code
You must change the ip address of the receiving unit for your environment.
Receiver unit code:
The button that is connected to the gpio 0 is used to control the on board led on the other unit.
There is a bit of a delay between holding down the button and the light turning on or off.
The controller code
You must change the ip address of the receiving unit for your environment.
Code: Select all
timer 5000 [check]
wait
[check]
serialprintln io(pi,0)
if io(pi,0) = 1 then io(po,d4,0)
if io(pi,0) = 0 then io(po,d4,1)
if io(pi,0) = 1 then wget("172.16.0.112/msg?stat=0")
if io(pi,0) = 0 then wget("172.16.0.112/msg?stat=1")
wait
Receiver unit code:
Code: Select all
memclear
msgbranch [doit]
wait
[doit]
msgget stat s
io(po,d4,s)
msgreturn s
wait