Introduction: RTL8720DN

About: Make it yourself if you cannot buy one!

This instructables should how to use RTL8720DN with Arduino IDE.

Step 1: What Is RTL8720DN?

Realtek RTL8720DN is a WiFi and Bluetooth module that has dual bands for WiFi communication. It is worth saying that this little module can support WiFi 5G and Bluetooth Low Energy 5.0 as well. This WiFi and Bluetooth module is a highly integrated WiFi and Bluetooth module with the main chip RTL8720DN, it can be regarded as an SoC for the WiFi and Bluetooth application with typical SBCs.

RTL8720DN just like ESP32 is WiFi and Blutooth module, but it have extra support for WiFi 5GHz. It is a very big advantages, since 2.4GHz only have 3 non-overlapping channels, 5GHz can provide more options. The performance and number of pins not as rich as ESP32, it is more like ESP8266.

Picture 1: DW16, this is a RTL8720DN module with RF shield

Picture 2: Rtlduino, this is a DW16 dev board but it need some tricks to program it.

Picture 3: Wio Terminal, this is a dev device Embedded DW16 for wireless connectivity.






Step 2: Arduino Support

Realtek has released Arduino IDE support for RTL8722CSM/RTL8722DM. The software also can support their family member RTL8720DN, but require some patch:

  1. Download and install latest Arduino IDE if not yet:
  2. Follow "Getting Started with RTL8722" guide to install AmebaD:
  3. Follow "Getting Started with Arduino and BW16 Module" guide to update the "variant.cpp" file:

After applied miley60's file patch, the pin layout is a little bit different from the PCB print, so I have draw a pinout diagram showing the correct PIN numbers and usage.

Step 3: BW16 Breadboard Connection

BW16 pins are 2 mm pitch, I have made a connector help to connect it to breadboard:


Step 4: BW16 Upload Program

Here are the BW16 to USB Serial Adapter connection summary:

BW16   -> USB Serial Adapter
3V3    -> 3V3
GND    -> GND

When upload program:

  1. Connect LOG_TX to GND
  2. Connect EN to GND and then reconnect EN to 3V3 to trigger reset
  3. disconnect LOG_TX from GND
  4. BW16 now entered the upload mode

After upload program, connect EN to GND and then reconnect EN to 3V3 to trigger reset. New program start run.


For first upload only, you may found new program not uploaded after finished "upload program", please try follow command erase and flash manually:


cd ~/Library/Arduino15/packages/realtek/tools/ameba_d_tools/1.0.5
tools/macos/image_tool/amebad_image_tool /dev/cu.usbserial-*

Step 5: Rtlduino Program Tricks

Rtlduino is a RTL8720DN breakout dev board, but I guess it is designed for using AT Command firmware only. The USB to Serial chip is connected to the Serial Port, GPIO1(PB1) and GPIO0(PB2), that using for AT firmware communication only. If you want to program it with Arduino IDE, amebad_image_tool require communicating to LOG Serial Port, pins GPIO14(PA7) and GPIO15(PA8). The simplest way to fix this issue is connect 2 Serial Ports together, i.e. join PB1 to PA7 and join PB2 to PA8. Please be reminded that this method sacrificed 1 Serial Port or 2 GPIO pins, but no need to desoldering and reroute any connections.

The remained GPIO still enough to connect to a SPI display like ILI9341 LCD.

Here are the connection summary:

Rtlduino        -> ILI9341 LCD
3V3             -> VCC
GND             -> GND
GPIO18          -> CS
GPIO22          -> RST
GPIO17          -> DC
GPIO19          -> CLK
GPIO23          -> LED
GPIO21          -> MOSI




Step 6: Test With Arduino_GFX

  1. Download latest Arduino_GFX libraries:
    (press "Clone or Download" -> "Download ZIP")
  2. Import libraries in Arduino IDE
    (Arduino IDE "Sketch" Menu -> "Include Library" -> "Add .ZIP Library" -> select downloaded ZIP file)
  3. Select PDQGraphicsTest example
    (Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "PDQGraphicsTest")
  4. Select Board: RTL8722DM/RTL8722CSM
    (Arduino IDE "Tools" Menu -> "Board:" -> "Ameba ARM (32-bits) boards" -> "RTL8722DM/RTL8722CSM")
  5. Hold the Rtlduino "Burn" button, press the "RST" button and then release the "Burn" button
  6. Press "Upload" for compile and upload the program

