Page 1 of 1
MQTT gpio switching info
Posted: 12 Feb 2016, 09:53
by ambassadoro
Hello,
there was the question how to drive a GPIO via MQTT:
Code: Select all
mosquitto_pub -d -t /esp3/GPIO/14 -m 0
The
esp3 is the subscription-topic from the advanced section of the esp-configuration webpage:
/%sysname%/#
Then the GPIO keyword and the number of the gpio that you want to switch.
-m 0 is the payload. So this sets the gpio14 to 0. -m 1 makes it high.
This example works when you are on a local mosquitto server. Otherwise it needs username and password.
Here an example for a simple blinker with a 2 relais card (relais connected via transistors to 12 & 14):
Code: Select all
while true; do
mosquitto_pub -q 1 -d -t /esp3/GPIO/14 -m "0";
mosquitto_pub -q 1 -d -t /esp3/GPIO/12 -m "1";
sleep 1;
mosquitto_pub -q 1 -d -t /esp3/GPIO/14 -m "1";
mosquitto_pub -q 1 -d -t /esp3/GPIO/12 -m "0";
sleep 1; done
When you have a real good power supply, this should run forever.
Re: MQTT gpio switching info
Posted: 12 Feb 2016, 11:29
by tozett
cool.
thanks a lot for the hint. i will try this..
maybe youve done similar with MQTT on linux and start a shell command through payload?
edit: i found this... look good to me (even python instead of bash, but on linux no prob ...)
https://github.com/jpmens/mqtt-launcher
Re: MQTT gpio switching info
Posted: 12 Feb 2016, 12:24
by ambassadoro
With the shell-command this is useful for test purpose. For more automation I am playing around with
Home Assistant. It supports mqtt very well and looks much more promising to me than fhem.
Have fun
Re: MQTT gpio switching info
Posted: 12 Feb 2016, 12:36
by tozett
i will try this:
https://home-assistant.io/components/shell_command/
and must define shell-commands to send from MQTT/Homeassistant.io with groupswrite(eibd) to KNX..
coool, thanx
edit: set up a debian8 vmware, now running homeassistant..looks promising..
Re: MQTT gpio switching info
Posted: 14 Feb 2016, 21:13
by tozett
ambassadoro wrote:... subscription-topic from the advanced section of the esp-configuration webpage: /%sysname%/#
... -m 0 is the payload. So this sets the gpio14 to 0. -m 1 makes it high.
hi,
i dont see realy clear if i can also send
PWM level to GPIOs as a payload
?
what payload-commands are possible?
same as http requests?
did not find the right place in the code,
but that must be me
a hint may help`....
edit: found something from the devs about PWM here:
http://www.esp8266.nu/forum/viewtopic.p ... 3601#p3601
Re: MQTT gpio switching info
Posted: 26 Feb 2016, 00:49
by wutu
Yes, it is possible.
I use:
esp GPIO:
<systopic>/pwm/<pin> with payload: 0-254
pca9685 GPIO
<systopic>/pcapwm/<pin> with payload: 0-4094
Re: MQTT gpio switching info
Posted: 20 Apr 2016, 12:02
by HarpieC
another question:
is there a way to send a pulse of some milliseconds to the gpio pin via MQTT too. I try to avoid http and have all communication via MQTT because it is easier to debug via MQTT spy or MQTT.fx
It's working via http:
http://<ESP IP address>/control?cmd=Pulse,<pin>,<state>,<duration>
Thank you for your support.
Chris
Re: MQTT gpio switching info
Posted: 18 Dec 2016, 09:52
by adibacco
Looking into the code or at this page
http://www.letscontrolit.com/wiki/index ... _Reference you will find that you can publish a message like
pulse,12,1,250 to topic cmd