RTL8720DN
Intro: RTL8720DN
This instructables should how to use RTL8720DN with Arduino IDE.
STEP 1: What Is RTL8720DN?
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.
Ref.:
https://www.seeedstudio.com/Realtek8720DN-2-4G-5G-...
https://en.wikipedia.org/wiki/List_of_WLAN_channel...
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:
https://www.arduino.cc/en/software - Follow "Getting Started with RTL8722" guide to install AmebaD:
https://www.amebaiot.com/en/amebad-arduino-getting... - Follow "Getting Started with Arduino and BW16 Module" guide to update the "variant.cpp" file:
https://github.com/mikey60/BW16-RTL8720DN-Module-...
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.
Notes:For first upload only, you may found new program not uploaded after finished "upload program", please try follow command erase and flash manually:
macOS:
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
Ref.:
STEP 6: Test With Arduino_GFX
- Download latest Arduino_GFX libraries:
(press "Clone or Download" -> "Download ZIP")
https://github.com/moononournation/Arduino_GFX - 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
Ref.:
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-...
19 Comments
webmaster_grumpy 1 year ago
EMU2 1 year ago
Ts´zul 1 year ago
matianfu 2 years ago
spirkin 2 years ago
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.
naticklamb 2 years ago
Ref: https://forum.amebaiot.com/t/rtl8720dn-sdk-crash-r...
zamanimran 2 years ago
Code:
#include
#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
#else
SoftwareSerial mySerial(0, 1); // RX, TX
#endif
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
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.begin(4800);
mySerial.println("Hello, world?");
}
void loop() { // run over and over
if (mySerial.available()) {
mySerial.write(mySerial.read());
}
}
Please help to resolve serial communication problem. I used the same hardware connection.
lefuturiste 2 years ago
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
陳亮 2 years ago
brcisna 2 years ago
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
陳亮 2 years ago
mcavalcante2 2 years ago
mcavalcante2 2 years ago
陳亮 2 years ago
mcavalcante2 2 years ago
The solution was based on the link below:
https://wiki.seeedstudio.com/Wio-Terminal-Network-...
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 ]:
print("passou")
if b["isbootloader"] == True :
return port, True
else:
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.
mcavalcante2 2 years ago
陳亮 2 years ago
mcavalcante2 2 years ago
Serial.begin(115200);
delay(1000);
// 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
Serial.println("teste111");
}
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.
xidameng 3 years ago
https://www.facebook.com/groups/AmebaIoT/permalink/2842483089339842/