Step 7: WiFi Photo Frame

RTL8720DN MCU is fast enough and have enough memory for JPEG image decode and also the SPI is good enough for display image.

However, AmebaD not yet have internal flash filesystem support like ESP8266 or ESP32 does. And also RTL8720DN does not have all AmebaD SDIO API required pins.

Fortunately RTL8720DN is WiFi capable, you can direct download the JPEG image and stream to the JPEG decoder and display it:

  1. Select WiFiPhotoFrame example
    (Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "WiFiPhotoFrame")
  3. Compile and upload

Please see my previous instructables to know more about how to build a photo web server: https://www.instructables.com/Face-Aware-OSD-Phot...

Step 8: Dual Band WiFi Analyzer

RTL8720DN is a dual band WiFi capable, 2.4GHz and 5GHz. So it is a better WiFi Analyzer than ESP8266 or ESP32 does.

  1. Select RTLWiFiAnalyzer example
    (Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "WiFiAnalyzer" -> "RTLWiFiAnalyzer")
  2. Compile and upload



Step 9: What's Next?

AmebaD still have many example for RTL8722DM/RTL8722CSM, most also works for RTL8720DN. But Sticky remember RTL8720DN is much lesser GPIO than RTL8722DM/RTL8722CSM, so many example requires override the default pins. E.g. blink example defined LED pin as GPIO8 but RTL8720DN does not have GPIO8.

