send commands from one ESP to another

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
reddo
New user
Posts: 7
Joined: 15 Nov 2016, 01:02
Location: The Netherlands

send commands from one ESP to another

#1 Post by reddo » 16 Feb 2017, 23:13

Evening,

I have an ESP measuring several temperatures, another in another place in the house with at the moment an LED to test and later a relay to switch an input on my heating. I can switch the led using

http://192.168.1.205/control?cmd=GPIO,2,0 or 1

from my browser so all good there. Now I want to switch this through a rule in the ESP measuring the temperatures.... I tried all variants from the tutorial http://www.letscontrolit.com/wiki/index ... rial_Rules but can't get it to work.

Any suggestions ??

Thanks !

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: send commands from one ESP to another

#2 Post by toffel969 » 16 Feb 2017, 23:21

Under advandced tab activate global sync and Set udp Port to the same value on both Devices. Then you can use the sendTo command.

Code: Select all

on RFID#Switch=1 do
sendTo 2,pulse,14,1,2000
//timerSet 1,5 //
if [Licht_TH#Lux<10]
gpio,13,1 
timerSet 2,30 
endon 
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

reddo
New user
Posts: 7
Joined: 15 Nov 2016, 01:02
Location: The Netherlands

Re: send commands from one ESP to another

#3 Post by reddo » 16 Feb 2017, 23:34

Ok, done that.

Can see the command being activated from the sending ESP ACT : sendto 243,event, vrijgave

on the receving end however, with the unit set to 243 nothing.. rule in the sender

Code: Select all

on System#Boot do
event,cvaan
endon

on  temp_vloer_uit#Temperature_3<25 do
event,cvaan
endon

on  temp_vloer_uit#Temperature_3>27 do
event,cvuit
endon

on cvaan do
sendto 243,event,vrijgave
endon

on cvuit do
sendto 243,event,blokkering
endon

and in the receiver

Code: Select all

on vrijgave do
GPIO,2,1
endon

on blokkering do
GPIO,2,0
endon

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: send commands from one ESP to another

#4 Post by paxi » 16 Feb 2017, 23:41

Unit number must be within 0-31.

I prefer SendToHTTP over sendto (TCP vs. UDP). Correct syntax is

SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,0

reddo
New user
Posts: 7
Joined: 15 Nov 2016, 01:02
Location: The Netherlands

Re: send commands from one ESP to another

#5 Post by reddo » 17 Feb 2017, 17:33

Ok, tried that, same result... nothing

I have both ESP's setup as Domoticz HTTP, ip of the Domoticz server and port 8080... so I changed the command to SendToHTTP 192.168.1.205,8080,/control?cmd=GPIO,2,0

anything wrong there ? I can see again in the log of the sender that it is sending the command aparrently but nothing the reveive ris not getting any commands in by the looks of the log.

And the global sync.. leave it on or off ? Bit lost here :(

Also tried the UDP and globalsync roure again, can see both ESP's in the node list. Again, in the sender log can see the command being generarted, receiver log... no joy....

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: send commands from one ESP to another

#6 Post by Shardan » 17 Feb 2017, 19:15

Global Sync is a bit special.

I tested it following http://www.letscontrolit.com/wiki/index ... GlobalSync
for driving a remote LCD display (Sensor on one ESP, display connected to another LCD).

It should be possible to make use of rules to switch a LED / relay from remote values.

Regards
Shardan
Regards
Shardan

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: send commands from one ESP to another

#7 Post by paxi » 17 Feb 2017, 19:26

If you address an espeasy unit directly you must use the default port for http: 80
It doesn't care what port your broker is listening on. ;)

reddo
New user
Posts: 7
Joined: 15 Nov 2016, 01:02
Location: The Netherlands

Re: send commands from one ESP to another

#8 Post by reddo » 17 Feb 2017, 19:53

Got it to work now with HTTP commandon port 80, thanks !!

Code: Select all

on System#Boot do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,1
endon

on vloer_uit#Temperature<25 do
event,cvaan
endon

on vloer_uit#Temperature>27 do
event,cvuit
endon

on cvaan do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,1
endon

on cvuit do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,0
endon
Now it keeps sending the command every cycle.. ok but... I would like to change this to somehtin like

Code: Select all

on vloer_uit#Temperature<25 do
if cvuit=1
event,cvaan
endon
and

Code: Select all

on vloer_uit#Temperature>27 do
if cvaan=1
event,cvuit
endon
to make it send only at change of temperature. Would that be possible ??

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: send commands from one ESP to another

#9 Post by toffel969 » 19 Feb 2017, 18:13

reddo wrote:Got it to work now with HTTP commandon port 80, thanks !!

Code: Select all

on System#Boot do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,1
endon

on vloer_uit#Temperature<25 do
event,cvaan
endon

on vloer_uit#Temperature>27 do
event,cvuit
endon

on cvaan do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,1
endon

on cvuit do
SendToHTTP 192.168.1.205,80,/control?cmd=GPIO,2,0
endon
Now it keeps sending the command every cycle.. ok but... I would like to change this to somehtin like

Code: Select all

on vloer_uit#Temperature<25 do
if cvuit=1
event,cvaan
endon
and

Code: Select all

on vloer_uit#Temperature>27 do
if cvaan=1
event,cvuit
endon
to make it send only at change of temperature. Would that be possible ??
Yes you can, therefore you have to store the state in a dummy device. Or use global sync to take switch state from other unit available. Don't forget to endifyour condition.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: No registered users and 133 guests