Introduction: Definitive Guide to Setting Up Your New ESP01 Module
This guide is created out of necessity when I first started venturing into the world of the ESP8266, now one of the most popular Wi-Fi SoC solutions on the market for makers. This guide is meant to complement my own custom Arduino, the SPEEEduino, with a basic guide available here.
Guiding supervisor for this project: Mr Teo Shin Jen
The biggest problem I encountered with most guides is fragmentation: they provide non-centralised information. This guide is written specifically with the beginner in mind (beginner with a bit of electronics background, that is).
If you happen to be one of those people who stumbled on their way to making an ESP8266 work, I cordially welcome you to this guide. Be my guest, and let's get started!
This guide will focus specifically on the ESP-01 module, which has the simplest pinout of all the versions out there.
Step 1: Familiarising Yourself With the ESP01
The image above is a highly informative cheat sheet of the ESP-01 module's pinouts and their respective functions, made by adlerweb (CC-BY). This page here will familiarise you with the different pins of the ESP-01:
Broken out pins:
- Vcc/GND: 3.3V power and ground, respectively
- CH_PD: Chip select. Set to high to select the chip, low to deselect. Should always be high if you intend to use the chip
- RESET: Set to high to allow normal operation of the chip, give it a low pulse to reset the module
- TXD/RXD: Transmit and receive serial pins, respectively
- GPIO0: Set to high to let the module boot up from its flash memory, low to enter programming mode to reflash the flash memory. Should always be high unless you want to reflash the chip
- GPIO2: Set to high by default
Non-broken out pins:
- GPIO15: Set to high to boot from SD card. This pin is not broken out, and is pulled low by default
The ESP01, unfortunately, is not breadboard friendly. That means you either have to break it out with a specially made board to split up the legs so that they will fit on a breadboard nicely, or use a set of female to male jumper wires if you want to connect it to a breadboard.
Step 2: Power and Data Requirements
The ESP8266 only and only runs on 3.3V, for both power and data.
The ESP8266 uses 3.3V logic exclusively, and runs on the following possible baud rates:
- 9600/115200: Usually runs on these two baud rates where you can issue AT commands to it
- 74880: This baud rate is usually used by the boot loader. See the picture above for what this particular baud rate displays when the reset pin is changed from LOW to HIGH and GPIO0 is set to 0 (programming mode). I spent several hours debugging why AT commands wouldn't respond until I realised that I used the wrong baud rate that is used exclusively by the boot loader and GPIO0 should be pulled high. The image I included above shows the messages printed by the boot loader (last two lines).
Step 3: Common Setup Procedures (hardware)
This step will get you to set up your ESP01 module as fast as possible:
As previously mentioned, the board can only accept 3.3V power and logic levels. That means if you have a 5V power supply, for example, a USB port, you need to use a voltage regulator with adequate current to provide 3.3V to the module. That means that you cannot power your module straight off a USB to Serial converter like an FTDI module that has a 3.3V inbuilt regulator (for reference, the FT232RL can only supply 50mA on its 3.3V output)! The ESP8266 is very power hungry at full transmission power, taking up to 100mA at 5V (when I used a USB current monitor) when it is actively transmitting. However, the voltage regulator on most Arduinos should be able to do the job just fine.
Connect the diagram as shown above
The diagram above shows how I connected my ESP01 module to a serial converter, through a Sparkfun logic level shifter (now a retired product), and used an Arduino as a 3.3V voltage regulator. The colour of the wires used in the diagram denotes different purposes:
- Red/Black: Power and Ground
- Yellow: Transmit (of the ESP8266)
- Blue: Receive (of the ESP8266)
- Grey: ESP8266 setting wires, like CH_PD, Reset, and the two GPIO pins (all of them set to logic level High at the moment)
The second picture taken is of the actual mess of wires I created while I was wiring the ESP01 module.
Step 4: Common Setup Procedures (software)
I strongly recommend ESPlorer as an IDE for developing for the ESP8266. It includes easy to use tools such as buttons that allow you to pass in commands simply by pressing buttons in the interface, and supports nodeMCU's Lua firmware as well as normal AT commands.
As I am hooking up this ESP8266 module with a normal Arduino Uno over a software serial port (which does not support the 115200 baud rate used by default), I had to manually change the baud rate of the ESP module directly, by issuing the following AT command, which specifies:
- 9600 baud
- 8 bits per byte
- 1 stop bit
- 0 parity
- 0 control flow
Step 5: Flashing the Firmware
Flashing the firmware for the ESP8266 is by far the hardest part due to the fragmented nature of the wide variety of firmwares available out there. For simplicity, we are sticking to the official binary build provided by Espressif.
Note: These instructions are ONLY for people who just want to grab the latest binary build and flash the chip! If you want to apply a patch or compile your own firmware, do not follow these instructions. I am working on another Instructables that will go through the full process on how to compile and upload a custom firmware.
You will need the following:
- The latest firmware from Espressif. They publish their firmwares on their BBS. Go under Downloads/SDKs > Announcements/[Latest Release/最新发布] to find the latest firmware. (At the time of writing, the latest SDK version is V2.0.0 with a patch)
- When you get there, there are a few versions of the firmware, such as "Non-OS SDK Patch", "Non-OS SDK", "Non-OS SDK with latest version MBEDTLS", "RTOS SDK". Download the "Non-OS SDK". Some release have patches as the development team discovered bugs after the release.
- Do take note, if you are planning to compile the firmware from scratch for whatever reason (such as including a new library like MBEDTLS), you need a dedicated UNIX-like environment, such a Linux distro, macOS or Windows with Cygwin installed. This process will be detailed in a separate Instructables that will be released some time later.
As of 2017-01-17, the address map looks like this (for modules with 1Mbyte/1024kbit or 8Mbits of flash storage):
0x00000: boot.bin (this is the bootloader, always use the latest) 0x01000: user1.bin (the actual firmware) 0xFC000: esp_init_data_default.bin (stores some default values) 0xFE000: blank.bin (blank space for padding)
Important notice: never assume anything! The ugly thing about firmware flashing is that you run the possibility of bricking your entire device if you clicked on something wrong!
Most of my references come from this AllAboutCircuits article.
Step 6: More to Come
This guide is not yet complete at this point, and there will be more content added incrementally as I go. This guide was created in part for the SPEEEduino (pictured above), a custom Arduino/ESP8266 fusion board designed by me and a fellow schoolmate. The first version is available here.
We have a be nice policy.
Please be positive and constructive.