MicroPython with the ESP32

MicroPython is a high-level programming language specifically designed for microcontrollers and resource-limited embedded devices. Think of MicroPython as "Python for Microcontrollers".

Want to learn a new technology? You will need three things:

Quality educational Content

Learning from the best available sources can make a huge difference in how quickly and how well you can master whatever it is that you want to learn. Excellent educational sources will not only teach you well and fast; they will also delight you.

Be an Active Learner

Technology education is hands-on.

The only way to truly learn something new is by executing your own simple experiments.

Each experiment is an opportunity to learn a new skill, capability, tool, or feature.

Work on Realistic Projects

Once you have acquire a few new skills, how can you consolidate your knowledge so that you can create a fully working machine, like a robot or a plant incubator? Project work is your opportunity to bring together everything you learned into a single activity.

Why learn MicroPython?

Micropython is a high-level language for embedded devices. It uses the syntax, structure, and conventions of the Python language, but is light enough to fit and work in devices that are constrained by memory and computing resources.

If you already know Python, then you will be able to use this knowledge to program devices like the ESP32. With MicroPython, you do not need to learn a low-level language, like C or C++, that are traditionally used in microcontroller programming. 

This is the biggest draw card for MicroPython.

MicroPython highlights

  • A lean and efficient implementation of Python 3.
  • Optimised to run on microcontrollers and in constrained environments.
  • Works on many microcontrollers, including the original Pyboard, ESP32 and ESP8266, Raspberry Pi Pico, and more.
  • Multiple SPI, I2C, UART and I2S
  • On-device REPL interactive prompt.
  • Easy to learn, especially if you already know Python.
  • Excellent documentation and community support.
  • Excellent and free development tools.
  • Comprehensive standard library and open-source code packages.
  • Support for many architectures (x86, x86-64, ARM, ARM Thumb, Xtensa) so that your code is highly portable.

Getting Started with MicroPython on the ESP32

This guide will help you learn how to use MicroPython on the ESP32. There is a custom and highly optimized version of MicroPython specifically developed for the ESP32 that exposes almost the entirety of the MCU's hardware resources to your MicroPython programs. The lessons below will help you get started.

Introduction to MicroPython with the ESP32: What is MicroPython?

Peter Dalmaris

The Guides in this series are dedicated to MicroPython for the ESP32. In this first lesson, I will introduce you to MicroPython, its reason to exist, how it relates to Python, and its most important characteristics.

MicroPython vs CPython

Peter Dalmaris

In this lesson, I will discuss some of the differences between MicroPython and CPython that I believe are most important to know when you are getting started with MicroPython.

Micropython uPython Resources title image

MicroPython Resources

Peter Dalmaris

In this lesson, I will discuss MicroPython Resources that will save you time and help you to learn faster.

MicroPython compatible boards

Peter Dalmaris

In this lesson, I will discuss some of the microcontroller boards that are compatible with MicroPython. As you'll see, there's a huge variety to choose from.

Getting started with the Thonny IDE

Peter Dalmaris

In this lesson, I will discuss the Thonny IDE, an open-source integrated development environment that we'll be using to program the ESP32 using MicroPython.

How to write and execute a MicroPython program

Peter Dalmaris

In this lesson, I will show you how to write and execute a simple MicroPython program. I'll do this with Thonny IDE in two different ways.

Thonny IDE with the Raspberry Pi Pico

Peter Dalmaris

In this lesson, I will demonstrate how to use Thonny IDE and MicroPython on a Raspberry Pi Pico.

Thonny IDE with BBC micro:bit

Peter Dalmaris

In this lesson, I'll show you how to run a simple MicroPython program on the BBC micro:bit that scrolls text on the device's 5 by 5 bitmap display.

Thonny IDE Advanced configuration

Peter Dalmaris

In this lesson, I'd like to show you the advanced configuration file of Thonny IDE so that you may modify some of the functionality and that is not possible to do via graphical user interface.

Find Python Packages at PyPI

Peter Dalmaris

PyPi is a repository of Python and MicroPython packages. You can search PyPi from Thonny IDE and install packages with a single click. In this lesson I'll show you how.

