Installation
- Update OS
sudo apt update sudo apt upgrade -y
- Install Mosquitto Software
sudo apt install mosquitto mosquitto-clients -y
- Verify Service Status
This will return the status of mosquitto service.sudo systemctl status mosquitto
Testing
- Start up a Subscriber
Keep this terminal and open another terminal for next step.mosquitto_sub -h localhost -t "home/living"
- Publish a Message
mosquitto_pub -h localhost -t "home/living" -m "TURN ON: Light"
- Message on Subscriber Terminal
TURN ON: Light
Enable Remote Access
- Run the following command to open the mosquitto.conf file
sudo nano /etc/mosquitto/mosquitto.conf
- Add Below Lines
listener 1883 allow_anonymous true
- Restart Mosquitto Service
sudo systemctl restart mosquitto