ESP32 is a series of low cost low power system SoC with integrated WiFi and Bluetooth. ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company. The ESP32 is the successor to the ESP8266.
- Processor: Single or dual core 32 bit LX6 microprocessor.
- Ultra low power co processor.
- Memory: 512 KB SRAM
- WiFi: 802.11 b/g/n
- Bluetooth: v4.2 BR/EDR and BLE
Comparison of ESP32 and ESP8266
The ESP32 is the ESP8266 successor. The ESP32 adds an extra CPU core, provides better WiFi, has more GPIO pins. In addition to all this, the ESP32 comes with a touch sensitive pin, built in temperature sensor. ESP32 supports the multiplexing of pin that can be used to assign multiple functions to the same pin. The multiplexing can be done through program.
Why MicroPython on ESP32?
MicroPython is a subset of the famous programming language Python. A user with basic programming experience with Python will find it very easy to get started with MicroPython. The MicroPython code is compatible with ESP32 and ESP8266, so most of the times we can use the same script for ESP32 and ESP8266.
Getting started with MicroPython on ESP32
The step by step guide is for Linux users. Guides for MacOS and Windows will be published soon! The process of installing the MicroPython firmware for ESP32 is similar to the process for ESP8266, with some minor changes.
Step 1: Install esptool.
esptool is a command line utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 microcontrollers.
pip3 install esptool
We are installing the python3 version of esptool.
Step 2: Identify the USB port number on which the ESP32 is running.
watch -d "ls /dev/ttyU*"
Disconnect the NodeMCU, then reconnect it. The port number on which the NodeMCU is connected to is highlighted.
Step 3: Change permission for the port on which ESP32 is connected.
sudo chmod 777 /dev/ttyUSB0
USB0 is the USB port number identified in last step.
Note: You will need to perform this action every time you connect the ESP32 to your computer.
Step 4: To erase the flash memory of the ESP32.
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash
Note: We specify the chip to be esp32 with the --chip option.
Disconnect the ESP32 module, then connect it back again after successful execution of command.
Step 5: Download and save the latest standard firmware for ESP32.
Download the latest standard MicroPython firmware for ESP32 from this link.
Step 6: Burn the firmware on ESP32.
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x1000 esp32-20190125-v1.10.bin
Note: Notice we are specifying the chip, the baud rate and the starting address with the --chip , --baud and -z options respectively.
Step 7: Get a MicroPython REPL prompt (REPL over serial port).
picocom /dev/ttyUSB0 -b115200
The baudrate of REPL is 115200.
Once you have made the connection over the serial port you can test if it is working by hitting enter a few times. You should see the Python REPL prompt, indicated by >>>.
Step 8: TEST!
The command should give the output: "hello esp32!"
Note: To exit picocom press CTRL+a followed by CTRL+q.
You can now try out more of examples to warm up with the ESP32 chip!
Please do let us know if we are missing any topic or you want us to elaborate any topic, comment below and subscribe to be updated.