there was the question how to drive a GPIO via MQTT:
Code: Select all
mosquitto_pub -d -t /esp3/GPIO/14 -m 0
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