Install Mosquitto MQTT Windows

Posted on

by

in

Install Mosquitto MQTT Windows

Introduction

This post will discuss how you can install Mosquitto MQTT broker on a windows machine. MQTT or MQ Telemetry Transport is a publish-subscribe lightweight protocol. This protocol is ideal for memory or bandwidth constraint devices like our microcontroller.

We will begin the installation process by installing the Mosquitto MQTT broker on a windows machine and then do the necessary configuration. Afterwhich, we will do the initial testing of a publish-subscribe cycle to verify the installation.

Prerequisites

You will need a workstation or laptop running Windows and with sufficient CPU power and memory. Also, make sure you have sufficient Administrator privileges so that we don’t encounter any permission issues.

Steps

  1. Download the MQTT Broker from this link. At the time of writing this post, the latest version is shown in the image below. Select if you want the 32-bit or 64-bit version.
MQTT Windows - download
  1. When the download is finished click the executable file. If a popup for user account control is shown then just click Yes. When this screen is shown click Next.
Install MQTT Windows - First Screen
  1. Click Next again on which components to install
Install MQTT Windows - Choose Components
  1. Select where you want to install it but in my case, I have set it to the default installation folder and clicked the install button.
Install MQTT Windows - Choose Install Location
  1. Once the installation is finished then open a command prompt. Right click and click the “Run as Administrator Option”
Command Prompt - Run as Administrator
  1. Change into the directory where you installed your Mosquitto broker and execute the below command to start the Mosquitto service.
net start mosquitto
net start mosquitto service

You should be able to see the following message above to be displayed.

If you go into the services then you would notice that the Mosquitto broker is now Running.

Mosquitto Broker Services

Testing our Mosquitto MQTT Broker

Now that we have successfully configured our Mosquitto MQTT Broker in our Windows environment then we will test it. To test it, we will send a publish and subscribe command on our same windows machine. This would be enough to test if our installation is successful.

Subscriber client

  • Open a command prompt and change the directory into our Mosquitto installation then type in the below command.
mosquitto_sub -t test_sensor_data -h localhost

The command above subscribes to the topic test_sensor_data. Keep this command prompt window open. This is waiting for any publisher to publish any information on that topic.

mosquitto subscribe command prompt

Publisher client

  • Open a new command prompt and change the directory into our Mosquitto folder installation. Type in the below command and click enter.
mosquitto_pub -t test_sensor_data -h localhost -m “temp:100”
command prompt mqtt publish

This publishes a message about the temperature on the topic test_sensor_data.

If you take a look now at our subscriber command prompt window then you would see that the message is displayed.

mqtt test publish-subscribe command prompt

Congratulations! We now have a functioning Mosquitto MQTT broker on our Windows machine. Yay!

How to Uninstall Mosquitto MQTT Broker in Windows?

Open a command prompt and make sure that it is running in Administrator mode.

Type in the below command to stop the Mosquitto MQTT service first.

net stop mosquitto
mosquitto mqtt stop service

Afterwhich, type in the below command to uninstall the Mosquitto

mosquitto uninstall

Delete the installation folder if it was not deleted automatically.

Wrap Up

We have successfully completed the process on how to install the Mosquitto MQTT broker on the Windows machine in this post. Also, we have run the configuration needed and then run the initial testing to verify our installation.

We are now ready to explore this awesome protocol in our IOT projects.

That’s it! Happy Exploring!

If you like my post then please consider sharing this. Thanks!

12 responses to “Install Mosquitto MQTT Windows”

  1. How to enable Websockets in Mosquitto? – donskytech.com

    […] Related Content: Install Mosquitto MQTT Windows […]

  2. Publish and Subscribe MQTT messages over WebSocket

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  3. MQTT using Node.js with practical examples – donskytech.com

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  4. How to test MQTT using MQTTX? – donskytech.com

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  5. MicroPython – MQTT Publish/Subscribe using ESP32/ESP8266

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  6. How to build your own custom MQTT dashboard?

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  7. MQTT Tutorial using Arduino Framework

    […] Content: Install Mosquitto MQTT WindowsHow to enable Websockets in Mosquitto MQTT […]

  8. Arduino MQTT Example Project – BMP/BME 280 Weather Station

    […] Content: Install Mosquitto MQTT WindowsMQTT Tutorial using Arduino […]

  9. Adafruit MQTT Library Tutorial – donskytech.com

    […] Content: Install Mosquitto MQTT WindowsPlatformIO Tutorial for Arduino […]

  10. Pico W -MicroPython MQTT – BMP/BME 280 Weather Station

    […] Content: Install Mosquitto MQTT WindowsPico W – MicroPython MQTT tutorial using umqtt.simple […]

  11. hark bachir Avatar
    hark bachir

    bien

  12. Node-Red – IoT Dashboard with Arduino – No Coding Required!

    […] Related Content: Install Mosquitto MQTT Windows […]

Leave a Reply

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