There are different firmwares that you can use to program the ESP32 boards. If you want to program the ESP32 board using the MicroPython firmware, we recommend using uPyCraft IDE/Thonny IDE. uPyCraft IDE runs in any major operating system. here we’ll show you how to install the uPyCraft IDE for MicroPython on a Windows PC.
Before installing uPyCraft IDE, make sure you have the latest version of Python installed in your computer. If you don’t, follow the next instructions to install Python.
you can buy Bharat Pi boards on Bharat pi website --> https://bharatpi.net/shop/ , AND on Amazon website.
-
Go to the Python Downloads page: www.python.org/downloads and download the installation file.
-
After a few seconds, you should have a file called python-3.12.1.exe file in your computer. Double-click the file to open it.
-
Enable the option at the bottom "Add Python 3.12 to PATH". Then, press the “Install Now” button.
-
Wait a few seconds while the software completes the installation process....
-
When it’s done, you should see the message "Setup was successful" then you can close that window.
As mentioned before,we’ll be using uPyCraft IDE to program the ESP32 or ESP8266 boards using the MicroPython firmware. In our opinion, uPyCraft IDE is the easiest way of programming ESP based boards with MicroPython at the moment.
-
To download uPyCraft IDE for Windows go to this link https://randomnerdtutorials.com/uPyCraftWindows.
-
After a few seconds you should see a similar file (uPyCraft_V1.exe) in your Downloads folder Double-click that file.
-
A new window opens with the uPyCraft IDE software, We’ll be using this software to flash our ESP based boards with MicroPython firmware as well as to program the boards.
With uPyCraft IDE installed in your computer, you can easily flash your ESP32 boards with the MicroPython firmware.
-
To download the latest version of MicroPython firmware for the ESP32, go to the MicroPython Downloads page https://micropython.org/download/ and scroll all the way down to the ESP32 section select ESP32/WROOM
-
Download the ESP32.bin file – for example: esp32-20181007-v1.9.4-631-g338635ccc.bin.
Go to Tools > Serial and select your ESP32 COM port.
Important: if you plug your ESP32 board to your computer, but you can’t find the ESP32 Port available in your uPyCraft IDE, it might be one of these two problems: 1. USB drivers missing OR 2. USB cable without data wires.
-->goto this link and dowload the drivers from here for our BharatPi boards-> https://wch-ic.com/downloads/CH341SER_ZIP.html
-
If you don’t see your ESP’s COM port available: --> This means you don’t have the USB drivers installed. Take a closer look at the chip next to the voltage regulator on board and check its name. --> after checking the name Go to Google and search for your specific chip to find the drivers and install them in your operating system. --> After they are installed, restart the uPyCraft IDE and you should see the COM port in the Tools menu.
-
If you have the drivers installed, but you can’t see your device, double-check that you’re using a USB cable with data wires: USB cables from powerbanks often don’t have data wires (they are charge only). So, your computer will never establish a serial communication with your ESP32. Using a proper USB cable should solve your problem.
Go to Tools > Board > so make sure you select the "esp32" option:
-
Finally, go to Tools > BurnFirmware menu to flash your ESP32 with MicroPython.
-
Select all these options to flash the ESP32 board: --> board: esp32 --> burn_addr: 0x1000 --> erase_flash: yes --> com: COMX (in our case it’s COM4) --> Firmware: Select "Users" and choose the ESP32 .bin file downloads After pressing the "Choose" button, navigate to your Downloads folder and select the ESP32.binfile.
-
Having all the settings selected, hold-down the "BOOT/FLASH" button in your ESP32 board.
-
While holding down the "BOOT/FLASH", click the "ok" button in the burn firmware window.
-
When the "EraseFlash" process begins, you can release the "BOOT/FLASH" button. After a few seconds, the firmware will be flashed into your ESP32 board.
Note: if the "EraseFlash" bar doesn’t move and you see an error message saying "erase false/update false", it means that your ESP32 wasn’t in flashing mode. You need to repeat all the steps described earlier and hold the "BOOT/FLASH" button again to ensure that your ESP32 goes into flashing mode.
NOTE:if you are not able to download the PyCraft IDE(it will not support for some windows) we have alternative for that i.e Thonny IDE
If you want to program your BharathPi ESP32 board with MicroPython firmware, it’s very handy to use an IDE in this guide, we’ll introduce you to Thonny IDE. We’ve experimented with several IDEs to program the ESP32 boards using MicroPython, and Thonny seemed a good choice. Although there are some bugs, it is constantly being updated and improved. It allows you to program your ESP32 boards with MicroPython, and it is compatible with Windows, Mac and Linux.
you can buy Bharat Pi boards on Bharat pi website --> https://bharatpi.net/shop/ , AND also on Amazon website.
MicroPython is a Python 3 programming language re-implementation targeted for microcontrollers and embedded systems. MicroPython is very similar to regular Python The most significant difference between Python and MicroPython is that MicroPython was designed to work under constrained conditions. Because of that, MicroPython does not come with the entire pack of standard libraries and few exceptions. It only includes a small subset of the Python standard libraries, but it includes modules to easily control and interact with the GPIOs, use Wi-Fi, and other communication protocols.
To install Thonny on your Windows PC, follow the next instructions:
- Go to https://thonny.org
-
Download the latest version for Windows and wait a few seconds while it downloads.
-
Run the .exe file.
-
Follow the installation wizard to complete the installation process. You just need to click on Next.
-
After completing the installation open Thonny IDE a page should open like below shown.
MicroPython isn’t flashed into the ESP32 boards by default. The first thing you need to do is to start programming your boards with MicroPython flash/upload/burn the firmware.
There are different ways in which you can do that: Thonny IDE comes with a tool that allows you to quickly install MicroPython firmware on your board.
- To download the latest version of MicroPython firmware for the ESP32, go to the MicroPython Downloads page https://micropython.org/download/ and scroll all the way down to the ESP32 section.
- Select the type of board you’re using select ESP32/WROOM.
You should see a similar web page (see figure below) with links to download .bin files. Download the latest release.
The downloaded file will go to the Downloads folder, Continue reading to learn how to flash the firmware on your boards.
In this section you’ll learn how to flash MicroPython firmware on your boards using Thonny IDE, Follow the next steps:
-
Connect your BharatPi ESP32 board to your computer.
-
Open Thonny IDE, Go to Tools -> Options -> Interpreter.
-
Select the interpreter you want to use accordingly to the board you’re using and select the COM port your board is connected to and Finally, click on the link Install or update firmware.
- Select the port once again, select the options as shown in the picture below and finally click on Install.After a few seconds, the installation should be completed. (OR) You can click on the Browse button to open the ".bin" file with the firmware you’ve downloaded in the previous step you can browse the downloaded firmware directly no need of installing firmware in thonny ide if you browse it from your downloads.
(OR) You can do this steps using -> configure interpreter in the bottom of the thonny ide screen as shown in the image below.
Important: before testing the installation, your ESP32 board needs to be flashed with MicroPython firmware (see the above steps for flashing).
Connect the board to your computer using a USB cable. To test the installation, you need to tell Thonny IDE that you want to run MicroPython Interpreter and select the board you are using.
- Go to Tools > Options and select the Interpreter tab. Make sure you’ve selected the right interpreter for your board as well as the COM port. You can also select the "Try to detect automatically" option, but only if you just have one board connected to your computer at a time. Otherwise, select the specific port for the board you’re using.
- Thonny IDE should now be connected to your board and you should see the prompt on the Shell.
- Type the command help() in the Shell and see if it responds back. If it responded back, everything is working fine. Now, you can send a few more commands to test.