[M467 | M487 | M2354 | M263] Control AT Command module on Mbed OS and NuMaker IoT Boards
Posted: 12 Jun 2023, 11:51
[For further inquiries, please e-mail to shchen2@nuvoton.com]
[Visit https://www.nuvoton.com/iot_startup for more IoT solutions]
AT command is used to communicate with a communication device, such as a modem or a Wi-Fi module. Mbed OS has ATCmdParser class to implement functionality to send and receive AT commands to the devices capable of using AT commands.
Some NuMaker-IoT boards have Wi-Fi modules, which are controlled by AT commands based on the ESP8266 chip.
You need an Mbed OS account to use Mbed tools, please register one if you don't have it.
https://os.mbed.com
Then download and install Mbed Studio which is a offline IDE tool provided by Arm for developing Mbed OS applications.
https://os.mbed.com/studio
Run Mbed Studio, and import example code to create a new project.
Fill the example link to "URL" https://github.com/ARMmbed/mbed-os-snippet-AT_CmdParser
Then click "Add Program"
"Active program" should be "mbed-os-snippet-at_cmdparser". If not, please select it.
Then select NuMaker-IoT-M467 to "Target" on the pull down menu.
Click "main.cpp" to show the source code. BufferSerial object is the UART port connected to Wi-Fi module. Declare a ATCmdParser object with the BufferSerial object. Send a get version command “AT+GMR” to the ESP8266 Wi-Fi module to get version number. Receive and parse the response string to get the version field.
Modify UART pins connect to Wi-Fi module. Here lists Wi-Fi module pins (Tx, Rx) for NuMaker boards:
And the code at line 36 has a little bug so we have to fix it. The correct code should be
Click hammer to build code.
While building the code, let's check NuMaker board, please make sure that no.1 & 2 are ON and no.3 & 4 are OFF of ICESW2 on Nu-Link2-ME. Then plug its USB to PC. You will find a NuMicro MCU drive on PC.
When build is completed, you get the binary firmware file "mbed-os-snippet-at_cmdparser.bin" in "C:\Users\YOUR-ACCOUNT\Mbed Programs\mbed-os-snippet-at_cmdparser\BUILD\NUMAKER_IOT_M467\ARMC6" folder. Just copy the binary firmware to NuMicro MCU drive.
Mbed Studio automatically open a terminal when a Mbed Enabled board detected. Or you can use other terminal tool to open Nu-Link2-Me virtual COM port and select the baud rate to 9600.
You can press RESET button on NuMaker-IoT-M467 board to restart firmware. Then the running information shows on terminal.
This is a simple way to use Mbed OS's ATCmdParser class library to control a AT Command module on NuMaker boards. If you have any problems, please contact us SalesSupport@nuvoton.com
[Visit https://www.nuvoton.com/iot_startup for more IoT solutions]
AT command is used to communicate with a communication device, such as a modem or a Wi-Fi module. Mbed OS has ATCmdParser class to implement functionality to send and receive AT commands to the devices capable of using AT commands.
Some NuMaker-IoT boards have Wi-Fi modules, which are controlled by AT commands based on the ESP8266 chip.
- NuMaker-IoT-M467
- NuMaker-IoT-M487
- NuMaker-IoT-M263A
- NuMaker-M2354
- NuMaker-PFM-M2351
You need an Mbed OS account to use Mbed tools, please register one if you don't have it.
https://os.mbed.com
Then download and install Mbed Studio which is a offline IDE tool provided by Arm for developing Mbed OS applications.
https://os.mbed.com/studio
Run Mbed Studio, and import example code to create a new project.
Fill the example link to "URL" https://github.com/ARMmbed/mbed-os-snippet-AT_CmdParser
Then click "Add Program"
"Active program" should be "mbed-os-snippet-at_cmdparser". If not, please select it.
Then select NuMaker-IoT-M467 to "Target" on the pull down menu.
Click "main.cpp" to show the source code. BufferSerial object is the UART port connected to Wi-Fi module. Declare a ATCmdParser object with the BufferSerial object. Send a get version command “AT+GMR” to the ESP8266 Wi-Fi module to get version number. Receive and parse the response string to get the version field.
Modify UART pins connect to Wi-Fi module. Here lists Wi-Fi module pins (Tx, Rx) for NuMaker boards:
- NuMaker-IoT-M467 : PC_1, PC_0
- NuMaker-IoT-M487 : PH_8, PH_9
- NuMaker-IoT-M263A : PC_7, PC_6
- NuMaker-M2354 : PC_7, PC_6
And the code at line 36 has a little bug so we have to fix it. The correct code should be
Code: Select all
if (_parser->recv(“SDK version:%d”, &version) && _parser->recv(“OK”))
Click hammer to build code.
While building the code, let's check NuMaker board, please make sure that no.1 & 2 are ON and no.3 & 4 are OFF of ICESW2 on Nu-Link2-ME. Then plug its USB to PC. You will find a NuMicro MCU drive on PC.
When build is completed, you get the binary firmware file "mbed-os-snippet-at_cmdparser.bin" in "C:\Users\YOUR-ACCOUNT\Mbed Programs\mbed-os-snippet-at_cmdparser\BUILD\NUMAKER_IOT_M467\ARMC6" folder. Just copy the binary firmware to NuMicro MCU drive.
Mbed Studio automatically open a terminal when a Mbed Enabled board detected. Or you can use other terminal tool to open Nu-Link2-Me virtual COM port and select the baud rate to 9600.
You can press RESET button on NuMaker-IoT-M467 board to restart firmware. Then the running information shows on terminal.
This is a simple way to use Mbed OS's ATCmdParser class library to control a AT Command module on NuMaker boards. If you have any problems, please contact us SalesSupport@nuvoton.com