MQTT tutorial on Raspberry pi, Arduino and Python

Arduino tutorial about the MQTT communication protocol between machines m2m.

Brief overview about mqtt.

Download and install Mosquitto on a raspberry pi:
Command lines:

sudo apt-key add mosquitto-repo.gpg.key

cd /etc/apt/sources.list.d/

sudo wget

sudo -i

apt-get update

apt-get install mosquitto

link to the arduino code:

Python code is in the arduino sketch.

command line
to see all the published topics and text:
mosquitto_sub -v -t “#”
to see a specific topic like “ledStatus”:
mosquitto_sub -h -i testLED -t ledStatus //repace the ip address with your broker IP.
to publish a new message to a topic (ledStatus):
mosquitto_pub -h -t ledStatus -m “0” // replace IP with your broker IP

install the python mqtt library paho-mqtt on Raspberry pi:

pip install paho-mqtt

Link to install mosquitto on Windows:
Step by step installing and configuring Mosquitto with Windows 7



Build A Site Info