Jump to content
Electronics-Lab.com Community

Run MicroPython on Realtek's RTL8722 development board


Recommended Posts

Realtek's RTL8722DM development board now supports running Python code through the MicroPython firmware. You can now control the GPIO and other peripherals using the Python syntax through the REPL interface in MicroPython, or by writing it as a script on the device.

A basic example using WiFi to control a LED can be seen at : 

 

Join in the community discussions at:
https://www.facebook.com/groups/AmebaIoT/
https://forum.amebaiot.com/

Purchase links for the various Realtek development boards can be found at:
https://www.amebaiot.com/en/where-to-buy-link/

Link to post
Share on other sites
  • 1 month later...

Microcontrollers are known for its low power usage and limited resources thus often deemed unable to understand Python script as Python need interpretor to translate script into machine langauge and intepretor are usaully quite resource-consuming. However, MicroPython has arisen as a lean and efficiant Python 3 interpretor that can be run on ARM Cortex-M series microcontrollers.

Ameba RTL8722 is an ARM Cortex-M33 microcontroller that has dual-band WiFi and BLE 5.0, other than that it is fully capable of running MicroPython and controls WiFi using Python script. In addition, its requirement for developing platform is also quite minimal-- only needs a serial port terminal like Tera term. Here is an example of RTL8722 controlling WiFi using just a few lines of Python code on Tera Term,

from wireless import WLAN
wifi = WLAN(mode = WLAN.STA)
wifi.scan()

Right after the last line, you will be able to see the result printed on the Tera term almost immediately,

micropython-started-4.png.af7c108059ba58d66d90b8d48c08208e.png

 

More details on getting started with MicroPython on the RTL8722DM can be found at:
https://www.amebaiot.com/en/amebad-micropython-getting-started/

Join in the community discussions at:
https://www.facebook.com/groups/AmebaIoT/
https://forum.amebaiot.com/

Purchase links for the various Realtek development boards can be found at:
https://www.amebaiot.com/en/where-to-buy-link/

Link to post
Share on other sites

For developers interested in MicroPython, the process of building a MicroPython firmware image and adding new features is also easy.

To build a MicroPython firmware successfully, the first step is to get the software and set them up correctly.

Here is a list of the most important software that are used in the firmware building process,

Cygwin: This is the first software you need to install, and we recommand using 32-bit version even for a 64-bit machine. During cygwin installation, there are 2 additional packeges to install as well, GNU make under Devel category and bc under Math category

Python3 : We need python3 to process some python script invoked during the making process, so this is needed. When installing, make sure to choose to add python3 to your system’s evironmental variable PATH so that cygwin knows where to look for the python3 executable file

Toolchain : This is the most important part of the SDK and luckily toolchain is provided in the SDK and will be automatically installed during the first time compilation

Teraterm : Teraterm is an free serial COM software that allow users to interact with MicroPython through REPL (Read Evaluate Print and Loop) prompt. Of course there are other options for serial COM, you may choose the ones you like, but make sure to set baud rate to 115200 in order to talk to REPL

Text editor : To develop efficiently, you need a powerful text editor to help you better understand the code and provide necessary help using its built-in code hinting and deifinition checking features. There are too many options out there, the most common ones are Visual Studio Code, Sublime, Notepad++ and etc.

For more information on developing MicroPython for the RTL8722, you can find an introductory series of post in the AmebaIoT forum:
https://forum.amebaiot.com/

Purchase links for the various Realtek development boards can be found at:
https://www.amebaiot.com/en/where-to-buy-link/

Link to post
Share on other sites
  • 2 weeks later...
UART is a versatile communication protocol commonly used to transmit and receive data with other microcontrollers. To use the UART protocol with a PC, a TTL USB to Serial module is required to translate UART signals to USB signals.
Here is an example of RTL8722 using the UART protocol with just a few lines of MicroPython code.
Connect the USB to UART module to PA_21 and PA_22 as shown below:
1.jpg
Then, copy and paste the following code line by line into REPL.
 
from machine import UART
uart = UART(tx="PA_21", rx= "PA_22")
uart.init()
uart.write('hello')
uart.read(5)

More details on the MicroPython UART API can be found at: https://www.amebaiot.com/en/amebad-micropython-uart/

Join in the community discussions at:
https://www.facebook.com/groups/AmebaIoT/
https://forum.amebaiot.com/

Purchase links for the various Realtek development boards can be found at:
https://www.amebaiot.com/en/where-to-buy-link/

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...