Ameba ARDUINO: Getting Started with RTL8722DM MINI

Required Environment

AmebaD RTL8722DM MINI board currently supports Windows OS 32-bits and 64-bits (WIN7/8/10), Linux OS (Ubuntu 18 LTS/20 LTS/latest) and macOS operating systems. Please use the latest OS version to have the best experiences. In this documentation, please use the latest version Arduino IDE (at least version 1.8.12).

Introduction to AmebaD RTL8722DM MINI

Ameba is an easy-to-program platform for developing all kind of IoT applications. AmebaD is equipped with various peripheral interfaces, including WiFi, GPIO INT, I2C, UART, SPI, PWM, ADC. Through these interfaces, AmebaD can connect with electronic components such as LED, switches, manometer, hygrometer, PM2.5 dust sensors, …etc.

The collected data can be uploaded via WiFi and be utilized by applications on smart devices to realize IoT implementation.

get-start-1

RTL8722DM MINI has smaller size than Arduino Uno, as shown in the above figure.

get-start-2

RTL8722DM MINI uses Micro USB to supply power, which is common in many smart devices.
Please refer to the following figure and table for the pin diagram and function of RTL8722DM MINI.

get-start-3

 PIN nameGPIO INTADCPWMUARTSPII2C
D0GPIOB_0    I2C0 SDA
D1GPIOB_1A4 Serial2_TX  
D2GPIOB_2A5 Serial2_RX  
D3GPIOB_3A6    
D4GPIOB_4A0   
D5GPIOB_5A1  I2C0 SCL
D6GPIOB_6A2   I2C0 SDA
D7GPIOB_7A3   
D8GPIOA_2     
D9GPIOA_12 Serial2_TXSPI1_MOSI 
D10GPIOA_13 Serial2_RXSPI1_MISO 
D11GPIOA_14   SPI1_CLK 
D12GPIOA_15   SPI1_CS 
D13GPIOA_16     
D14GPIOA_28    
D15GPIOA_18  Serial1_TX  
D16GPIOA_19  Serial1_RX  
D17GPIOA_30    
D18GPIOA_21  Serial1_TX  
D19GPIOA_22  Serial1_RX  
D20GPIOA_23    
D21GPIOA_24    
D22GPIOA_31    I2C0 SCL

Setting up Development Environment

Step 1. Installing the Driver

First, connect RTL8722DM MINI to the computer via Micro USB(same as power):

get-start-4

If this is the first time you connect RTL8722DM MINI to your computer, the USB driver for RTL8722DM MINI will be automatic installed.
If you have driver issue of connect board to your computer please go to https://ftdichip.com/drivers/ for USB driver.
You can check the COM port number in Device Manager of your computer:

get-start-5

Step 2. Set up Arduino IDE

From version 1.6.5, Arduino IDE supports third-party hardware. Therefore, we can use Arduino IDE to develop applications on RTL8722DM MINI, and the examples of Arduino can run on RTL8722DM MINI too. Refer to basic example link.

Arduino IDE can be downloaded in the Arduino website: https://www.arduino.cc/en/Main/Software
When the installation is finished, open Arduino IDE. To set up RTL8722DM MINI correctly in Arduino IDE, go to “File” -> “Preferences”.

get-start-6

And paste the following URL into “Additional Boards Manager URLs” field: https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek.com_amebad_index.json

Next, go to “Tools” -> “Board” -> “Boards Manager”:

get-start-7

The “Boards Manager” requires about 10~20 seconds to refresh all hardware files (if the network is in bad condition, it may take longer). Every time the new hardware is connected, we need to reopen the Board Manager. So, we close the Boards Manager, and then open it again. Find “Realtek AmebaD Boards (32-bits ARM Cortex-M4 @200MHz)” in the list, click “Install”, then the Arduino IDE starts to download required files for AmebaD.

get-start-8

If you are facing GitHub downloading issue, please refer to the following link at “Download/Software Development Kit”. There are 3 sections.
1. “AmebaD_Arduino_patch1_SDK”, please select at least 1 of the SDKs. There are 5 latest released SDK options.
2. “AmebaD_Arduino_patch2_Tools”, please select according to your operation system. There are Windows, Linux and MacOS.
3. “AmebaD_Arduino_Source_Code”, this section is optional download only wants to refer the latest source code.

https://www.amebaiot.com.cn/en/ameba-arduino-summary/

Download the files selected, then unzip (patch1 and patch2 are compulsory). There are “Install.doc”/“Install.pdf” for you to refer installation steps. According to your system, please run the installation tool in the “Offline_SDK_installation_tool” folder.

After the installation tool running successfully, you may open Arduino IDE and proceed to “tools” -> “Board“ -> “Boards Manager…”. Try to find “Realtek AmebaD Boards (32-bits ARM Cortex-M4 @200MHz)” in the list, click “Install”, then the Arduino IDE starts to download required files for AmebaD.

Finally, we select AmebaD as current connected board in “tools” -> “Board” -> “Ameba ARM (32-bits) Boards” ->” RTL8722DM MINI”:

get-start-9

Try the First Example

Step 1. Compile & Upload

Arduino IDE provides many built-in examples, which can be compiled, uploaded and run directly on the boards. Here, we take the “Blink” example as the first try.
Open “File” -> “Examples” -> “01.Basics” -> “Blink”:

get-start-10

Arduino IDE opens a new window with the complete sample code.

get-start-11

There are onboard LED of RTL8722DM MINI, the default “LED_BUILTIN” is blue onboard LE.D
Change “LED_BUILTIN” to “LED_B” or “LED_G” for different colour. Onboard LEDs options LED_B and LED_G. (blue and green).

get-start-12

Next, we compile the sample code directly; click “Sketch” -> “Verify/Compile”

get-start-13

Arduino IDE prints the compiling messages in the bottom area of the IDE window. When the compilation is finished, you will get the message similar to the following figure:

get-start-14

Afterwards, we will upload the compiled code to RTL8722DM MINI.
Please make sure RTL8722DM MINI is connected to your computer, then click “Sketch” -> “Upload”.
The Arduino IDE will compile first then upload. During the uploading process, users are required to enter the upload mode of the board. Arduino IDE will wait 5s for DEV board to enter the upload mode.

get-start-15

To enter the upload mode, first press and hold the UART_DOWNLOAD button, then press the RESET button.

get-start-16

It is optional for users to check if the board entered the upload mode. Open serial monitor/terminal and look for “#Flash Download Start”. Note, it is normal that some serial terminals may show unknown characters as following picture.

get-start-17

Again, during the uploading procedure the IDE prints messages. Uploading procedure takes considerably longer time (about 30 seconds to 1 minute). When upload completed, the “Done uploading” message is printed.

Run the Blink example

In each example, Arduino not only provides sample code, but also detailed documentation, including wiring diagram, sample code explanation, technical details, …etc. These examples can be directly used on RTL8722DM MINI.
So, we find the detailed information of the Blink example:
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink

In short, for RTL8722DM MINI, the example can be run on both onboard LEDs (green or blue) or external LED (use any GPIO pins for signal output).
Finally, press the RESET button, and you can see the LED blinking.
If you encounter any problem, please refer to Troubleshooting.

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved.
Please confirm that QQ communication software is installed