Below you will find pages that utilize the taxonomy term “Iot”
MQTT with Python
The library that allows to connect and interact with an MQTT broker (mosquitto) is paho. to get it.
pip install paho-mqtt
You need to know two things before start (for now):
- MQTT broker (mosquitto) server IP and PORT
The default port of the MQTT broker is 1883
And for this test define a default Topic to communicate the clients. The Topic can also be called channel and can be defined as the conference room you enter whether to talk or to listen to it.
Install mosquitto MQTT on a raspberry
Add the repository source
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
Install the MQTT server.
sudo apt-get update
sudo apt-get install mosquitto
Validate it’s running
/etc/init.d/mosquitto status
Bonus. Run inside Docker.
Instead of installing directly in the machine, you can install it on Docker too.
Download the Docker image. This will download the “latest” version of the image.
docker pull eclipse-mosquitto
To run for the first time
docker run -it -p 1883:1883 -p 9001:9001 eclipse-mosquitto
There are two more options. Link with a configuration file and persist file storage. More on that, in the link bellow.