Installation of MQTT Server on Raspberry PI

Installation

  1. Update OS
    sudo apt update
    sudo apt upgrade -y
  2. Install Mosquitto Software
    sudo apt install mosquitto mosquitto-clients -y
  3. Verify Service Status
    sudo systemctl status mosquitto
    This will return the status of mosquitto service.

Testing

  1. Start up a Subscriber
    mosquitto_sub -h localhost -t "home/living"
    Keep this terminal and open another terminal for next step.

  2. Publish a Message
    mosquitto_pub -h localhost -t "home/living" -m "TURN ON: Light"
  3. Message on Subscriber Terminal
    TURN ON: Light

Enable Remote Access

  1. Run the following command to open the mosquitto.conf file
    sudo nano /etc/mosquitto/mosquitto.conf
  2. Add Below Lines
    listener 1883
    
    allow_anonymous true
    
  3. Restart Mosquitto Service
    sudo systemctl restart mosquitto

Leave a Comment

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