Programming the ESP32 with MicroPython

Once you have downloaded your ESP32 image and installed esptool, it is time to flash the development board with the MicroPython kernel. With a brand new development board, we must first erase the existing firmware. Once the firmware is erased, we can then program a new image onto the device and, after a reset, we should see the familiar MicroPython REPL appear in the terminal. Let's get started:

  1. Plug the ESP32 development board into the computer.
  2. Open a terminal or Command Prompt.
  3. Navigate to your Python installation.
  4. Type the following command to erase your ESP32 firmware. Note that you will need to identify which serial port the board has enumerated on:
esptool.py –chip esp32 –port COM3 erase_flash

If this is successful, you should find that the terminal shows an output similar to the one in the following screenshot:

  1. Make sure that your new ESP32 image's path is readily available. You may want to copy the image and place it in your Python folder temporarily.
  2. Enter the following command to program MicroPython onto the ESP32:
esptool.py --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 esp32spiram-idf3-20191220-v1.12.bin

Note that you will need to update the image name to the latest version that you downloaded and update the port that your development board is connected to. The update operation may take a few minutes and will look something like the following during the entire process:

  1. Once the firmware has been programmed, press the reset button on your development board to ensure that you get a clean bootup.
  2. Open a terminal and set the baud rate to 115200.
  3. Press Ctrl + D. You should now see the ESP32 perform a soft reboot and load the MicroPython REPL as follows:

Congratulations! You now have MicroPython running on the ESP32!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.184