Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » MicroPython on ESP32 using uPyCraft IDE – Getting Started
ESP32 MicroPython

MicroPython on ESP32 using uPyCraft IDE – Getting Started

Mamtaz AlamBy Mamtaz AlamUpdated:August 22, 20224 Comments7 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
ESP32 MicroPython uPyCraft
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: Getting Started with MicroPython on ESP32 using uPyCraft IDE

In this getting started tutorial, we will learn how to use MicroPython on ESP32 using uPyCraft IDE. We all are familiar with the Python Programming Language. Python is an interpreted, high-level, general-purpose programming language. As Python is a very powerful language it is used for Artificial Intelligence (AI) & Internet of Things Applications.

As Python became very popular, the Python community developed MicroPython. MicroPython is a lean and efficient implementation of the Python programming language that includes a small subset of the Python standard library and is optimized to run on microcontrollers and in constrained environments. Micropython is supported by the boards like PyBoard, ESP8266, ESP32 & other boards.

In this tutorial, we will be using MicroPython on ESP32 Board using uPyCraft IDE. uPyCraft is an IDE that works with Windows and Mac and designed with a simple interface which is convenient to use. uPyCraft is developed by DfRobot.

We will take two examples here as a reference to learn MicroPython on ESP32 using uPyCraft IDE.
1. We will first write code to blink an LED which is simply like writing the “Hello World” Program.
2. In the second example, we will make a Web Server to control an LED using Web Page.



What is MicroPython?

MicroPython is a software implementation of a programming language largely compatible with Python 3, written in C, that is optimized to run on a microcontroller. The difference between Python & MicroPython is that MicroPython does not come with the full library support as Python. Therefore MicroPython works in constraint conditions only. There are few standard libraries to access and interact with the low-level hardware like GPIOs, Wi-Fi, Networking.

MicroPython is a full Python compiler and runtime that runs on the microcontroller hardware. The user is presented with an interactive prompt (the REPL) to execute supported commands immediately. Included are a selection of core Python libraries; MicroPython includes modules that give the programmer access to low-level hardware.


MakePython ESP32 Board

As already explained above, we will first need an ESP32 Board. So I purchased an ESP32 Board specially designed for using Micropython from MakePython ESP32 Board from MakerFabs.

ESP32 MakePython

MakePython ESP32 Board has the same ESP32 Chip from espressif. The advantage of this board over the normal ESP32 Board is that, the board has an additional 0.96″ OLED Display added to it.

MakePython ESP32 is a powerful, generic Wifi+ BLE MCU module target to MicroPython learners & developers. It is true “breadboard compatible”, with the very detailed pins explanation, it is easy to learn & use. The MakePython ESP32 is programmed with MicroPython by default, users can begin the MicroPython developing as getting then on hand.

MakePython ESP32 Pins

The complete pin description and detail about this board can be found here: MakePython ESP32 Description. You can even purchase the board from the same link.




Getting Started with MicroPython on ESP32 using uPyCraft IDE

The section covers:
1. Installing Python 3.8.x on Windows/MAC
2. Installing uPyCraft IDE
3. Flashing the MicroPython Firmware (Bin File) on MakePython ESP32 Board
4. Writing Python Code and uploading the code on ESP32 using uPyCraft IDE
5. Blinking of LED
6. Controlling the LED using Web Server

Step 1: Installing Python 3.8.x on Windows

MicroPython is an implementation of Python so we first need to install Python 3.8.x or above. To install Python 3.8.x download Python from https://www.python.org/downloads/

.

Python Installation

After downloading Python 3.8.x, you need to install it.

Once the installation is completed, you can close the installation window.

Step 2. Installing uPyCraft IDE

There are only a few IDEs that support MicroPython like Thonny IDE and uPyCraft IDE. Thonny IDE does not have an option to flash MicroPython firmware on ESP32 but the uPyCraft IDE has inbuilt functionality to flash firmware, programming and uploading the code in ESP32 board.

Go to this link: uPyCraft IDE Download & download the uPyCraft IDE.

After downloading, you can simply click the .exe and the following window will open.

Now Let’s have a closer look at the uPyCraft IDE and its 4 sections. All the 4 sections have its own importance.

1. Folders and files:
This section contains files and folders like Device, SD Folder, uPy_Lib & Workspace. The device folder contains the files stored in the ESP board including boot.py or main.py. SD folder contains the files stored in the SD card. uPy_lib contains in-built MicroPython IDE libraries. The workspace contains the files that will be saved on your PC.​

