-
Notifications
You must be signed in to change notification settings - Fork 1.1k
stm32 networking
EN | 中文
This article will show you how to use mqtt on STM32L475 to connect to the cloud, based on the AliOS Things 1.2.0.
1、Development board STM32 B-L475E-IOT01A
-
The development board we use is STM32L475, with 1M bytes of Flash and 128K bytes of SRAM.
-
Support WiFi, Bluetooth, SubG, NFC and many other wireless connections. Besides, it supports Arduino interface, so users can also use other wireless connection modules, such as the GSM.
-
64 Mbits's Quad-SPI Flash is also integrated on the board.
-
There are many kinds of sensors on board, such as temperature and humidity sensors, 3 axis magnetometer, acceleration sensors, gyroscopes, proximity sensors and pressure sensors. It is convenient for developers to apply a variety of applications.
-
There are two digital full-angle microphones on the board. If needed, it can achieve voice control.
Detailed information about hardwares can refer to Introduction of STM32
2、MK3060 communication module
3、Three double-head Dupont Lines
4、Ways of connection:
Connect STM32L475 D0 with MK3060 UART TX, STM32L475 D1 with MK3060 UART RX, and STM32L475 GND with MK3060 GND. Detailed way of connection is shown as followed picture: connect the point with same color in two boards with Dupont Line.
How to connect to Alibaba Cloud through mqtt app can refer to Connect preparations for IoT devices and Connect the devices
- Register a Alibaba cloud account
- Start a IoT Suite
- Create a product, get
ProductKey
- Create a device, get
DeviceName
andDeviceSecret
- Define Topic
$(PRODECT_KEY)/$(DEVICE_NAME)/data
, and set the permission as: Devices are capable of publishing and subscribing
Source code of mqtt app is AliOS-Things/example/mqttapp/mqtt-example.c
, credentials for connecting to mqtt server is located at framework/protocol/linkkit/iotkit/sdk-encap/imports/iot_import_product.h. The three parameters obtained from the cloud ( ProductKey
,ProductSecret
,DeviceName
和DeviceSecret
) are corresponding to the three macros PRODUCT_KEY
,PRODUCT_SECRET
,DEVICE_NAME
和DEVICE_SECRET
in the code.
#elif MQTT_TEST
#define PRODUCT_KEY "b1eszMRbDvz"
#define DEVICE_NAME "mqtt_test"
#define DEVICE_SECRET "CAaQz8Fc1JkFEyuzFhu4NpHSTlRSmRxV"
#define PRODUCT_SECRET "Fxx6nyYptOugnS6H"
#else
The current AliOS Things mqtt app compilation command line is:
aos make mqttapp@b_l475e
After the command is executed, the generated bin file and the hex file can be found in out/mqttapp@b_l475e/binary/
directory.
Please go to MK3060 AT firmware download website officially provided by Mxchip, and select the firmware corresponding to MOC108/EMW3060 model. Way of burning can refer to "1. Update application firmware" in MK3060 firmware burning guidance.
Use ST-LINK to burn the firmware. Steps of burning is shown as followed picture:
After the above 4 steps, the corresponding mqttapp binary has been burned into stm32L475 development board, and the port print is started as followed:
Wifi module can be connected to corresponding AP through command line.
netmgr connect *ssid* *password* *open|wep|wpa|wpa2*
When devices can connect to the network, mqttapp will start running. The following picture is mqtt run log:
Log information that can be further obtained on the cloud is shown as below:
| Home | Tutorial | Hardware | Porting Guide | Utilities | API Reference | Technical Docs | Certification |
Crafted with ❤️ by AliOS Things Team.
- Quick Start
- Hello World
- Starter Kit Tutorial
- Developer Kit Tutorial
- AliOS Studio Tutorial
- Add a New Board Example
- Add a New Component Example
- Environment Setup
- SIG BLE Mesh Setup Guide
- BLE Tutorial
- LoRaWAN Tutorial
- Linkkit Tutorial
- LinkVoice Tutorial
- Hardware Setup
- WiFi Provisioning and Alink Certification
- Step by Step: MQTT to Cloud with STM32
- Video Tutorial