I got my Raspberry Pi up and running again (read how here), and I plan to use it as a message broker for a small sensor network at home. I haven’t decided exactly what I want to do, but I will need a message broker.
First, log in to your Raspberry Pi. I use
ssh to access it:
sudo apt-get install mosquitto
Now we want make sure it work properly by subscribing to a topic and passing some messages.
Open two terminal windows, and in one of them you write:
mosquitto_sub -h 192.168.2.5 -t raspberry/test
-h is for the messagebroker host, and
-t is for the topic you want to subscribe to.
Use the other terminal window to publish a test message with:
mosquitto_pub -h 192.168.2.5 -t raspberry/test -m "First message"
The first two parameters are explained above, and the
-m parameter is for the message.
This was a short explanation for how to get started with using a raspberry pi as an MQTT message broker. You should now be able to use the message broker for whatever project your’re starting on.
Let me know what you think in the comment section below!