2. Editor Window:
This section is for writing and editing the python code. Multiple python files can be opened in Editor.

3. Tools:
This section contains options for creating a new file, saving the file, uploading the file, connecting/disconnecting the board, clearing shell.

4. MicroPython Shell/Terminal:
This section is for writing and executing the shell commands on the ESP board. This section also shows the status of the program, errors & print messages.



Step 3: Flashing the MicroPython Firmware (Bin File) on MakePython ESP32 Board

Now we need to flash firmware to ESP32 Board so that it can support MicroPython. Visit this link: https://micropython.org/download/esp32/ and download the .bin file as shown in the image below. Choose the stable version.

After downloading the firmware, we need to upload it to ESP32 Board using uPyCraft IDE. So first connect the ESP32 Board to your PC using Micro-USB Data Cable.

ESP32 Micropython upycraft

Now open the uPyCraft IDE and Select Tools >>>Burn Firmware.

Choose the following options shown in the image below. Select the bin file that you downloaded recently (explained above). And then click on OK.

So the firmware will start uploading. In some ESP32 boards, you need to press the boot button to get the process started.

Once the uploading is done, the window will close automatically.

Step 4. Writing Python Code and uploading the code on ESP32 using uPyCraft IDE

1. Now click on File and create a new file with name main.py or give it any other name.

2. Then, go to Tools->boards. Choose your board as esp32

3. Again go to tools-> Serial and choose your COM port.

4. Now, click on the connect icon in the Tools section to make the connection between IDE and ESP32 board.




ESP32 LED Blinking with MicroPython using uPyCraft

Now let us do the first getting started program. For that connect the LED to GPIO5 Pin of MakePython ESP32 Board.

ESP32 MicroPython Getting Started LED blinking

Copy the following MicroPython Code and upload it to the ESP32 Board by clicking on the download button.

1
2
3
4
5
6
7
8
9
import time
from machine import Pin
led=Pin(5,Pin.OUT)          #create LED object from pin5,Set Pin5 to output
 
while True:
  led.value(1)              #turn off
  time.sleep(0.5)
  led.value(0)              #turn on
  time.sleep(0.5)

ESP32 MicroPython uPyCraft LED Blink Code

As soon as you hit the download button, you can view the details in Python shell as shown in the above image. Similarly, the connected LED will start blinking.

ESP32 MicroPython uPyCraft LED Blink


ESP32 Micropython: Controlling LED using Web Server

Now let us design a small webpage and control the turning ON & OFF of LED using Web Server. You can follow ESP32 Web Server Tutorial if you want to learn more about the Web Server.

Copy the following MicroPython Code and upload it to the ESP32 Board by clicking on the download button again. In the below code change the credentials for wifi SSID & Password.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#webserver.py
import network
import webrepl
import time
from machine import Pin
try:
  import usocket as socket
except:
  import socket
 
AUTH_OPEN = 0
AUTH_WEP = 1
AUTH_WPA_PSK = 2
AUTH_WPA2_PSK = 3
AUTH_WPA_WPA2_PSK = 4
 
SSID = "************"      #Modify here with SSID
PASSWORD = "*************"   #Modify here with PWD
led = Pin(5, Pin.OUT)
 
def web_page():
  html = """<html><head><meta name="viewport" content="width=device-width, initial-scale=1"></head>
  <body><h1>ESP32 Web Server</h1><a href=\"?led=on\"><button>OFF</button></a>&nbsp;
  <a href=\"?led=off\"><button>ON</button></a></body></html>"""
  return html
 
def do_connect(ssid,psw):
    #import network
    #import time
 
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    s = wlan.config("mac")
    mac = ('%02x:%02x:%02x:%02x:%02x:%02x').upper() %(s[0],s[1],s[2],s[3],s[4],s[5])
    print("Local MAC:"+mac) #get mac
    wlan.connect(ssid, psw)
    if not wlan.isconnected():
        print('connecting to network...' + ssid)
        wlan.connect(ssid, psw)
 
    start = time.ticks_ms() # get millisecond counter
    while not wlan.isconnected():
        time.sleep(1) # sleep for 1 second
        if time.ticks_ms()-start > 20000:
            print("connect timeout!")
            break
 
    if wlan.isconnected():
        print('network config:', wlan.ifconfig())
    return wlan
 
