000 – ESP32 MicroPython: How to Get Started with MicroPython

In this article you will learn how to get started with MicroPython explorations. We will begin to learn to install first a Thonny Python IDE for developing MicroPython codes for development board of your choice. I will be using an ESP32 development board.

Instructions:
1. Download the Thonny Python IDE at:
Download Thonny Python 
This is one of the best, beautiful, and beginner-friendly IDE available. We will also use Thonny Python to erase and flash new firmware to ESP32 with the help of esptool pluggins.

2. Download the MicroPython firmware from:
Download Firmware at MicroPython.org
Go to download section and look for your development board. Choose the stable bin file for your board.

3. Download the ESP32 USB driver at:
Download ESP32 USB driver

4. Download some references files for your development board like pinouts and schematic diagram.

5. Install Thonny Python

6. Install the ESP32 USB driver

7. Flash a new firmware to ESP32 using the Thonny Python.

Video Demonstration:

If you find this tutorial as helpful, please take time to share it so that it can reach more people who might benefited from this.

Please kindly support me by Subscribing to my Youtube channel: Click this to SUBSCRIBE to TechToTinker



Source Code:

Example 1, Turn ON or turn OFF the onboard LED


# Load the 'machine' module to access the hardware
import machine

# Create an 'led' object in pin 2
# and set the pin direction to output
led = machine.Pin(2, machine.Pin.OUT)

# This turns on or turns off the 'led'
led.on()
led.off()

# This is the same as the above code
# but now we are passing a value
led.value(1)
led.value(0)

# This is the same as the above code
# as you already know
#	1 = True
#	0 = False
led.value(True)
led.value(False)

Example 2, Blink the onboard LED


# Load the 'machine' module to access the hardware
import machine

# Load the 'time' module which includes the 'sleep' class
import time

# Create an 'led' object in pin 2
# and set the pin direction to output
led = machine.Pin(2, machine.Pin.OUT)

# Create an eternal loop that blinks the LED
# time.sleep(0.5) creates a 0.5 second delay
# or 500 milli seconds
while True:
    led.on()
    time.sleep(0.5)
    led.off()
    time.sleep(0.5)
    

8 thoughts on “000 – ESP32 MicroPython: How to Get Started with MicroPython

  1. hello , help please, I have esp32-s3 and priogramming with Thonny .
    Programming is OK , but in shell I have continuos " invalid header:0xfffffff

  2. Hi Guys
    I did every thing as explained but when I lunched Thonny and tried to install esptools
    I got the message
    Device is busy or does not respond. Your options:
    I did evey thing; tried to reinstall with no result below is terminal output
    ts Jul 29 I Speed : 40MHz
    I (43) boot.esp32: SPI Mode : DIO
    I (48) boot.esp32: SPI Flash Size : 4MB
    I (52) boot: Enabling RNG early entropy source…
    I (58) boot: Partition Table:
    I (61) boot: ## Label Usage Type ST Offset Length
    I (68) boot: 0 phy_init RF data 01 01 0000f000 00001000
    I (76) boot: 1 otadata OTA data 01 00 00010000 00002000
    I (83) boot: 2 nvs WiFi data 01 02 00012000 0000e000
    I (91) boot: 3 at_customize unknown 40 00 00020000 000e0000
    I (98) boot: 4 ota_0 OTA app 00 10 00100000 00180000
    I (106) boot: 5 ota_1 OTA app 00 11 00280000 00180000
    I (113) boot: End of partition table
    I (118) boot_comm: chip revision: 3, min. application chip revision: 0
    I (125) esp_image: segment 0: paddr=00100020 vaddr=3f400020 size=295d8h (169432) map
    I (195) esp_image: segment 1: paddr=00129600 vaddr=3ffbdb60 size=04474h ( 17524) load
    I (202) esp_image: segment 2: paddr=0012da7c vaddr=40080000 size=0259ch ( 9628) load
    I (206) esp_image: segment 3: paddr=00130020 vaddr=400d0020 size=111630h (1119792) map
    I (614) esp_image: segment 4: paddr=00241658 vaddr=4008259c size=1b568h (111976) load
    I (660) esp_image: segment 5: paddr=0025cbc8 vaddr=400c0000 size=00064h ( 100) load
    I (661) esp_image: segment 6: paddr=0025cc34 vaddr=50000000 size=00010h ( 16) load
    I (681) boot: Loaded app from partition at offset 0x100000
    I (681) boot: Disabling RNG early entropy source…
    module_name:WROOM-32
    max tx power=78,ret=0
    2.4.0

    Device is busy or does not respond. Your options:

    – wait until it completes current work;
    – use Ctrl+C to interrupt current work;
    – reset the device and try again;
    – check connection properties;
    – make sure the device has suitable MicroPython / CircuitPython / firmware;
    – make sure the device is not in bootloader mode.

Leave a Reply to George Bantique Cancel reply

Your email address will not be published. Required fields are marked *