hello,
I want to change an IO-pin on an other ESP device. The devices are coupled by P2P.
I feel it should be possible, but I can't find the answer.
In more general, how to "address" another ESP in the network ?
cheers, Stef
is it possible to change a GPIO on an other ESP-device ?
Moderators: grovkillen, Stuntteam, TD-er
Re: is it possible to change a GPIO on an other ESP-device ?
There are at least 2 ways of doing that, either via the P2P network, or by http command, and when using an MQTT server, you can even use MQTT for that (somewhat depending on the MQTT server and ESPEasy-Controller used)
1) Via P2P there is the SendTo command, where you can send a command to another P2P unit (you're already having unique Unit number, right?). I'll explain about how to use a command, below.
2) Via http you can use the "http://<ip-address-of-the-remote-esp>/control?cmd=<command-with-arguments>" format.
About the command:
To avoid needing knowledge of what exact GPIO (or TaskName/TaskIndex to enable/disable/run something) on the remote device, you should better not use direct commands, but use Rules as an intermediate, so instead of sending "GPIO,12,1", you could send "event,switch=1" to turn on the Relay on a Sonoff switch.
In rules you would add:
This way you could use the same commands for all kind of ESPEasy devices, and not have to change GPIO pins on several other devices, if the hardware might be replaced, or is rather differently wired.
Another advantage is that you can do some argument checking, like I did in the example, and you can execute multiple commands with a single trigger (also in the example).
To get some inspiration on Rules, there is quite some documentation on that, including examples: https://espeasy.readthedocs.io/en/lates ... Rules.html
1) Via P2P there is the SendTo command, where you can send a command to another P2P unit (you're already having unique Unit number, right?). I'll explain about how to use a command, below.
2) Via http you can use the "http://<ip-address-of-the-remote-esp>/control?cmd=<command-with-arguments>" format.
About the command:
To avoid needing knowledge of what exact GPIO (or TaskName/TaskIndex to enable/disable/run something) on the remote device, you should better not use direct commands, but use Rules as an intermediate, so instead of sending "GPIO,12,1", you could send "event,switch=1" to turn on the Relay on a Sonoff switch.
In rules you would add:
Code: Select all
On Switch Do
If %eventvalue1|-1%>-1 // Don't respond if no argument given...
If %eventvalue1%=1
GPIO,12,1 // Relay On
LongPulse_MS,13,0,500,500,3 // Slow-Flash the green led on the Sonoff 3x to indicate (remote) action
Else
GPIO,12,0 // Relay Off
Endif
Endif
Endon
Another advantage is that you can do some argument checking, like I did in the example, and you can execute multiple commands with a single trigger (also in the example).
To get some inspiration on Rules, there is quite some documentation on that, including examples: https://espeasy.readthedocs.io/en/lates ... Rules.html
/Ton (PayPal.me)
Re: is it possible to change a GPIO on an other ESP-device ?
Ath thanks for the extended answer, Sndto worsk like a charm.
Who is online
Users browsing this forum: No registered users and 2 guests