Raspberry Pi GPIO to MQTT Hardware and installation advice

Been trying for a while to get to grips with, but just can’t get it to fire the relays

https://github.com/flyte/pi-mqtt-gpio

is anyone aware of a step by step installation guide I’m not sure i’m completing the installation process correctly.

Is anyone able to confirm if the relay boards I’m using are the correct ones ? to run from a pi gpio, Ive powered the board from a separate 5v supply and attached the pins to the relevant pi gpios, but it just doesn’t work… if i short the supply 5 v to any of the trigger inputs i hear the relays click no problem… does the Raspberry pi gpio give out 5v dc as an ON signal ?

https://www.aliexpress.com/item/High-Low-level-trigger-8-channel-relay-control-panel-PLC-relay-5V-module-for-arduino-hot/32744028214.html?spm=a2g0s.9042311.0.0.27424c4dWZw2lM

I followed the “serving suggestion” and installed it in a ve. Works well. Check your logs at:

/var/log/pi-mqtt-gpio.log

for errors.

No it does not. It uses 3.3v logic.

Ok so I’ve got round to having a good play and I’ve got it working… sort off, the problem appears to be more home assistant end. when i press the switch within home assistant to turn ‘ON’ a message is published to gpio2mqtt and the relay turns on but then the problem is that shortly after the switch in home assistant is turned on it bounces back to the off position ( This isn’t published to MQTT ) if I’m quick i can press it on and then press off again before it bounces back and an ‘OFF’ command is published to gpio2mqtt and works no problem turning the relay off.

Ive used an example from off the forum just whilst I’m testing

  • platform: mqtt
    name: “Switch 1”
    state_topic: “pibox/switch/output/1/state”
    command_topic: “pibox/switch/output/1/set”
    payload_on: “ON”
    payload_off: “OFF”
    state_on: “ON”
    state_off: “OFF”
    optimistic: false
    qos: 0
    retain: true

and then the yams for gpio2mqtt

mqtt:
host: localhost
port: 1883
user: “”
password: “”
topic_prefix: pibox/switch

gpio_modules:

  • name: raspberrypi
    module: raspberrypi

digital_outputs:

  • name: ‘1’
    module: raspberrypi
    pin: 17
    on_payload: “ON”
    off_payload: “OFF”
  • name: ‘2’
    module: raspberrypi
    pin: 4
    on_payload: “ON”
    off_payload: “OFF”

Got it working here’s a copy of home assistant config, error was in the state_topic line

  - platform: mqtt
    name: "MQTT2GPIO 1"
    state_topic: "pibox/switch/output/1"
    command_topic: "pibox/switch/output/1/set"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true

I would like to install the HA in a Intel Nuc computer and use a remote Raspberry pi with some GPIO expander boards to control all the house inputs and outputs.

I read:
https://github.com/flyte/pi-mqtt-gpio

I don’t know how to start. In the pi-mqtt-gpio I saw that is prepared to work with GPIO expanders. There is an example of that.

Can someone explain, step by step, how to install that in the remote pi? And how to prepare HA?

I can start installing the raspbian, right? And after that?

Install Raspian on your Pi in the usual way then follow this: https://github.com/flyte/pi-mqtt-gpio#serving-suggestion

Will do. Thank you.

And It’s needed to install mosquitto?

Yes, indeed, but not on the pi.

Ok. Thanks.