mikey60 also rewrote some examples: https://github.com/mikey60/BW16-RTL8720DN-Module-...

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share


    • Make It Modular: Student Design Challenge

      Make It Modular: Student Design Challenge
    • Digital Fabrication Student Design Challenge

      Digital Fabrication Student Design Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest



    5 weeks ago

    Hi. thank you for your excellent introduction to RTL8720DN. Do you have any data on iperf testing, tcp or udp, for this chip? Since it has 5G band, most people would expect it to outperform esp32 substantially. I have googled but cannot find any posts or videos with real world test. Do you have any information to share?


    6 weeks ago

    Hey !!!
    I have a problem at work my colleagues don't want to work and play games all the time. I need to disconnect from the game. The DSTIKE clock can do this, but not all of them - they can only do it at a frequency of 2.4, and I need a frequency of 5 gigahertz. Can you help me give the firmware - you have already worked with the BW16 RTL8720DN 5.0 module. Looking forward to help.


    3 months ago

    Even with the stock "B+T" firmware on the BW16 module a connection to a close (sitting next to it) OPEN wifi access point causes system to crash. Same behavior with SDK/make and Arduino environments. Putting unit in partial faraday cage or simply putting finger on antenna alleviates the problem. Appears problem is in the wifi driver library which I cannot get the source to. I hope Realtek fixes this problem. Id like to replace ESP designs with this. This was a great article and the rtl8720dn a great 5Ghz solution.
    Ref: https://forum.amebaiot.com/t/rtl8720dn-sdk-crash-r...


    5 months ago

    Hi Chen! I am working on RTL8720DN module. The flashing process works fine for me but I have issue with serial as no data received.



    #if defined(BOARD_RTL8722DM)
    SoftwareSerial mySerial(0, 1); // RX, TX
    #elif defined(BOARD_RTL8722DM_MINI)
    SoftwareSerial mySerial(2, 1); // RX, TX
    #elif defined(BOARD_RTL8720DN_BW16)
    SoftwareSerial mySerial(PB2, PB1); // RX, TX
    SoftwareSerial mySerial(0, 1); // RX, TX

    void setup() {
    // Open serial communications and wait for port to open:
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

    Serial.println("Goodnight moon!");

    // set the data rate for the SoftwareSerial port
    mySerial.println("Hello, world?");

    void loop() { // run over and over
    if (mySerial.available()) {

    Please help to resolve serial communication problem. I used the same hardware connection.

    Screenshot 2021-12-08 154136.png

    10 months ago

    Hi! Can you share a little bit more about your configuration in the Arduino IDE I followed the guide that you gave but I have a problem :
    When I plug in the FT232 (USB to serial adapter) with the BW16 connected to my computer, I can't select a port in the arduino IDE


    Reply 9 months ago

    Any USB serial adapter should be the same in Arduino IDE, no special configuration. Before you open the IDE, can you see the port with command `ls /dev/cu.*`


    10 months ago

    Hi Moon,
    I purchased two rtlduino modules. I followed your instrucatable on this as best I could. One thing,I could not figure out how to 'overwrite' the original realtek/amibad files with the 'mikey' variant modded files. Regardless i was able to upload code sketches to the rtlduino with success but,,after repower and also trying the rst button,,the module never functions,,I want these to work as a repeater for a drone flying project so wifi only. If i open Arduino console i do see interface 0 & interface 1 initialzied,,,and UART something,and that is all? Am powering the rtlduino with usb mimi cable? Thank You, brcisna@gmail.com
    Barry Cisna


    Reply 10 months ago

    I have added a notes at step 4, please try is it work for you.


    11 months ago

    Hello Chen... is there some library to support WPS on RTL8720DN? Do you know some example about how to use WPS?


    1 year ago

    Is it possible to upgrade the rtlduino dev kit (rtl8720dn) firmware directly from the PC through its microUSB port, not using an official development/IO board?


    Reply 12 months ago

    Yes, please read the details in step 4 and 5.


    Reply 12 months ago

    Finally I could put it working. What I had to do was to erase the flash before to upload my sketch to the board.

    The solution was based on the link below:

    Maybe it´s not the best solution, but it is the one that worked for me. What I did was to change the function getAvailableBoard() in script ambd_flash_tool.py, and let it like below:
    def getAvailableBoard():
    for info in getAllPortInfo():
    port, desc, hwid = info
    ii = hwid.find("VID:PID")
    print (str(info))
    #hwid: USB VID:PID=2886:002D SER=4D68990C5337433838202020FF123244 LOCATION=7-3.1.3:1.
    if ii != -1:
    for b in BOARD_IDS:
    print (str(b) + " " + str(b["info"]) + " " + str(ii) + str(hwid[ii + 8: ii + 8 + 4]) + " " + hwid[ii + 8 + 5 :ii + 8 + 5 + 4 ])
    (vid, pid) = b["info"]
    if vid == hwid[ii + 8: ii + 8 + 4] and pid == hwid[ii + 8 + 5 :ii + 8 + 5 + 4 ]:
    if b["isbootloader"] == True :
    return port, True
    return port, False
    elif b["isbootloader"] == True :
    print("Ok, eh bootloader")
    return port, True

    After that, I´ve opened the PowerShell and executed it as below:

    C:\Users\mcava\ambd_flash_tool> python.exe .\ambd_flash_tool.py erase

    But, before to execute the command below, put the board in the download mode, like below:
    1) press and hold the burn button;
    2) press and release the RST button;
    3) release the burn button.

    It will start to erase the board´s flash, it will take a while (~ 5 or 10 minutes), and afterwards all you have to do is to upload your sketch.


    Reply 12 months ago

    Thank you for answering soon. Yes, I did it. But the output I have after reseting the board is the one shown in picture attached.


    Reply 12 months ago

    void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(19, OUTPUT);
    pinMode(20, OUTPUT);
    pinMode(21, OUTPUT);

    void loop() {
    digitalWrite(19, HIGH); // turn the LED on (HIGH is the voltage level)
    digitalWrite(20, HIGH); // turn the LED on (HIGH is the voltage level)
    digitalWrite(21, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(19, LOW); // turn the LED off by making the voltage LOW
    digitalWrite(20, LOW); // turn the LED off by making the voltage LOW
    digitalWrite(21, LOW); // turn the LED off by making the voltage LOW
    delay(1000); // wait for a second

    Does this script work for you?

    Please find attached the picture of my board.

    Notice that there´s a command that is intended to send the message "teste111" to the serial output, that is not shown in the log that I attached in the previous message.