Install an MQTT broker on your Raspberry Pi

Not only for home automation purposes, a central MQTT broker can be a good system that connects sensors and control applications. MQTT has been designed especially to be very lightweight. Therefore, it will also work very well on a Raspberry Pi. Installing it is very simple:
sudo apt-get install -y mosquitto mosquitto-clients

Your Mosquitto server should be already running now. You can test this easily.
mosquitto_sub -h localhost -v -t test

This starts a MQTT subscriber waiting for incmoming messages on the “test” channel.

Now open a new connection to your Raspberry Pi and type the following:
mosquitto_pub -h localhost -t test -m "Hello world, Mosquitto"

The first process should now display the “Hello world” message.

One thought on “Install an MQTT broker on your Raspberry Pi”

  1. Halleluja. Mosquitto und seine Clients sind mittlerweile getrennte apt-Pakete. Dieser Hinweis fehlt momentan so ziemlich jedem andern Tutorial. Danke daf├╝r!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.