MicroPython with the ESP32
The easiest way to write programs for the ESP32 microcontroller.
Description
Last Updated in June and July 2022 to cover the latest versions of the Thonny editor (version 4) and MicroPython firmware (version 1.18+).
More details about this update: I have introduced new lectures to show you how to install and use Thonny 4, and how to upgrade your ESP32 devkit and Raspberry Pi Pico boards to use the MicroPython 1.18 firmware.
I have also tested all experiments to ensure that they work with these versions of Thonny and MicroPython.
If you are using an ESP32 board that is unable to automatically enter upload mode, you will find a solution in a new lecture in Section 3.
-------------------------
With this course, you will learn how to use MicroPython with the ESP32 microcontroller.
MicroPython is a high-level programming language specifically designed for microcontrollers and resource-limited embedded devices.
Who is this course for?
I have created this course for three types of students:
If you are familiar with Python, you will find that MicroPython looks, feels, and works like regular Python. This course will help you get started quickly, and help you out with the peculiarities of using Python as MicroPython operating on the ESP32 hardware.
If you have little programming experience, MicroPython is a perfect option for learning how to program hardware. This course will help you learn enough MicroPython to be able to write programs that run on the ESP32 microcontroller.
If you have experience in programming the ESP32 with the Arduino IDE and language, but what to check out MicroPython, this course will help you do that.
What is MicroPython?
MicroPython is a programming language that borrows the syntax and language attributes of Python 3.
Python 3 is a powerful high-level general-purpose language that is designed to be easy to learn and use. It is extremely popular, and among the top-5 most widely used programming languages. As a result, has an extensive set of learning resources, excellent documentation, and code libraries that cover an amazing breadth of applications.
From gaming to the Internet of Things, from data science to industrial automation, anything that can be programmed in Python.
MicroPython was modelled after Python to reduce the barrier to entry for people that want to write programs for microcontrollers or embedded devices that have limited resources.
What is the ESP32?
The ESP32 is a powerful yet low-cost microcontroller device from Espresif.
The appeal of the ESP32 device is that it packs a powerful dual-core CPU, with relatively large amounts of RAM and flash storage, a full complement of wireless and wired communications options, with lots of input/output pins in a small low-cost package.
The ESP32 is also versatile, as you can program it with a variety of programming tools and languages, including the Arduino IDE, and, of course, MicroPython.
I selected the ESP32 as the hardware for this course because it is easy to find in the market, very affordable considering its capabilities, and, most likely, most people interested in microcontrollers already have at least one.
What are the objectives of this course?
This course has 3 main objectives:
To introduce you to the MicroPython programming language, even if you have little or no prior experience.
To help you learn how to use MicroPython with common external devices, like motors and screens, with MicroPython programs running on an ESP32 microcontroller.
To consolidate this knowledge with the help of two capstone projects. In these projects, you will create a working gadget by combining the knowledge you acquired earlier in the course.
What are the knowledge prerequisites?
Before embarking on this course, please confirm that you tick the following boxes:
You have a basic understanding of electronics. You are comfortable with assembling simple circuits on a breadboard, and you understand simple concepts like pull-up resistors and voltage dividers.
You have a basic understanding of microcontrollers. For example, you know what is a GPIO, the I2C or SPI interfaces and PWM. You understand that if you connect a 3.3V device to a 5V power source, you will damage the device.
You are familiar with related concepts, such as the Internet Of Things (which features in one of the course sections).
You are comfortable with at least one programming language and programming tool. It doesn’t matter which ones, as all modern languages and programming share the same basics.
You have a growth mindset, and you are willing to work hard in order to learn.
If you feel that you don’t tick one of these boxes, consider doing one of my introductory Arduino and Electronics courses first. Then you’ll be ready to come back to this course.
Course organization
This course is organised in four parts.
In the first part, you will learn the basics. This is where you’ll learn how to set up and use Thonny, our programming editor, and prepare your ESP32 to work with MicroPython.
You will also have the opportunity to learn the basics of MicroPython and where and how to find compatible libraries.
The second part is where you roll up your sleeves and write MicroPython programs. You’ll start with simple pin operations that make LEDs blink and read buttons, then move on to sensors, displays, and motors. There’s a large section dedicated to Wifi and Internet of Things applications, and another section dedicated to more advanced topics such as hardware timers, working with internal sensors, and sleep.
In the third and final part, you will consolidate your new knowledge with the help of two capstone projects. Both projects combine the same hardware components with one big difference in the software. While in the first project, all of the MicroPython code exists in the same file, in the second project I show you how to modularise the design and break up the code into two files.
Required software and hardware
For details on the required software and hardware, I have prepared two separate lectures in this section, which I invite you to watch next.
But, in summary:
For the software, you will the Thonny programming tool, and the MicroPython firmware for the ESP32. Both are open-source and free
For the hardware, you will need an ESP32 board, and an assortment of common components like LEDs, resistors, sensors and motors. It doesn’t matter which ESP32 board you have. As long as it is an ESP32, it will work with MicroPython.
If you have taken one of my Arduino courses, you probably already have everything you need.
For the details, please refer to the two lectures in this section where I go into the details for the required software and hardware.
Ok, what's next???
I hope that you now have a good understanding of what this course is about and what to expect ahead.
The first section contains several free lectures with more detailed information about the course. Feel free to watch them if you wish before enrolling.
Happy Learning!
What You Will Learn!
- The MicroPython programming language.
- How to use MicroPython with the ESP32 microcontroller.
- How to use the Thonny editor with MicroPython and the ESP32.
- How to use MicroPython with common peripherals such as motors, displays and sensors.
- How to use MicroPython to write programs that work with IoT services like IFTTT.
- How to search, find and install MicroPython libraries on the ESP32.
Who Should Attend!
- People that are familiar with Python that want to program microcontrollers.
- People with little programming experience but familiar with basic electronics.
- People with experience in the ESP32 using the Arduino IDE.