MQTT command to communicate between esp units

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Patou
Normal user
Posts: 106
Joined: 21 May 2018, 10:33

MQTT command to communicate between esp units

#1 Post by Patou » 13 Sep 2019, 18:46

Hello Friends,
Up to now I have used UDP to communicate between ESP units.
Looking at the forum it seems that using MQTT is a better solution.
I have a MQTT broker on NAS and I check it ... it works

I found examples to communicate with Domoticz : like : Publish domoticz/in,{"command": "switchlight", "idx": 96, "switchcmd": "Off" }
But not really to communicate between ESP units.
I should like to have example to communicate a value from one Esp to another.
I supposed we can used event and event value but what should be the message ?

On ESP1 ( the sender)
On Temp#°C do
Let,1,[Temp#°C]
Publish ??? // I want to send this temp to ESP2
Endon

On ESP2 ( the receiver)
What do I need to write ?

Can somebody help me ?
Thanks in advance
Patou

dirk_k
Normal user
Posts: 19
Joined: 19 Aug 2017, 22:41

Re: MQTT command to communicate between esp units

#2 Post by dirk_k » 15 Sep 2019, 21:50

I use mqtt to communicate with my fhem server.
... and the ESP talks to itself to check MQTT communication.

i send the uptime from rules using:
Publish fhem/sensors/sonoff_S20_01/in/UPTIME,%uptime%

i receive using a "Generic - MQTT Import" device named "MQTT-IN"
MQTT Topic 1: fhem/sensors/sonoff_S20_01/in/UPTIME
named: uptimePong

Controller is configured as "openHAB MQTT"
Subscribe: fhem/sensors/%sysname%/#
publish: fhem/sensors/%sysname%/in/%valname%

now i can use the result within rules:
on UPTIME#UPTIME do //will run every 1 minutes
TaskValueSet 6,1,[UPTIME#UPTIME]-[MQTT-IN#uptimePong]
if [Dummy#Watchdog] > 60
reboot
endif
endon

Patou
Normal user
Posts: 106
Joined: 21 May 2018, 10:33

Re: MQTT command to communicate between esp units

#3 Post by Patou » 18 Sep 2019, 00:30

Thanks for your answer
I will try this way and look at some other post.
Patou

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests