Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

IO Pi Plus & Mosquitto MQTT

The IO Pi Plus is a 32 channel MCP23017 GPIO expander for the Raspberry Pi

19/12/2017

Posted by:
PJ Bear

PJ Bear Avatar

I have been using these boards with Home assistant however wish to have more inputs than I can with 4 boards direct on to a Pi. As I use MQTT for the main parts of the house automation using Mosquitto as the broker I thought the best way forward would be to have another Pi with the boards attached and for that to read the pin and send an MQTT message to the broker where Home Assistant could be subscribed to and then react.

It would be great to do this the outher way round as well so Home Assistant could publish a MQTT messge and the Pi could then turn on the output.

So I know what I want to happen and that it can be done but I do not know how in python to program the boards and to interface with the Mosquitto python library.



Is there a great python programmer that can help me I do not think it should be very hard to achieve - if you know how to program python.



If I can get this to work it will allow endless automations and real life onteraction

20/12/2017

Posted by:
andrew

andrew Avatar

Hi Pete

I found this tutorial on using MQTT with Raspberry Pi and Python.

Sending and receiving messages with mqtt

The code in the subscriber example could be modified to work with the IO Pi library. You would need to add your code into the on_message function so it checks to see if a certain message has been received and if so it can then send the command to the IO Pi to read or write to the pins.

Sign in to post your reply


Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout