Home   >   Blog   >   How MQTT Enables Extensive Connectivity for Wireless Modules in IoT Communication Protocols

How MQTT Enables Extensive Connectivity for Wireless Modules in IoT Communication Protocols

Plate type: Technical Guides
Time: 2024.06.24
Author:
Viewing count: 539

Introduction

As IoT technology rapidly advances, wireless modules are crucial for connecting smart devices and enabling data exchange. A lightweight, efficient, and reliable messaging protocol is essential to meet diverse IoT communication needs. MQTT (Message Queuing Telemetry Transport) is designed specifically for IoT. This article explores MQTT's role in IoT wireless connectivity and demonstrates its benefits through the MS11SF1 small size module on a cloud platform.


1. What is MQTT?

MQTT is a lightweight publish/subscribe messaging protocol designed for IoT. It operates over the TCP/IP protocol, making it ideal for devices with limited hardware and unstable network conditions. MQTT enables wireless modules to communicate with cloud servers, other modules, and user devices, ensuring real-time data transmission and remote control.



2. MQTT in IoT and Wireless Connectivity

MQTT's lightweight design and efficiency are key to its importance in IoT. It supports real-time data transmission and adapts to resource-constrained scenarios, making it ideal for diverse IoT environments like smart homes, industrial automation, smart cities, and agriculture. MQTT supports various QoS (Quality of Service) levels and TLS/SSL encryption, ensuring secure and reliable communication.


MQTT's advantages include:

  • Lightweight and Efficient: Ensures fast, reliable data transmission even with limited resources.

  • Publish/Subscribe Model: Simplifies system architecture and enhances scalability.

  • Reliability: Message acknowledgment and retransmission mechanisms ensure reliable delivery.

  • Security: Supports TLS/SSL encryption and authentication.

 

 

3. Using the MS11SF1 Small Size Module on a Cloud Platform

The MS11SF1 module is a Wi-Fi + BLE SoC Combo based on the ESP32-C3 SoC, featuring low power consumption and high performance. It supports Wi-Fi 4 and BLE 5.0, with a RISC-V 32-bit single-core processor, 400KB RAM, 4MB Flash, and 22 GPIO pins, providing strong hardware support for IoT applications.

 

On a cloud platform, the MS11SF1 enables remote communication and data sharing between IoT devices. With its latest AT firmware, the module facilitates cloud data transmission, allowing devices to send and receive data easily, thereby enhancing remote communication and data sharing capabilities.

 

 

Operation Guide for MS11SF1 with MQTT on AWS IoT Core

Functionality:

MS11SF1, based on the ESP32C3 SoC with the latest AT firmware, facilitates cloud data transmission between two modules.

 

Preparation:

●AWS account

●USB to TTL tool

●2 MS11SF1 modules (pre-flashed with the latest AT firmware)

●Several Dupont wires

 

AT Command Communication Connections:

●Connect the lines as required for AT command communication.

 

 

Main Process:

1.Register an AWS account and access the IoT Core platform:

●Create a thing and generate certificates



2. Download and save all certificates

 

 

3. Replace files in the ESP-AT directory:

●Replace customized_partitions/raw_data/mqtt_ca/mqtt_ca.crt with Amazon-root-CA-1.pem.


 

●Replace customized_partitions/raw_data/mqtt_cert/mqtt_client.crt with your xxx.pem.crt.

 


●Replace customized_partitions/raw_data/mqtt_key/mqtt_client.key with your xxx.pem.key.

 


Recompile the firmware:

●Open PowerShell, navigate to the ESP-AT directory,

 

 

●And run: python build.py build

 

 

5. Flash the firmware with certificates:

●Connect the module for flashing

●Run: python build.py -p com23 flash (replace com23 with your actual COM port)

 


6. Create a new policy on AWS IoT Core

 

 

7. Attach the policy:

●Select the product and name it, e.g., "MS11SF1"


 

●Attach the generated certificates to the policy

 

 

●Select "strategy"

 

 

8. Create a device shadow

 


9. Get the device endpoint:

●Select "Activity" and copy the endpoint details

 

 

10. Connect the module to the cloud and subscribe to a topic:

●Connect the USB to TTL tool to the module's UART0.

●Send the following commands:

 

AT+RESTORE

AT+CWMODE=1

AT+CWJAP="WiFi_Name","WiFi_Password"

AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"

AT+CIPSNTPTIME?

AT+MQTTUSERCFG=0,5,"Thing_Name","AWS_Account","AWS_Password",0,0,""

AT+MQTTCONN=0,"Endpoint_Link",8883,1


 

 

●Subscribe to a topic:

AT+MQTTSUB=0,"$aws/things/MyTestThing/shadow/name/AAA",1

●Verify successful subscription.

 

 

Publish a message from the cloud:

●Go to "Publish to a topic" in AWS IoT Core, enter the subscribed topic, and input the message payload. Click "Publish".

 

 

●Verify the message on the module's serial monitor.

 

 

12. Configure the second module following the same steps.

 


13. Test mutual message publishing:

●Publish message command:

AT+MQTTPUB=0,"topic/esp32at","hello aws!",1,0

 

●Module 1 publishes message to module 2 subscribe to topic

Module 1 publishes a message:

 


Module 2 receives message:

 


●Module 2 publishes message to module 1 subscribe to topic

Module 2 publishes message:

 


Module 1 receives message:


 


Command screenshot:

Module2:

 


Module1:

 


Summary:

The MS11SF1 module, as a high-performance, low-power Wi-Fi + BLE combo module, is valuable for cloud applications. As IoT technology advances, MQTT's lightweight, efficient, reliable, and flexible features make it a preferred protocol for IoT communication. Future improvements in MQTT will enhance security, performance, standardization, and interoperability, further supporting edge computing and large-scale IoT scenarios. Its applications will expand in smart homes, industrial automation, logistics, supply chain, and agriculture, enabling efficient and reliable device communication and driving rapid IoT development.