MicroPython
This chapter contains the following sections. Please read as needed:
MicroPython Getting Started Tutorials
New to ESP32 MicroPython development and want to get started quickly? We have prepared a general introductory tutorial ESP32 MicroPython Getting Started for you.
- Section 1 Set Up Development Environment
- Section 2 Basics
- Section 3 GPIO Digital Output/Input
- Section 4 ADC Analog Input
- Section 5 PWM Output
- Section 6 UART Communication
- Section 7 I2C Communication
- Section 8 SPI Communication
- Section 9 Wi-Fi Networking Basics
- Section 10 Web Server
- Section 11 Bluetooth
- Section 12 Comprehensive Projects
Setting Up Development Environment
1. Flash MicroPython Firmware and Configure Thonny
Please refer to the Set Up MicroPython Development Environment to flash the MicroPython firmware.
2. Other Tips
-
ESP32-S3-Pico MicroPython Firmware Download Link: https://micropython.org/download/ESP32_GENERIC_S3/
-
If using the Espressif Flash Download Tool to flash MicroPython firmware onto the ESP32-S3-Pico, the flashing address is
0x0.
Demo
The MicroPython example programs are located in the Demo Package.
Most demos are written based on the Pico-Sensor-Kit-B.
For a better user experience, our firmware includes a built-in .py file that wraps the discrete GPIOs into pins ordered according to the Pico pin layout. The source code is as follows:
from micropython import const
D0 = const(11)
D1 = const(12)
D2 = const(13)
D3 = const(14)
D4 = const(15)
D5 = const(16)
D6 = const(17)
D7 = const(18)
D8 = const(33)
D9 = const(34)
D10= const(35)
D11= const(36)
D12= const(37)
D13= const(38)
D14= const(39)
D15= const(40)
D16= const(42)
D17= const(41)
D18= const(1)
D19= const(2)
D20= const(4)
D21= const(5)
D22= const(6)
D26= const(7)
D27= const(8)
D28= const(9)
A1= const(7)
A2= const(8)
A3= const(9)
RGB_PIN= const(21)
USB_ADC= const(3)
| Demo | Basic Description |
|---|---|
| 01_GPIO | Blink and Key Examples |
| 02_PWM | Fade and Siren Examples |
| 03_UART | UART Example |
| 04_SD_I2C | I2C-OLED and I2C-SCAN Examples |
| 05_SPI | Driving the Pico-LCD-1.3 Example |
| 06_ADC | ADC Example |
| 07_RGB | Lighting Up the Onboard RGB LED |
| 08_SYS | FLASH-SIZE, RAM-SIZE, RTC, SLEEP, and WDT Examples |
| 09_WIFI | Scanning for Surrounding Wi-Fi Networks |
01_GPIO
Demo Description
- Demonstrates the use of GPIO input and output.
Hardware Connection
- Insert the ESP32-S3-Pico into the Pico-Sensor-Kit-B.
- Connect the development board to the computer
Blink Operation Result
- The LED module on the Pico-Sensor-Kit-B (connected to D10) blinks at a frequency of 1 second.
Key Operation Result
- Read the KEY module on the Pico-Sensor-Kit-B (connected to D3).
- If a low level is detected (key pressed), toggle the state of the LED module (connected to D10).
02_PWM
Demo Description
- Demonstrates the use of PWM.
Hardware Connection
- Insert the ESP32-S3-Pico into the Pico-Sensor-Kit-B.
- Connect the development board to the computer
Fade Operation Result
- The BUZZER module on the Pico-Sensor-Kit-B (connected to D12) outputs a PWM signal at a frequency of 1000 Hz, with the duty cycle increasing or decreasing between 0% and 100%.
Siren Operation Result
- The BUZZER module on the Pico-Sensor-Kit-B (connected to D12) outputs a PWM signal with a duty cycle of 30%, and the frequency increases or decreases between 600 Hz and 1400 Hz.
03_UART
Demo Description
- Demonstrates the use of UART.
Hardware Connection
- Connect GP11 and GP12 on the ESP32-S3-Pico together.
- Connect the development board to the computer
UART Operation Result
- GP11 and GP12 on the ESP32-S3-Pico are used as UART TX and RX pins, respectively, to perform a UART echo test.
04_I2C
Demo Description
- Demonstrates the use of I2C.
Hardware Connection
- Insert the ESP32-S3-Pico into the Pico-Sensor-Kit-B.
- Connect the development board to the computer
I2C-OLED Operation Result
- The OLED module on the Pico-Sensor-Kit-B displays text and graphics via I2C communication.
I2C-SCAN Operation Result
- The ESP32-S3-Pico configures D8 and D9 in I2C mode, scans for I2C modules on the Pico-Sensor-Kit-B, and outputs their corresponding I2C addresses.
05_SPI
Demo Description
- Demonstrates driving an LCD screen via the SPI interface.
Hardware Connection
-
Insert the ESP32-S3-Pico into the Pico-LCD-1.3 expansion board.
-
Connect the development board to the computer
The LCD module is connected using the default SPI pins.
Pico-LCD-1.3 Operation Result
- Successfully drives the Pico-LCD-1.3 module and displays test content.
06_ADC
Demo Description
- Demonstrates the ADC analog sampling function.
Hardware Connection
-
Use USB_ADC, A1, A2, and A3 as ADC inputs.
-
Connect the development board to the computer
ADC Operation Result
-
Sequentially reads the voltage values from USB_ADC, A1, A2, and A3.
-
Outputs the corresponding sampled data via the serial port.
07_RGB
Demo Description
- Demonstrates RGB LED control.
Hardware Connection
-
Use the onboard RGB LED.
-
Connect the development board to the computer
RGB Operation Result
- The RGB LED continuously changes colors and cycles through displays.
08_SYS
Demo Description
- Demonstrates system-related functions, including FLASH, RAM, RTC, SLEEP, and WDT.
Hardware Connection
-
Use only the ESP32-S3-Pico development board.
-
Connect the development board to the computer
FLASH-SIZE Operation Result
- Outputs the remaining FLASH space.
RAM-SIZE Operation Result
- Outputs RAM usage and remaining space.
RTC Operation Result
- Sets the RTC time and continuously reads the RTC value in a loop.
SLEEP Operation Result
- Configures the ESP32-S3 for deep sleep for 10 seconds and automatically resets.
WDT Operation Result
- Enables the watchdog timer and waits for it to trigger a reset.
09_WIFI
Demo Description
- Demonstrates the Wi-Fi scanning function.
Hardware Connection
-
Use the onboard Wi-Fi of the ESP32-S3-Pico.
-
Connect the development board to the computer
Scan Operation Result
- Scans for surrounding Wi-Fi networks and outputs relevant information.