Building and Running Mosquitto* MQTT on the Intel® Edison board


One of the big features of the Intel® Edison board is that it's not just an Arduino* compatible development board but it is also a Linux* single board computer that can provide full access to the underlying Linux capabilities to an Arduino sketch.

In this series of blog entries, I will explore the various ways that Linux capability can be integrated into an Arduino sketch, and how to leverage existing code to make IoT development much simpler.

We will start with building a simple sensor node that contains a temperature sensor, light sensor, LED, and a switch. We will publish the data to the Internet using MQTT, then demonstrate some rudimentary data analytics using Node-RED* to trigger events and send command back to our sensor node.

The Linux distribution that came with the Intel® Edison board is derived from the Yocto Project*, Yocto is a small Linux kernel designed for embedded systems with limited resource.


MQTT is a light-weight protocol used for Machine to Machine (M2M) communication. MQTT uses a publish/subscribe message forwarding model built on top of the TCP/IP protocol. Central to the MQTT protocol is an MQTT server or broker that is accessible to both publishers and subscribers. Using MQTT, one can build a sensor network where various sensors can publish their sensor values in the form of a message unique to each sensor. Actuators can subscribe to different messages that they can act upon. The MQTT broker will take care of forwarding messages from publishers to subscribers.


Microcontroller A can read the state of a switch and publish the state of the switch as a message in the form "switch = on" to an MQTT server. Microcontroller B somewhere on the internet subscribes to the MQTT message "switch". Now whenever a user pushes the switch, microcontroller A will publish a message to the MQTT broker. The broker will forward the message to a list of subscribers. When microcontroller B receives the message, it can parse the content, determine the state of the switch and turn on or off a light accordingly.

More details on MQTT can be found at

The Intel® Edison board's Yocto-built OS came with a small MQTT broker called RSMB (Really Small Message broker). Unfortunately, there isn't a bundled MQTT client for the purpose of testing. In this article, we will build another MQTT broker, Mosquitto*, mostly for the clients. In subsequent articles, we will use these clients to connect to our Arduino sketches.

Building Mosquitto on the Intel® Edison board

It is assumed that readers have already set up their Intel® Edison board and are familiar with standard Linux operations.

Building Mosquitto is fairly straightforward. Here are the steps to build Mosquitto:

  1. Download Mosquitto from
    $> wget
  2. Extract the archive:
    $> tar xzf mosquitto-1.3.5
    $> cd mosquitto-1.3.5
  3. Build:
    $> make WITH_SRV=no
  4. Test and install your Mosquitto compilation:
    # Create user mosquitto
    $> add user mosquitto
    # Test 
    $> cd test/broker
    $> make test
    $> cd ../../
    # Install
    $> cp client/mosquitto_pub /usr/bin
    $> cp client/mosquitto_sub /usr/bin
    $> cp lib/ /usr/lib
    $> cp src/mosquitto /usr/bin

There is also a test target in the Mosquitto root directory. This target, however, requires Python* 3, which isn't available on the Intel® Edison board's OS and so some of the latter tests will fail. The target in test/broker does not require Python 3 and will cover all the essential MQTT operations.

Test your Mosquitto client and server

The Intel® Edison board's OS was configured to start the RSMB broker automatically. So the default TCP port 1883 is already used by RSMB. We'll test the mosquitto clients against the rsmb broker using the default MQTT port. Later on, we'll configure the Mosquitto broker to run on a different port and test that as well.

To test the client, open two ssh connections to the Intel® Edison board. In the first connection, run a mosquitto_sub client that subscribes to a topic called 'test' on the rsmb broker running locally on the Intel® Edison board.

In the second ssh connection, publish a message 'Hello World!' to the topic test on the same local server.

You should see the messages in the window running the mosquitto_sub program. Note that the mosquitto_sub client is persistent and will continue to listen to new messages from the server until it is terminated.

The above test showed that the mosquitto_sub and mosquitto_pub clients that we built are working properly with the local RSMB MQTT server.

We can run the same test using the mosquitto broker that we built running on a different port (1993).

Using the same command as above but with the -p 1993 argument with mosquitto_sub and mosquitto_pub, test the Mosquitto broker on port 1993.


We've built and ran Mosquitto server and clients on the Intel® Edison board. In subsequent postings, I will start to develop Arduino sketches that leverage the MQTT clients that we've just built.


Mosquitto documentation can be found here

Details on the Intel® Edison board can be found here:

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.
Возможность комментирования русскоязычного контента была отключена. Узнать подробнее.