Node-red und Mosquitto für MQTT auf den Raspberry Pi installieren: https://www.youtube.com/watch?v=heyH0hgENF8

WiFi - Relais mit Node-red über MQTT schalten: https://www.youtube.com/watch?v=aHiAVTuKL7M

Node-Red installieren:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential curl npm
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Dasboard installieren:

node-red-stop
cd ~/.node-red
npm install node-red-dashboard

Mosquito installieren:

sudo apt install mosquitto mosquitto-clients
sudo systemctl enable mosquitto
sudo systemctl status mosquitto

Mosquito testen:

Subscribe im Terminal 1
mosquitto_sub -h localhost -t "test/message"
Publish im Terminal 2
mosquitto_pub -h localhost -t "test/message" -m "Hello, world"

Node-red starten: <code> node-red-start <code>

Code für ESP https://github.com/Edistechlab/Relais-per-MQTT-schalten/blob/master/MQTT_Output.ino