The MicroPython shell

Peter Dalmaris

In this lesson I'll show you a couple of ways to interact with the MicroPython Shell and run interactive programs or execute programs that are already stored on the ESP32 file system.

MicroPython Programming with files

Peter Dalmaris

In this lesson I will show you how to split your MicroPython programs into multiple files so that you can better organize your code.

How to interrupt a running program

Peter Dalmaris

In this lesson, I'll show you how to interrupt a running program and how to restart your ESP32 using soft reset.

How to run a program at boot

Peter Dalmaris

In this lesson, I'll show you how to set your ESP32 to execute a program when it powers up or when you press the reset button.

How to debug a MicroPython program

Peter Dalmaris

In this lesson, I will show you a few techniques you can use to debug and troubleshoot your MicroPython scripts.

A comprehensive course for people new to MicroPython

Now that you have learned the basics of the MicroPython programming language on the ESP32, it is time to take the next step.

I have designed three courses that can help you do that.
MicroPython with the ESP32 introduce you to the MicroPython programming language, tech you how to use MicroPython with common external devices and help you consolidate this knowledge with two cap-stone projects.

This course is for anyone looking for the easiest (yet still powerful) way to program a micro-controller.

Familiarity with Python is not necessary - with this course you will learn everything you need.

If you already know Python, then this course will help you get started with MicroPython and use it to program the ESP32.

Why learn with Tech Explorations?

Thousands of students have already taken our video courses to learn how to use MicroPython with the ESP32.

Video on demand

With our video courses, it's like having a tutor showing you how to create circuits and write programs, one step at a time.

Help is here

If you need help, you can use our Community spaces tool to ask your questions, available in each lecture.

Keep calm and learn

Learn in a calm, distraction-free environment. No advertisements, no cat and dog videos to break your concentration. Just learning.

Let's make something together

Hi, I’m Peter.

I am an online educator and Maker, author of Maker Education Revolution, KiCad Like a Pro, and founder at Tech Explorations.

I create all the content on the Tech Explorations website. 

Why? Because, as I already mentioned, I'm an educator and a Maker, and I have a Mission.

My mission is to help people learn electronics, programming, printed circuit board design, and lots more. Most importantly, I want to help as many people as possible to enjoy their technology education adventures.

After a 15 year career as a University Lecturer, I decided to become a Maker, again. Like most of us, as a child, I was curious, and I learned how things worked by experimenting with them (usually, this meant taking them apart and hoping to not loose any screws as I was putting things back together). 

Growing up, I became an Engineer, only to loose my childish curiosity in the name of pursuing a career. 

I became a child again once I got my first Arduino. With it, I started creating thing, tinkering with components, testing ideas. Even though I was a "career educator", it was only now that I realised how wrong my last 15 years of education had been. I was partly responsible for destroying the creativity of thousands of students, just like mine had been destroyed in the name of being a "proper adult".

At Tech Explorations, my job is to learn and to create. I learn what I am curious about, and I create educational content. This content is the record of my learning.

I don't create this content to teach "students". I create it to help learners learn things that they want to learn. 

At the end of the day, we are all learners, and we learn from each other.

I sincerely hope that through the content I create at Tech Explorations, as many people as possible will be inspired to re-kindle their childhood curiosity, learn, and create amazing things.

Learning is social

The Internet has brought a revolution in publishing and learning. It is the biggest repository of knowledge that has ever existed, and it is getting exponentially bigger. For anything you want to learn, there's a good chance that someone has written a blog post or created a video about it.

Perfect! Well, not exactly. While there is a lot of great content out there, much of what is available on the Internet lacks quality, and most important, lacks the human connection.  

The best learning is social. When you communicate with others that have been where you are now, you learn faster and better. You have someone to fall back when you need help, or discuss an idea when you are stuck. 

At Tech Explorations, we support our students through our community tools because we know that this is the best way to learn and teach.

Helping is part of learning

Learning new skills and technologies is a journey into uncharted territory. It is much better if you have a map, and even better if you can "radio in" for help. 

