[M467 | M487 | M2354] Cellular Communication on Mbed OS and NuMaker IoT Boards

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

02 Aug 2023, 10:52

[For further inquiries, please e-mail to shchen2@nuvoton.com]
[Visit https://www.nuvoton.com/iot_startup for more IoT solutions]


Cellular communication is wireless technology using cellular networks for long-distance data exchange. It relies on infrastructure like base stations and offers wide coverage, reliability, and secure connectivity for IoT devices. So it enables IoT applications with high data rates through LTE and low-power, low-data-rate connectivity with NB-IoT, offering versatility and efficient connectivity options for diverse IoT use cases.

Nuvoton provides two cellular expansion boards for NuMaker-IoT platforms
  • RF-EC21A (Click here to Nuvoton Direct) : Quectel EC21 module on board for 3G/4G LTE
    Picture2.jpg
    Picture2.jpg (48.4 KiB) Viewed 11083 times
  • RF-BG96A (Click here to Nuvoton Direct) : Quectel BG96 module on board for NB-IoT
    Picture3.jpg
    Picture3.jpg (47.97 KiB) Viewed 11083 times
The expansion board is plugged into the Arduino connector on the NuMaker IoT platform. The cellular module is connected to MCU through UART.

Prerequisite
  • A NuMaker-IoT-M467 board
    Other NuMaker-IoT boards are also possible but use NuMaker-IoT-M467 for this tutorial.
    Picture1.jpg
    Picture1.jpg (9.37 KiB) Viewed 11083 times
  • A cellular expansion board
    Use RF-EC21A for this tutorial.
  • A mini SIM card which has network plan
  • Mbed Studio – the development tool
    Register an Mbed OS account to use Mbed tools for free https://os.mbed.com
    Download Mbed Studio and install it https://os.mbed.com/studio
Put SIM card on the back of cellular expansion board. Check the three switches to correct settings.
Picture4.jpg
Picture4.jpg (76.81 KiB) Viewed 11083 times
Plug the cellular expansion board on NuMaker-IoT board and put on antenna.
Picture5.jpg
Picture5.jpg (164.73 KiB) Viewed 11083 times



Create a Project
  • Run Mbed Studio
  • Log in your Mbed account if it asks.
  • Click File
  • Click Import Program
Picture6.png
Picture6.png (24.55 KiB) Viewed 11083 times


Picture7.png
Picture7.png (41.81 KiB) Viewed 11083 times

  • Active program is “NuMaker-mbed-Cellular-example”
  • Use NuMaker-IoT-M467 as example
    • Select target on the pull down menu, use M467 as keyword to find “NuMaker-IoT-M467”, then select it. Or you can
    • Plug the Nu-Link2 USB on NuMaker-IoT-M467 to PC. Mbed Studio will detect it automatically and then select Yes when it ask you to set the device as active.
Picture8.png
Picture8.png (66.93 KiB) Viewed 11083 times



View the Code
  • Click main.cpp to show the source code
  • Get default network interface, it is configure to cellular in mbed_app.json.
  • Connect the network.
  • If connection success, print IP address and do send and receive test. The test is send a data string to remote server then receive the same data from server.
  • Disconnect the network
  • End
Picture9.png
Picture9.png (80.97 KiB) Viewed 11083 times



Modify Settings for Cellular
The default setting of the example selects GENERIC_AT3GPP driver for cellular module. It is fine for most cases. However, Mbed OS has drivers that supported Quectel EC2X and BG96, we can use them.
  • Click mbed_app.json to open it.
    Picture10.png
    Picture10.png (79.27 KiB) Viewed 11083 times
  • For RF-EC21A
    Picture11.png
    Picture11.png (17.34 KiB) Viewed 11083 times
  • For RF-BG96A
    Picture12.png
    Picture12.png (11.52 KiB) Viewed 11083 times




Build Code
  • Click hammer to build code
  • After build finish, you get the firmware image file NuMaker-mbed-Cellular-example.bin in the folder.

    Windows
    C:\Users\YOUR-ACCOUNT\Mbed Programs\NuMaker-mbed-Cellular-example\BUILD\NUMAKER_IOT_M467\ARMC6

    Linux
    ~/Mbed Programs/NuMaker-mbed-Cellular-example/BUILD/NUMAKER_IOT_M467/ARMC6
Picture13.png
Picture13.png (72.21 KiB) Viewed 11083 times




Program firmware
  • Make sure that no.1 & 2 are ON and no.3 & 4 are OFF of ICESW2 on Nu-Link2-ME
    Picture15.jpg
    Picture15.jpg (32.45 KiB) Viewed 11083 times
  • Plug in USB cable to PC
  • A NuMicro MCU drive appears on PC
  • Copy NuMaker-mbed-Cellular-example.bin to NuMicro MCU drive to program firmware. Or click “Connect” icon to download firmware and run.
Picture14.png
Picture14.png (97.63 KiB) Viewed 11083 times



Open the Terminal
  • Mbed Studio automatically open a terminal when a Mbed Enabled board detected.
  • Or you can run a terminal tool to open Nu-Link2-ME virtual COM port
  • Select baud rate to 115200
Picture16.png
Picture16.png (59.92 KiB) Viewed 11083 times


Run it
  • Press RESET button on NuMaker-IoT-M467 to run it
    Picture17.jpg
    Picture17.jpg (48.04 KiB) Viewed 11083 times
  • The terminal shows the running messages
    • Establish connection
    • Print IP address when connected
    • TCP connects to remove echo server
    • Send 4 bytes to remove echo server
    • Receive 4 bytes from remote echo server
Picture18.png
Picture18.png (69.66 KiB) Viewed 11083 times
That's all. ;)

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 81 guests