Close
0%
0%

Use MQTT to upload and listen data

MQTT (Message Queuing Telemetry Tansport) is a protocol proposed by IBM and Eurotech.

Public Chat
Similar projects worth following
62 views
0 followers
MQTT (Message Queuing Telemetry Transport) is a protocol proposed by IBM and Eurotech. The introduction in MQTT Official Website: MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. We can say MQTT is a protocol designed for IoT. MQTT is based on TCP/IP and transmits/receives data via publish/subscribe.

In the operation of MQTT, there are several roles:
Publisher: Usually publishers are the devices equipped with sensors (ex. Ameba). Publishers uploads the data of the sensors to MQTT-Broker, which serves as a database with MQTT service.
Subscriber: Subscribers are referred to the devices which receive and observe messages, such as a laptop or a mobile phone.
Topic: Topic is used to categorized the messages, for example the topic of a message can be “PM2.5” or “Temperature”. Subscribers can choose messages of which topics they want

Ameba RTL8722DM is a low-power dual-band WLAN and Bluetooth Low Energy SoC by Realtek. The RTL8722DM also include memory for Wi-Fi protocol functions and application making it simple for anyone to develop various kind of IoT applications. At the same time it has a wide range of peripheral interfaces. With all these interfaces, it can connect to most of the electronics components like LEDs, temperature and humidity sensors, and so on.

More Resources:

If you need additional technical documents or the source code for this project. Please visit the official websites and join the Facebook group and forum.

  • 1 × RTL8722DM Microcontroller
  • 1 × PMS3003/PMS5003 sensor

  • 1
    Setup

    In this example, we connect Ameba to MQTT-Broker. Then send messages as publisher and receive messages from MQTT Broker as subscriber. Open the MQTT example "File"  → "Examples"→ "AmebaMQTTClient" → "MQTT_Basic"

  • 2
    Programming

    Please modify some Wi-Fi related parameters. And some information related to MQTT:

      The “mqttServer” refers to the MQTT-Broker, we use the free MQTT sandbox “test.mosquitto.org” for testing. “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. 

  • 3
    Final Results

    compile the code and upload it to Ameba. Press the reset button, then open the serial monitor9-4  After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. To see the message, we need another MQTT client. Here we use a chrome plugin “MQTTLens” to be the MQTT client. You can find it in google webstore.9-5Install and open the MQTTLens, click “+” next to “Connection” on the left, and fill in the required information

    • Connection Name: Used to identify the connection, you can choose a name you like.
    • Hostname: The MQTT-Broker server, here we use “iot.eclipse.org”
    • Client ID: We use the default randomly generated ID.

    Then click “CREATE CONNECTION”.9-6Since we have not registered the topic we want to listen to, we would not receive any messages now. Fill in “outTopic” in the “Topic” field and click “Subscribe”. Wait for Ameba to send next message (or you can press the reset button). Then you can see the “hello world” message show up.9-7

View all 3 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates