ESP8266 Support WIKI

User Tools

Site Tools


getting-started-with-the-esp8266

**This is an old revision of the document!**

Table of Contents


Getting Started with ESP8266

This page gives some information on how to get started using a ESP8266-based board. It is intended for the newbie with past experience in arduino-like mcu who wants to get a first hand at ESP8266.

Procuring a ESP8266 based board

Which ESP board?

ESP8266 usually comes assembled on a board, the most popular ones having been the ESP-NN by vendors such as AIThinkers. Olimex has also started to sell their own boards, and you can find several others too. The boards integrate an ESP8266 chip plus a SRAM chip, and an crystal. SRAM size and chip model can vary.

Among the ESP-XX boards, the most notable to get started is the ESP-01, which has a male 2×4 1/10“ pitch connector that can be readily used with Dupont wires. It is not breadboard friendly because it cannot straddle the two sides of breadboards, though.

ESP-01 exposes serial communication pins (RX/TX), and the minimal 4 control pins, GPIO0, GPIO2, CH_PD and ReSeT, plus VCC and GND of course. With that you will not have access to all-purpose GPIOs. ESP-01 also has a Wifi Antenna etched on the PCB, which is efficient enough for starters.

The other ESP-NN modules expose GPIO pins, but are packaged in SMT packages, at best with a 2mm-pitch notches. Some modules have etched antenna, some have ceramic antenna, and some have just a socket or a pin. A favorite for that is the ESP-07, which has a shield (with FCC marking, but probably not registered at FCC)

Where to get ESP modules from?

Modules can be found in several places, just google for ESP8266 or ESP-01. eBay has several sellers, some are found on AliExpress or the bignames DIY electronics in US or Europe. Price vary in the $3-$5 range.

European vendors such as Olimex has neat modules too.

While you will be at it, remember to also order a (couple) USB/TTL converters. Several models exist, based on FTDI FT232 chip, CH340G or CP2102. There are fake FT232 chips that will cause issues (due to FTDI a blotch that disables these chips in their windows driver), so better aim for CH340G or CP2102 if you're not ordering from the big names. Price is from $1.4 for CH340G-based up to $5.

:!: Some adapters have a 3.3V/5V switch, but they usually cannot provide enough power (300mA) to ESP chip, so a separate 5V-3.3V converter (called an 'buck' converter, usually adjustable) could be a good idea too.

Got an ESP-NN board in the mail, now what ?

At-tension please

:!: Caution :!:, before anything, ESP8266 is a 3.3V board, which is not advertised as 5V-friendly. This means the module must be powered from 3.3V and any 5V I/O must be level shifted to 3.3V in either/both directions.

For beginning use, the best thing is to use a USB to 3.3V TTL converter and a 3.3v power supply and not mess with 5V levels (except maybe to feed into a 3.3v regulator). Get everything working and talking and figure out how it works first, then proceed to use a level shifter.

On output, 3.3V levels High voltage is also seen as High voltage by 5V TTL

Some have reportedly been running on 5V TTL I/O, but this may reduce the lifespan of your device, or burn it out immediately.

There are two ways to split tension on input, using a resistor divider, or using a bidirectional 2N7000-based 'level shifter' circuit:

  • Resistor divider will use two Rs, for example 1k and 2.2k (3.3V is just 2/3rd of 5V, mind you)
  • Level shifter has the great advantage of working both ways, great for GPIO pins, and (probably) drawing less current than a divider (uses 10k pull ups). It has the disadvantage of being slightly more expensive, and 2N7000 are static sensitive. See http://husstechlabs.com/support/tutorials/bi-directional-level-shifter for example.

Discussion here too: http://electronics.stackexchange.com/questions/18186/cheapest-way-to-translate-5v-spi-signal-to-3v-spi

Basic wiring

So, now we assume that you got:

  1. an ESP-01
  2. a USB/TTL converter
  3. a 3.3V power supply
  4. a breadboard and Dupont wires
  5. 1k and 2.2K resistors

Note that the FTDI USB UART adapters internal 3.3v supply might not provide enough current to power the ESP8266 under all circumstances, so some external 3.3v power supply is recommended. It it seems to disconnect or reset, try a separate power supply.

Looking at the (8 pin) board from the top (chips and antenna side), with the antenna to the right, the pins from the top down in the edge row are:

  • TXD (goes to the RxI of the UART USB adapter to the PC)
  • CH_PD (enable/power down, must be pulled to 3.3v directly or via resistor)
  • REST (reset, must be pulled to 3.3v)
  • VCC (3.3v power supply)

The inner row (top and bottom have square pads)

  • GND (connect to power ground)
  • GPIO 2
  • GPIO 0 (leave open or pull up for normal, pull down to upload new firmware)
  • RXD (goes to TxO of the UART USB adapter to the PC)

Other modules have more pins, but these will be included. If GPIO 15 is broken out, it must be pulled low to get out of the bootloader.

If there is power, a red LED will come on, and a blue LED will flash briefly as it comes out of reset - it flashes when the UART is transmitting.

Talk to me, baby

Once setup, you will want to start talking to the ESP. For that, a terminal emulator on windows will do. Tera Term, Putty, Hyperterminal or nearly anything else will work. One caution is if you detach your UART device or it goes offline (e.g. loses power or the ESP causes the chip to reset), it might not clear and reset until you exit or close or restart the program.

First, your board might talk at any of several baud rates. The ones to try first are 9600 and 115200. Then 57600 and/or 76800 (38400 * 2). Note the noise when you reset the device (pull the RST pin to ground) is typically some bootup messages at 76800. But there should be a ”ready“ message at the selected baud rate if your UART Rx is wired correctly.

If your UART Tx is correct, typing ”ATfollowed by control-m and control-j, yes both carriage return and linefeed are needed, should return an ”OK“. And you are now ready to start working with the ESP8266. It should echo the characters as you type them.

Boot up

By “HIGH” I mean pulled up, usually through a resistor (1k), but can be directly connected to 3.3v power, and “LOW” means something similar, but to the ground pin.

If one of the boot-mode pins is not set correctly, when you reset, you won't get the ready message. To diagnose this, you can see what the bootloader is putting out by setting the baud rate to 76800. Then you can pull the RST pin Low, then High, and see what the output is.

It will display a message giving the reason for the reset. It should give a loading message and some addresses if everything is correct. If it doesn't give any more messages, or “Waiting for host”, or something else, one of the other pins is not connected properly.

The CH_PD must be High, as well as the RST line and GPIO 2 (or left floating, i.e. unconnected)

GPIO 0 has to be High for normal mode, Low for flashing new firmware.
For the modules with extra GPIOs (more than the 8 pin), GPIO 15 must be pulled low.

If everything here is right, you should get a bootloader loading message, then nothing or some noise as the baud rate changes to normal.

AT Commands

The first AT command you will want to try is AT+GMR, it will output the firmware revision number.

Then, you may want to list the Access Points that are visible from your ESP module:

  • Set Wifi mode to both Access Point and STAtion: AT+CWMODE=3
  • List Access Points: AT+CWLAP

And connect to one of the listed APs:

  • Join an Access Point: AT+CWJAP=“SSID”,”password“

Alternate Firmware loading

getting-started-with-the-esp8266.1423087298.txt.gz · Last modified: 2015/02/04 22:01 by gregware

Page Tools