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:
- Download and install latest Arduino IDE if not yet:
- Follow "Getting Started with RTL8722" guide to install AmebaD:
- 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 LOG_RX -> TX LOG_TX -> RX 3V3 -> 3V3 GND -> GND
When upload program:
- Connect LOG_TX to GND
- Connect EN to GND and then reconnect EN to 3V3 to trigger reset
- disconnect LOG_TX from GND
- 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 GPIO1 -> GPIO14 GPIO0 -> GPIO15 GPIO18 -> CS GPIO22 -> RST GPIO17 -> DC GPIO19 -> CLK GPIO23 -> LED GPIO21 -> MOSI
Step 6: Test With Arduino_GFX
- Download latest Arduino_GFX libraries:
(press "Clone or Download" -> "Download ZIP")
- Import libraries in Arduino IDE
(Arduino IDE "Sketch" Menu -> "Include Library" -> "Add .ZIP Library" -> select downloaded ZIP file)
- Select PDQGraphicsTest example
(Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "PDQGraphicsTest")
- Select Board: RTL8722DM/RTL8722CSM
(Arduino IDE "Tools" Menu -> "Board:" -> "Ameba ARM (32-bits) boards" -> "RTL8722DM/RTL8722CSM")
- Hold the Rtlduino "Burn" button, press the "RST" button and then release the "Burn" button
- 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:
- Select WiFiPhotoFrame example
(Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "WiFiPhotoFrame")
- Fill your own SSID_NAME, SSID_PASSWORD, HTTP_HOST, HTTP_PORT and HTTP_PATH_TEMPLATE
- 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.
- Select RTLWiFiAnalyzer example
(Arduino IDE "File" Menu -> "Examples" -> "GFX Library for Arduino" -> "WiFiAnalyzer" -> "RTLWiFiAnalyzer")
- 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-...
Participated in the