At Tech Explorations, we have made a big investment in our communication tools to make sure that no student is left behind. We have three levels of Support: Community Discussion Forums for each course, lecture-level Questions and Answers tool, and a Help Desk. 

Our content is live and monitored by our team so that we can respond to student questions quickly. Speed is important because learning obstacles can have a devastating effect in our learning process, so we try our best to help our students smash through them.

Stay Calm And Keep Learning

The world and the Internet are extremely noisy places. Many "free" earning resources operate more like noisy open-air bazaars, with annoying distractions that aim to stop you from doing what you want to do (to learn something new) so that you can click on the next video (often about a cat doing a funny trick). 

The loss of concentration alone accumulates to many hundreds of hours of lost learning productivity per learner per year. 

Would you be able to learn how to program the Arduino in the food court of a shopping center? In a way, that's what many of us are doing.

At Tech Exploration, we have created a calm environment that is appropriate for immersive learning. Concentrate, turn off your mobile phone, start the lecture video, and follow on with the experiment. 

That's all. Nothing else should compete for your attention.

The Path Forward

In this page we have given you lots of free and quality learning content, opportunities for hands on experimentation, and even larger projects that you can use to consolidate your learning. All that in a calm, learner-friendly environment.

A question I get a lot is "What should I do next?"

People that have just learned a new skill, like how to make an LED blink or spin a motor, are often overwhelmed. They have just grasp something new, but are having a hard time figuring out what is next.

It is totally understandable, and I have been there myself. In fact, I feel like that every time I learn a new thing, isolated from its possibilities.

Think about this: you just learned how to spin a motor. How can you build a robot out of that? What is the process of going from a single working component, to a system that brings together many components, into a working gadget?

The best answer I can give to this question is this simple process, plus a lot of perseverance (you need it when you decide to pursue something important):

  1. You need a project that excites you. This project gives you a goal, and even a path (although the path is not clear in the beginning). Think about what the project is about, and especially what it is supposed to do. This ("what is it supposed to do") is what gives you your project goal. You will need this for step 5 of this process.
  2. You need to analyse your project and break it down to its components. A robot is made of motors, motor controllers and microcontrollers, sensors, software, and a frame to hold everything together. Figure out what are main components in your project.
  3. Based on you analysis, figure out your level of knowledge in relation to the project components. You may have a good grasp of motors but lacking in sensor. 
  4. Plan your prototyping process. This part of the process is critical, because you have to make several decision, that involve the hardware, software, and assembly of the gadget, but also the learning that you have to engage in in order to make this possible. You don't need to know everything before you begin, but you need to choose a place to begin. If you were to build a wheeled robot, for example, you could start with the wheel and motor assembly so that your robot can move, and leave the sensors for later. Why? Because you know how to use motors now. You can learn how to use sensors later. Like so many things in life, beginning is half of everything you do. The first iteration will give you the momentum and confidence you need to go for the second, third, until the last iteration.
  5. Repeat until the project is complete. The iterative process of prototyping is your guide. Each iteration solves problems and creates new ones. The new problems usually demand that you learn something new. Go on, learn it, and come back to continue with the current iteration. The project is complete when you have achieved the goal that you set in step 1. But here's the catch: In prototyping, like in life, everything is fluid. Your original goal was based on early assumptions of what you wanted to achieve, before you had actually done any work towards that goal. In the process of working towards your goal, the goal changes! Be mindful of that, and know that it is Ok. Enjoy the process, and the achievement of the result.

This is the process that I follow with my projects, including my books and my courses. Over time, you will become better at picking projects and especially analysing them so that what you eventually create is very close to your original goal.

The only way to build up your project management and gadget building skills is to do it.

And we are here to help you 🙂

Join the Tech Explorations Insiders

Want to make sure that you get notified when I release my next article or video? Then sign up below to join my list of Tech Explorations Insiders.

You'll receive email notifications whenever I release new content plus you'll get access to insiders-only updates that aren't published on the site!

We never spam, and you can unsubscribe at any time.

By submitting this form, you agree to receive educational and promotional announcements from Tech Explorations. Your personal details will not be shared with anyone outside of Tech Explorations, and you may unsubscribe at any time.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}