How to switch GPIO output using MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

How to switch GPIO output using MQTT

#1 Post by Affinite » 01 Apr 2020, 16:19

Sorry this will be a dumb newbie question for the experts but I cant see how to control ESP8266 NodeMCU GPIO pins on/off using MQTT over the internet

Im Running ESPEasy Mega and publishing and subscribing through a public MQTT broker (Hive)
FWIW - I can turn the GPIO pins/on off with a local Http command
Connectivity is OK, To confirm, I can see the ESP WiFi strength over MQTT using MQTTlens

Can someone share some example configs/settings to get me on track ?

Thanks

seb82
Normal user
Posts: 62
Joined: 05 Sep 2018, 10:56

Re: How to switch GPIO output using MQTT

#2 Post by seb82 » 01 Apr 2020, 18:48

When defining the MQTT controller, there is the setting "Controller Subscribe" which most likely is set to %sysname%/#

%sysname% is "Unit Name" in config tab.

To send an MQTT command, you need to send it to %sysname%/cmd. Command is the same as with http.

For example, I have an esp named esp230. To switch gpio 5 to 1, I publish gpio,5,1 on esp230/cmd.

In the config tab, you may also want to uncheck "Append Unit Number to hostname" as it modifiers %sysname% (or change accordingly).
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to switch GPIO output using MQTT

#3 Post by Affinite » 01 Apr 2020, 19:02

Thanks - that worked first time.
I didnt find the "Append Unit Number to hostname" checkbox but it seemed to work ok anyway

I really appreciate your help. :P

Post Reply

Who is online

Users browsing this forum: No registered users and 97 guests