MQTT Publish for Raspberry Pi AIY Projects

I have a lot of things in my house connected using a Raspberry Pi mosquitto broker and Node-RED so I wanted to add simple publish commands to my AIY Project.

The code is hosted at Github here: https://github.com/ktinkerer/aiyprojects-raspbian/tree/mqtt

For this you will just need to copy the action.py file to your ~voice-recognizer-raspi/src/ folder.

For it to work you need to install paho-mqtt:
sudo pip install paho-mqtt

I’ve set this up as an example to swich lights on and off so you will need to tweak it to suit your own setup.

If you are using the new version of the AIY Projects kit (from version aiyprojects-2017-09-11.img) and don’t have an action.py file then you need to use the mqtt_mod.py from my updated version (voicekit branch) copy the my_config.py file as well and fill it in with your MQTT config details.

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *