On the left is the WiFi-enabled ESP8266 ESP01 microchip. This module is a self-contained SOC (System On a Chip) that doesn’t necessarily need another microcontroller to manipulate inputs and outputs. The chip displayed here has 1MB flash and 4MB memory storage. It runs at 80mhz by default and can be tweaked to run at 160mhz. That's a lot of processing power, considering the size of the ESP01. The ESP01 is very thin, about 2mm (1mm for the PCB board and 1mm for the chips on board).
On the right is the 'programmer' for ESP01. Nothing fancy, it's just a adapter from the UART (serial) to USB. It allow the ESP module to be connected to PC for two key tasks: 1) Flash new firmware and 2) Upload & Delete Python scripts onto the ESP.
ESP01 can come with variety of firmwares. The most common one is the Espressif which use C or Java alike language. The Python that is specifically written and optimized for microchips is called 'Micropython'. The package is roughly between 0.5mb to 1.0mb, depending on the version. There are specific versions that are developed for different chips. For this exercise, we need the version developed specifically for ESP8266.
Latest version of Micropython is slightly more than 0.5mb. Make sure the ESP01's flash size is larger than the size of the firmware
To flash Micropython, following hardware and software components are needed:
Below are the steps for flashing Micropython onto ESP8266-ESP01-S:
Mount the ESP01 as shown in the image on the left below.
Insert ESP01 into USB, WHILE connecting GPIO-0 to GROUND, using the short breadboard cable. Then use 'device manager' on Windows to find out the PORT NUMBER of the programmer.
When displaying the Port Number in 'Device Manager'. Look for the chip type of the programmer. The used in here is CH340, the driver can be downloaded from here
Reboot the PC and reconnect the programmer with ESP01 mounted into the PC's USB port.
To test whether ESP01 chip is in downloading (or flashing) mode, run
python -m esptool --port COM7 flash_id
.
Note the COMX, number should be changed according to the actual port number shown.
If the chip is in downloading mode, info of the chip will be displayed, as shown in the image
on the right below.
cd C:\Users\Username\Downloads
python -m esptool --port COM7 erase_flash
python -m esptool --port COM7 --baud 115200 write_flash --flash_size=detect -fm dio 0 esp8266-20190529-v1.11.bin
Unplug and reconnect the programmer (still with ESP01 mounted), but without grounding GPIO-0 to GND. Now connect using putty (speed set to 115200). How the ESP01-S will work as in the RELP (interactive) mode. Try the following code to make sure it is working.
# Returning the current CPU frequency
import machine
machine.freq()
More helpful information on setting up the ESP01 can be found on the official page here. Examples of instruction can be found there including:
The next article will be focusing on the uploading and management of scripts on the ESP module using Ampy