Jump to content
Electronics-Lab.com Community

MQTT with “Arduino” WiFi dev. Board


MENG XI

Recommended Posts

MQTT is a machine-to-machine (M2M)/"Internet of Things" (IOT) connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.

 

With an Arduino-compatible wireless soc, e.g. Realtek Ameba1 (RTL8195/RTL8710) dev. Board, we can create a MQTT client that sends our sensor data to the cloud or any other MQTT clients.

 

The source code is available on github at,

https://github.com/ambiot/amb1_arduino/blob/master/Arduino_package/hardware/libraries/MQTTClient/examples/mqtt_basic/mqtt_basic.ino

 

The things that need to take note of,

·       The "mqttServer" refers to the MQTT-Broker, we use the MQTT sandbox "test.mosquitto.org", it is provided by IBM eclipse for developers to test MQTT.

·       "clientId" is an identifier for MQTT-Broker to identify the connected device.

·       "publishTopic" is the topic of the published message, we use "outTopic" in the example. The devices subscribe to "outTopic" will receive the message.

·       "publishPayload" is the content to be published.

·       "subscribeTopic" is to tell MQTT-broker which topic we want to subscribe to.

 

Here we can use a chrome plugin "MQTTLens" to be a second MQTT client. You can find it in Chrome Web Store at,

https://chrome.google.com/webstore/detail/mq-tt-lens-the-best/cgmogjdjpnemdlijokkdomfapcodiohh?utm_source=chrome-ntp-icon

 

After setting up a “connection” and key in the same topics we used on Ameba, we should be able to see a “Hello World” message printed on the MQTT message console.

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...