How to set up your own MQTT server using Mosquitto?

I am setting up a sensor network for my new DIY home automation system and am in the main checkpoint. I use OpenHAB as the "home base" for the system, and since it has an MQTT binding, I decided that this would be a good way for all nodes to talk to it. I know that I can connect to test.mosquitto.org, which is great for testing. But, obviously, this is not safe enough for a permanent server (I am also sure that they specifically say that they do not use this server for permanent things).

After a lot of Google searches, I found a decent amount of information about Mosquitto and MQTT, but to be honest, most of them are on my head since I'm just getting started. My question here is that most seem to already be known, already known, how am I really going to set up my own MQTT server on a Raspberry Pi that will run everything? Or is this not the norm, and should I find a public server (e.g. test.mosquitto.org)? It just doesn't seem like the most practical method.

Thanks in advance for your help.

+6
source share
2 answers

Mosquitto is light enough to fit anywhere. I would use test.mosquitto.org if I tested, since it is publicly available (i.e., anyone can see your data!) And it doesn't always work and works.

When running on pi, I usually add the Mosquitto Debian repository as it is more up to date. Has v1.3.5

Good instructions on the mosquitto.org website or good beginners, like jpmens , just install to the TLS part (if you don't need it!)

+5
source

On raspberries pi

If you just run the following commands:

sudo apt-get update

sudo apt-get install mosquitto

sudo update-rc.d mosquitto defaults

(I'm not 100% sure that you need this one, but it won’t hurt)

sudo /etc/init.d/mosquitto start

(only this time is required since it should start automatically upon reboot)

This will give you a mosquito broker working on your pi

+3
source

Source: https://habr.com/ru/post/979808/


All Articles