How to communicate between two esp8266
Moderators: grovkillen, Stuntteam, TD-er
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
How to communicate between two esp8266
Hello World (represents my coding skills ),
I use a bunch of ESPs with MQTT OpenHAB Controller to my IPSymcon Housautomating System.
All works great !
Now i have special needs:
I have one ESP with 2 Buttons connected to an MCP23017
and another ESP with 2 relais connected also to an MCP23017
i would love to push button1 on ESP1 and send it to ESP2 to toggle relais1 (one button push = relais on, next button push = relais off)
same for button2.
Both ESPs are in the same Wifi.
So do i need to set an second cotroller for this need or is there a simple solution ?
Thank you so much for your help an i hope you are all OK in these days
Sascha
I use a bunch of ESPs with MQTT OpenHAB Controller to my IPSymcon Housautomating System.
All works great !
Now i have special needs:
I have one ESP with 2 Buttons connected to an MCP23017
and another ESP with 2 relais connected also to an MCP23017
i would love to push button1 on ESP1 and send it to ESP2 to toggle relais1 (one button push = relais on, next button push = relais off)
same for button2.
Both ESPs are in the same Wifi.
So do i need to set an second cotroller for this need or is there a simple solution ?
Thank you so much for your help an i hope you are all OK in these days
Sascha
"the flat earth society has members all around the globe"
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: How to communicate between two esp8266
Since you already have the MQTT broker up and running, why not use it? You can send commands over MQTT. I'd use event calls to the recipient side (relay unit).
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
Re: How to communicate between two esp8266
Thank you for your help
so far i did try a lot but could not get it to work.
i was reading the "rules tutorial" aswell.
Ist it all possible only by using rules ? (MQTT Controller is set)
I did try this:
ESP1 with buttons:
ESP2 with relay:
So probably i do a lot wrong here ?
Thanks for help!
Sascha
so far i did try a lot but could not get it to work.
i was reading the "rules tutorial" aswell.
Ist it all possible only by using rules ? (MQTT Controller is set)
I did try this:
ESP1 with buttons:
Code: Select all
on System#Boot do
monitor,mcp,1
endon
on mcp#1=1 do
Publish,"LichtgrHalleVorne","1"
endon
Code: Select all
on LichtgrHalleVorne=1 do
mcpgpio,1,0
endon
Thanks for help!
Sascha
"the flat earth society has members all around the globe"
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
Re: How to communicate between two esp8266
ok, i got it to work
i used an MQTT generic input in "devices"
and the rule looks like:
so this provides the toggle feature i was looking for.
YAY
i used an MQTT generic input in "devices"
and the rule looks like:
Code: Select all
on MQTT_INPUT#LichtgrHalleVorne=1 do
if [plugin#mcpgpio#pinstate#1]=1
mcpgpio,1,0
else
mcpgpio,1,1
endon
YAY
"the flat earth society has members all around the globe"
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: How to communicate between two esp8266
Yes that is probably the most generic way. It's also possible to post to the cmd topic of that particular unit. But using MQTT import you can have any number of units listen to any topic.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: How to communicate between two esp8266
Unless you do not want to involve MQTT and enable the ESPEasy P2P Networking. You will have 2 units 1 and 2
Unit 2 :
Unit 1:
here:
https://www.letscontrolit.com/wiki/inde ... nd_Publish
-D
Unit 2 :
Code: Select all
on System#Boot do
monitor,mcp,1
endon
on mcp#1=1 do
sendTo,1,LichtgrHalleVorne,1
endon
Unit 1:
Code: Select all
on LichtgrHalleVorne=1 do
mcpgpio,1,0
endon
https://www.letscontrolit.com/wiki/inde ... nd_Publish
-D
-D
Re: How to communicate between two esp8266
I do have tp correct a little bit. Beside the fact that the syntax is wrong for current mega release (I don't know which release iron runs), I don't know exactly since when, but in the current version of ESPEasy Mega you may not use SendTo not like this:
to get the desired result
refer to: https://github.com/letscontrolit/ESPEasy/issues/2724
But instead you have to use
Code: Select all
SendTo 1,'event,LichtgrHalleVorne=1'
refer to: https://github.com/letscontrolit/ESPEasy/issues/2724
Code: Select all
pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
Re: How to communicate between two esp8266
ok, thanks a lot for all the answeres
no i try something simular which is not working at the moment.
i use an PCA9685 to have some PWM outputs.
i changed the range in plugins from 0 - 4096 to 0 -100 which is enough for my needs.
now i have an MQTT_INPUT plugin where the topic is "Dimmer" and the value i called "Dimmer1"
i am not sure about the sytax now ?
this is not working:
at least
seems to be ok as trigger but my PWM signal goes down to "0" always.
so somehow i can not send the value "Dimmer1" which is from 0 - 100
Thank you for your help
no i try something simular which is not working at the moment.
i use an PCA9685 to have some PWM outputs.
i changed the range in plugins from 0 - 4096 to 0 -100 which is enough for my needs.
now i have an MQTT_INPUT plugin where the topic is "Dimmer" and the value i called "Dimmer1"
i am not sure about the sytax now ?
this is not working:
Code: Select all
on MQTT_INPUT#Dimmer1 do
PCAPWM,0,[plugin#MQTT_INPUT#Dimmer#Dimmer1]
Code: Select all
on MQTT_INPUT#Dimmer1 do
so somehow i can not send the value "Dimmer1" which is from 0 - 100
Thank you for your help
"the flat earth society has members all around the globe"
- Sasch600xt
- Normal user
- Posts: 164
- Joined: 10 Sep 2018, 16:37
Re: How to communicate between two esp8266
got it !
this was the right syntax:
this was the right syntax:
Code: Select all
on MQTT_INPUT#Dimmer1 do
PCAPWM,0,[MQTT_INPUT#Dimmer1]
"the flat earth society has members all around the globe"
-
- New user
- Posts: 6
- Joined: 07 Jun 2020, 11:38
Re: How to communicate between two esp8266
Hi,
There is another possibility to communicate between two esp devices.
You can use the rule command
sendto
Example: you have 2 espdevices dev1 (unit:1) and dev2 (unit:2). They can also have the same name , but the Unit Number must be different -> unit=1 and unit=2. The UDP communication is done through the unit numbers
Add a controller ESPEasy P2P Networking on both devices
in rules on dev1:
senfto command to the unit number
in rules on dev2:
Hope that helped
regards Chris
There is another possibility to communicate between two esp devices.
You can use the rule command
sendto
Example: you have 2 espdevices dev1 (unit:1) and dev2 (unit:2). They can also have the same name , but the Unit Number must be different -> unit=1 and unit=2. The UDP communication is done through the unit numbers
Add a controller ESPEasy P2P Networking on both devices
in rules on dev1:
Code: Select all
on Button#State do
sendto 2, "event,Button1=1"
endon
in rules on dev2:
Code: Select all
on Button1 do
// do something on dev2 when button1 was pressed on dev1
// use this to retrieve the event value from the dev1 -> %eventvalue%
endon
regards Chris
Last edited by besterquester on 07 Jun 2020, 13:53, edited 1 time in total.
Re: How to communicate between two esp8266
I guess you meantbesterquester wrote: ↑07 Jun 2020, 12:21 [...]
in rules on dev1:
[...]Code: Select all
on Button#State do sendto 1, "event,Button1=1" endon
Code: Select all
sendto 2,....
-
- New user
- Posts: 6
- Joined: 07 Jun 2020, 11:38
Re: How to communicate between two esp8266
yes of course.
thx!!
thx!!
Re: How to communicate between two esp8266
Hello,
I'd like to change the IP of an existing device with node 14. It is listet at the device with node 16.
Normally the code "SendTo 14, IP XXX.XXX.X.XXX" should work? Although i get an "Ok" as response, the IP has not been changed.
Has anybody an idea or could give some advice?
Thanks in Advance.
I'd like to change the IP of an existing device with node 14. It is listet at the device with node 16.
Normally the code "SendTo 14, IP XXX.XXX.X.XXX" should work? Although i get an "Ok" as response, the IP has not been changed.
Has anybody an idea or could give some advice?
Thanks in Advance.
Re: How to communicate between two esp8266
Maybe you should use quotes and also call for "save" + reboot that node.
Code: Select all
SendTo 14,"IP XXX.XXX.X.XXX"
Re: How to communicate between two esp8266
Thanks for your help.
Who is online
Users browsing this forum: No registered users and 61 guests