MQTT and Intel Edison - Intro

4.1K152

Intro: MQTT and Intel Edison - Intro

Hi there!
Today I write about MQTT and Edison. MQTT (Message Queue Telemetry Transport) consists in a M2M (Machine to Machine) communication protocol used for reporting events to another machines around the Internet (or in a local network). According to its architecture, it´s possible to have only one publisher and a lot (no limit reported) of subscribers.

One of the greatest highlights of this protocol is that MQTT is a lightweight messaging protocol (in processing, memory use and bandwhich), what makes it perfect for mobile devices and embbeded devices. For more details, please access this website: http://mqtt.org/

Here in this example I´ll show how to make Intel Edison writes on a LCD a message received from MQTT

STEP 1: Setting Up Intel Edison for MQTT

Before setting up Edison for MQTT, please make sure your Intel Edison is up-to-date, and that pip is correctly installed and that there´s a repository configured.

To setting up Intel Edison, please follow these instructions:

- Get Mosquitto library for python typing this at console:
pip install paho-mqtt

Now, if everything is ok, you´re ready for make it real!

STEP 2: Sending/receiving Messages

In this instructable, Intel Edison will work as a subscriber and a ready-2-go publisher will be used for sending messages to Intel Edison.

I used this online publisher(MQTTLens): https://chrome.google.com/webstore/detail/mqttlens...

It is a free online Google Chrome application for Subscribe ou Publish MQTT. For this example, set up the configurations like is shown below:

Hostname: test.mosquitto.org (choose tcp:// on left combobox)
Port: 1883
Topic: MQTTEdison

Now, execute the attached Python script in Intel Edison´s (it is full of comments, really easy to understand) and send messages in MQTTLens. Your message will be shown in LCD!

Here, there´s a video of a application for MQTT and Edison. In this case, I wrote a webpage that connects to websocket of Mosquitto, so I can publish messages using a simple Browser in a computer, smartphone, tablet, etc.

Link of the video: https://www.youtube.com/watch?v=-UeEbfzOYrw

2 Comments

Hi,
Great post.
This is a request for guidance.
My ESP8266 module connects to “test.mosquitto.org” and subscribes to a topic say “b1”. What ever is published to “b1”, it can read it immediately.
Problem happens when my second ESP8266 module subscribes to “test.mosquitto.org” to “b1”. It continuously returns :

WiFi connected
IP address:
192.168.0.9
Attempting MQTT connection…connected
Message arrived [b1] 0
Attempting MQTT connection…connected
Message arrived [b1] 0
Attempting MQTT connection…connected
Message arrived [b1] 0
Attempting MQTT connection…connected

Could you kindly suggest what might be going wrong. I look forward to your advice.
Hi siddhc.

First of all, thank you for reading the post!
Based on your situation's description, it seems to me that both ESP8266 have the same deviceid / mqttid. Every broker has a rule: two clients with the same device id cannot communicate at the same time. So, the connection of one of them is immediately dropped (and considering your ESP8266 is programmed to retry MQTT broker connection, it goes into this "loop of death").
I suggest you change the device id of one of your ESP8266. It may work.


Best regards,
Pedro Bertoleti.