def connect():
do_connect(SSID,PASSWORD)
 
def app():
  connect()
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind(('', 80))
  s.listen(5)
  while True:
    conn, addr = s.accept()
    print('Got a connection from %s' % str(addr))
    request = conn.recv(1024)
    request = str(request)
    print('Content = %s' % request)
    led_on = request.find('/?led=on')
    led_off = request.find('/?led=off')
    if led_on == 6:
      print('LED ON')
      led.value(0)
    if led_off == 6:
      print('LED OFF')
      led.value(1)
    response = web_page()
    conn.send('HTTP/1.1 200 OK\n')
    conn.send('Content-Type: text/html\n')
    conn.send('Connection: close\n\n')
    conn.sendall(response)
    conn.close()
 
app()

After code is successfully downloaded, you can see the ESP32 Board connecting to the network in the uPyCraft Shell. Similarly the IP Address of the Board will also be displayed.

ESP32 MicroPython uPyCraft Web Server

Copy the IP Address and paste it on any web browser. So the page will open as shown below.

ESP32 MicroPython Web Server

You can now send ON Command or OFF Command to Turn ON or Turn OFF the LED respectively.

LED Control MicroPython



Video Tutorial

Episode 1: MicroPython on ESP32 using uPyCraft IDE - Getting Started Tutorial
Watch this video on YouTube.

Well that’s all from the ESP32 MicroPython uPyCraft Getting Started Tutorial. If you have any further queries, feel free to comment down below.

You can follow these projects using MicroPython with ESP32 Board:
1. Interfacing 0.96″ OLED Display With ESP32

2. Interfacing DS18B20 Temperature Sensor with ESP32 & OLED

3. ESP32 MicroPython Web Server – Sensor Data on Webpage

4. ESP32 with DHT11 Humidity Temperature Sensor

5. Interfacing Ultrasonic Sensor with ESP32 using MicroPython

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleDIY 3.7V to 5V Boost Converter for Lithium-Ion Battery
Next Article Flex Sensor & Arduino Interfacing – Measure Bend/Resistance

Related Posts

LoRa Soil Moisture

LoRa Based Soil Moisture Monitoring on LoRa ESP32 WebServer

Updated:August 20, 202223K
ESP32 MicroPython - Interfacing Ultrasonic Sensor HC-SR04

ESP32 MicroPython – Interfacing Ultrasonic Sensor HC-SR04

Updated:August 21, 20224K
MicroPython ESP32 DHT11

MicroPython: ESP32 with DHT11 Humidity Temperature Sensor

Updated:August 22, 202213K
ESP32 MicroPython Web Server

ESP32 MicroPython Web Server – Sensor Data on Webpage

Updated:August 21, 202227K
MicroPython DS18B20 ESP32

MicroPython: Interfacing DS18B20 Temperature Sensor with ESP32

Updated:August 21, 20228K
ESP32 OLED DisplayMicroPython

MicroPython: Interfacing 0.96″ OLED Display with ESP32

Updated:May 26, 20234K
View 4 Comments

4 Comments

  1. steve on December 26, 2020 2:49 PM

    why doesn’t the ESP32 keep the program like other microcontrollers?
    is there a separate step to compile and load it onto the chip so it runs without being attached via USB to the PC?

    Reply
  2. Alberto on December 27, 2020 2:48 AM

    Save the file like main.py. If you want keep the program in the ESP32 download the file like main.py !

    Reply
  3. Alberto on December 27, 2020 2:54 AM

    I have find solution today ! Save the file download with the name main.py .

    Reply
  4. Ronald Foth on March 13, 2023 6:31 PM

    Is there anybody to help me?

    Downloading the above webserver.py example program I get the the following messages in the status window:

    download ok
    exec(open(‘webserver.py’).read(),globals())
    Local MAC:CC:DB:A7:41:07:84
    E (3881771) wifi:sta is connecting, return error
    Traceback (most recent call last):
    File “”, line 1, in
    File “”, line 81, in
    File “”, line 56, in app
    File “”, line 53, in connect
    File “”, line 36, in do_connect
    OSError: Wifi Internal Error

    for better understanding:
    line 36: wlan.connect(ssid, psw)
    line 53: do_connect(SSID,PASSWORD)
    line 56: connect()
    line 81: app()

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • Half Wave Rectifier Basics, Circuit, Working & Applications
    Half Wave Rectifier Basics, Circuit, Working & Applications
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.