Go Down

Topic: MQTT with “Arduino” WiFi dev. Board (Read 557 times) previous topic - next topic

xidameng

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.


Go Up