MicroPython
Programming
By:
Dr. Siti Marwangi Mohamad Maharum
Electronics Technology Section
UniKL British Malaysian Institute
SLIDESMANIA.COM
sitimarwangi@unikl.edu.my
You’ll learn …
Pin Diagram of ESP32 Board
What is MicroPython Programming
Flashing ESP32 Board Firmware
Run your 1st Micropython Program
on ESP32
SLIDESMANIA.COM
● A dual core MCU, developed by Espressif Systems.
● A successor to ESP8266.
● Consists of integrated WiFi and Bluetooth.
● Preferable by hobbyists, students, teachers, SMEs
for Proof of Concept (PoC) & prototype
development.
● Suitable for battery operated applications like
wearables, audio equipment, baby monitors, smart
SLIDESMANIA.COM
watches, etc.
What is on the board?
ESP-WROOM-32 Module
Two rows of IO Pins (with 15 pins on each side)
CP2012 USB – UART Bridge IC
Micro–USB Connector (for power and
programming)
AMS1117 3.3V Regulator IC
Enable Button (for Reset)
Boot Button (for flashing)
Power LED (Red)
User LED (Blue – connected to GPIO2)
SLIDESMANIA.COM
Some passive components
Pinout of ESP32 Board
SLIDESMANIA.COM
ESP32 Actual View
SLIDESMANIA.COM
● A tiny open-source Python programming interpreter.
● Supports most of Python’s syntax.
● Includes a small subset of Python standard library.
● The library is optimized to run on a microcontroller.
● Aims to be compatible with normal Python to allow
coding to be transferred from desktop to
microcontroller/embedded system.
● Consists of interactive REPL (read-evaluate-print-
SLIDESMANIA.COM
loop) where program is executed w/o the need to
compile it.
SLIDESMANIA.COM
ESP32 for Newbie!
Connect ESP32 microcontroller
Now, flash the ESP32 board
to your laptop/computer.
as follows:
If Ports (COM & LPT) is not detected,
download ESP32 driver from VLE.
● run file “mytoolsesp32.bat”
and press BOOT button on
It shall display, eg: ESP32 when you see the word
Connecting ……..
● Complete the flashing via this
status:
Install ESP32 firmware as follows:
● Download ESP32 firmware file from VLE
● via Command Prompt, change cmd directory ( cd\ )
● Get the file directory link in which your firmware was
downloaded and extracted (move the folder to C)
● Install esptool via instruction:
SLIDESMANIA.COM
pip install esptool
Flashing MicroPython Firmware
Select the Serial Port of
Download installer for your ESP32 board.
Windows:
https://randomnerdtutorials
.com/uPyCraftWindows
Select the dedicated
Upon download, double- microcontroller board.
click on the installer file.
SLIDESMANIA.COM
Flashing MicroPython Firmware
To choose file in Users in
Now, flash your ESP32 with Step 6, browse for
MicroPython. esp32.bin file in
espfirmware folder (Refer
Step 2 for ESP32 Newbie)
While holding down the
“BOOT“, click the “ok” and
Setting the options as in few seconds, the
follows: firmware will be flashed
into your ESP32 board.
SLIDESMANIA.COM
SLIDESMANIA.COM
uPyCraft for Newbie!
Open uPyCraft IDE, a new window opens:
1) Folder and files
2) Editor
3) MicroPython Terminal
4) Tools
SLIDESMANIA.COM
uPyCraft for Newbie!
Getting to know
the available
Tools on uPyCraft:
SLIDESMANIA.COM
uPyCraft for Newbie!
Click the workspace folder. A new window pops up for you to choose your
workspace path. Create a new folder or select an existing folder to be your
working directory.
For example: Create a folder name “uPyCraft”
Then, click File > Reflush Directory to update the directory.
SLIDESMANIA.COM
uPyCraft for Newbie!
After having the MicroPython firmware installed on your board and having
the board connected to your computer through a USB cable, follow the next
steps:
Go to Tools > Board and select the board you’re using.
Go to Tools > Port and select the com port your ESP is connected to.
Press the Connect button to establish a serial communication with
your board.
The >>> should appear in the Shell window after a successful
connection with your board. You can type the print command to test if
it’s working.
SLIDESMANIA.COM
uPyCraft for Newbie!
Now create a new main file to execute a micropython program on ESP32
board:
Click New File on Tools (Left Sidebar).
Press Save File button to save the file in your computer.
A new window opens, name your file and save it in your computer. For
example:
main.py
Click Download and Run on Tools (Left Sidebar) to upload the file to
your ESP board
SLIDESMANIA.COM
uPyCraft for Newbie!
Run the following code to the Editor on the main.py file:
SLIDESMANIA.COM
uPyCraft for Newbie!
Click Download and Run on Tools (Left Sidebar) to upload the script to the
ESP32 or ESP8266:
You should see a message saying “download ok” in the Shell window
SLIDESMANIA.COM
Tadaaaa… Look on your board now! The blue LED is blinking for every
0.5seconds
Thank you!
Do you have any questions?
sitimarwangi@unikl.edu.my
013-7304703
SLIDESMANIA.COM