[M467 | M487 | M2354 | M263] Control AT Command module on Mbed OS and NuMaker IoT Boards

Post Reply
morgandu
Posts: 45
Joined: 28 Apr 2017, 22:47

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.
  • NuMaker-IoT-M467
  • NuMaker-IoT-M487
  • NuMaker-IoT-M263A
  • NuMaker-M2354
  • NuMaker-PFM-M2351
Let’s use ATCmdParser class on NuMaker-IoT-M467 to control the Wi-Fi module.
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.
Picture1.png
Picture1.png (112.3 KiB) Viewed 10610 times

Fill the example link to "URL" https://github.com/ARMmbed/mbed-os-snippet-AT_CmdParser
Then click "Add Program"
Picture2.png
Picture2.png (140.05 KiB) Viewed 10610 times

"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.
Picture3.png
Picture3.png (172.82 KiB) Viewed 10610 times

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.
Picture4.png
Picture4.png (288.88 KiB) Viewed 10610 times

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
For NuMaker-IoT-M467, it is PC_1 and PC_0, so modify the D1 and D0 in code to PC_1 and PC_0.
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”))
Picture5.png
Picture5.png (274.32 KiB) Viewed 10610 times

Click hammer to build code.
Picture6.png
Picture6.png (277.89 KiB) Viewed 10610 times

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.
Picture8.png
Picture8.png (187.24 KiB) Viewed 10610 times

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.
Picture7.png
Picture7.png (197.73 KiB) Viewed 10610 times

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.
Picture9.png
Picture9.png (252.14 KiB) Viewed 10610 times

You can press RESET button on NuMaker-IoT-M467 board to restart firmware. Then the running information shows on terminal.
Picture10.png
Picture10.png (317.81 KiB) Viewed 10610 times

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

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 89 guests