Getting Started With the ESP8266 ESP-12

973K520114

Intro: Getting Started With the ESP8266 ESP-12

This instructable will cover the basic steps that you need to follow to get started with the ESP8266 ESP-12.

A lot of this content is already out there, but I had a hard time getting everything in place, and the different tutorials can cause a great deal of confusion, which is why I have tried to make the simplest setup possible.

Specifically, this instructable will cover how to make the ESP-12 behave as a WiFi client by connecting to your home wireless network and how to send sensor data ( we will send random numbers to test, and will not really be covering sensors in this instructable) to a Thingspeak channel.

The following are the materials we will be using :

1. ESP8266 ESP-12 module

2. CP2102 USB to UART Serial module

3. LM1117 3.3V Voltage Regulator

4. Jumper Wires

5. 5V Power adapter

STEP 1: Breakout the ESP8266 ESP-12 Onto a Perforated Board

The ESP-12 has a 2mm pitch, which means you cannot access all the pins on a breadboard or a perforated / dot matrix directly, which have a 2.54mm pitch (distance between adjacent pins).

You could use a Xbee adapter board, but there's an easier way out. Take a small length of single strand cable or multi strand cable, and get a spider web breakout like this. I added two rows of pinouts, to make sure the pins were handy. Here's what it looks like.

STEP 2: Add Power Supply

Add a power barrel so that you can easily plug in a 5V adapter into your board to power it. This is an optional step, but one that saves you a lot of trouble later.

Connect the terminals of the power connector to the LM1117 (SMD), so that you have 3.3V output to supply to the ESP8266 ESP-12. It is good practice to add capacitors across the input and output lines, but I am just going to skip that, since this application is very basic and is non-essential.

Here is what the board looks like after adding the power connector and the LM1117.

The additional jumper wires are so that I can either channel the power from the connector to the LM1117 (if I am using a power source > 3.3V), or directly to the ESP-12 (if I am using a 3V power source). This is optional, and you do not need to add this.

STEP 3: Make the Connections

You need to connect a few GPIO pins on the ESP-12 to 3.3V or Ground, to set it in the right mode for communicating with it. Here are the connections you need to make :

VCC ----> 3.3V Power supply (Vout of LM1117)

GND ----> Ground of power supply

CH_PD ----> HIGH (3.3V)

GPIO2 ----> HIGH (3.3V)

GPIO15 ----> LOW (GND)

GPIO0 ----> HIGH or Floating for AT Mode (3.3V) [ * if you want to flash completely different firmware then you must connect it to ground ]

STEP 4: Plug in Your CP2102

You will now need to plug in your CP2102 to the USB of the computer.

The CP2102 is a USB to serial converter that lets us communicate with the ESP-12 over UART.

The CP2102 will be detected as a serial device. If you have used a serial device before, you ideally should not need the drivers. In case you need the drivers, you can find them here : CP2102 Serial VCP (Virtual Communications Port) Drivers

The connections between the CP2102 and ESP-12 are straight-forward.

CP2102 <--------> ESP-12

Rx <----------------> Tx

Tx <----------------> Rx

GND <----------------> GND

Note : Do NOT connect the 3V3 line from the CP2102 to the ESP-12. The ESP-12 consumes a lot of current, and the USB port is NOT capable of providing that, you are at risk of blowing the USB port if you connect the two.

Alternatively, you can also connect an Arduino Uno 's Rx and Tx lines with the CP2102, but you will need to have a voltage divider resistor arrangement to step down the 5V UART lines from the Uno to the 3.3V needed by the ESP-12, otherwise you risk damaging the ESP-12.

STEP 5: Open a Serial Terminal

Depending on your OS, you can download and install a Serial Terminal to communicate with the ESP-12.

Here are some popular ones :

Linux / Windows: Putty Download

Mac: Coolterm Download

If you have Arduino IDE installed, you can just use the Serial Monitor present inside. For that, you have to navigate to Tools > Ports , select the Port that the CP2102 was detected on, and then open the Serial Monitor.

For the next few steps, we will be using the Arduino Serial Monitor for demonstrating.

In the Arduino Serial Monitor, at the bottom right, in the line endings tab, select "Both NL and CR". This inserts a NewLine and CarriageReturn at the end of each command you send, and is necessary for the ESP-12 module to receive and understand your commands.

The other terminals should have a similar option in their respective configuration pages.

STEP 6: Setup the Communication Parameters

First, to check if the module has been recognised and is accepting commands, just briefly connect the "REST" pin of the ESP-12 to ground, using a jumper. This resets the ESP-12 and you should see something like the screenshot if this works well.

Next, we run the following set of commands in the Serial Terminal:

1. AT

This is just a hello message, and if the ESP-12 is in the correct mode, it will return an "OK" message.

2. AT+GMR

This command returns the firmware version currently on the chip.

3. AT+CWMODE?

This command returns the mode of operation. If the mode is not 3, we will change it to 3 using the following command :

AT+CWMODE=3

This mode makes the ESP8266 behave both as a WiFi client as well as a WiFi Access point.

4. AT+CWLAP

The LAP (List Access Points) lists the WiFi networks around. Next, we choose our WiFi network

5. AT+CWJAP="your_network_name","your_wifi_network_password"

This command JAP (Join Access Point) makes the ESP-12 join your WiFi Network.

6. AT+CIFSR

This command returns the IP address of the ESP-12 as the second line and the gateway IP address as the first line if it managed to connect successfully.

STEP 7: Post Your Data

Next, we just post our data to Thingspeak. For now, we will be posting made up numbers, which you can replace with sensor data if you are using an Arduino Uno or some other micro-controller with the ESP-12, or once you progress to using the ESP-12 with your own custom firmware.

You need to sign up for an account at Thingspeak, set up a channel, but to make the process simpler, I am just going to include my access key for Thingspeak, so you can send data right away to test your modules and view it too.

You can view the data you posted here :

Commands :

AT+CIPSTART="TCP","api.thingspeak.com",80

The above line opens a connection with api.thingspeak.com on Port 80, to send an HTTP GET request with our data

AT+CIPSEND=70

The above line specifies the number of bytes that are going to be sent as a part of the request. The length is the length of the line below, plus 4 bytes for the CR,NL (Carriage Return and New Line) that the Serial Terminal always inserts at the end of a command. If the size is not correct, you will get an error.

Once you enter that, you will see the " > " symbol in the window, which means you are now ready to send the actual data. Enter the line below, with the numbers you desire, and press Enter. Then press Enter one more time.

GET /update?api_key=QNI517W61UOC40KF&field1=12&field2=19&field3=94

The above three commands effectively call the URL http://api.thingspeak.com/update?api_key=QNI517W61UOC40KF&field1=12&field2=19&field3=94

The api_key is necessary for authentication, and field1, field2, field3 are the data fields for our example.

You can now go and view the data you just posted at the link here : Sensor data on Daflabs Test Channel on Thingspeak

STEP 8: And Done !

Congratulations, you are now done ! You have just posted some data to the web using the ESP-12 and GET requests.

You could extend this by adding some sensors to an Arduino Uno and interfacing it with the ESP-12, and automate the entire process of sensing and updating data. What you effectively have here is an Arduino Yun (minus the Linux) for a mere $5 more !

For a tutorial on how to use the Arduino with the ESP-12 and the code for uploading sensor data, you can visit here: An IoT project with ESP8266 and Arduino

93 Comments

Nice tutorial.
Got my ESP-12 working and posted some data to your thingspeak test channel.

Thx!
The LM1117 comes in different forms.
The adjustable version needs resistors to set the output voltage.
For this setup you must use the 3.3 volt fixed version, marked 3.3

The ESP8266 draws a lot more power when transmitting.
It may work when idle, but not work when transmitting.
Its needs a good power supply.

I want to use ESP8266 ESP-12 as a slave with my FPGA spartan6 .For accessing 2MByte per second, i need to communicate with ESP-12 using SPI.
So, my question is: Can i Configure and send/receive data only trough SPI pins(and leave unconnected UART Tx/Rx pins)?
I am just getting started with the "Getting started with ESP 8266 ESP-12" and I got an immediate road block. I have installed both the CP2102 & the ESP-12, hopefully correctly and wired them as per instructions. The Arduino IDE says "Board at COM 10 is not available. The tools>port choices are 3 & 11. Neither worked. Any advice?
I tore it all down & very carefully connected it up exactly as the Connection diagram calls for, I added an LED and 330 ohm resistor from GPIO-13 to GRND and tried to run "Blink," same result, only two choices Com 3 and Com 11. Neither worked. Here are the error messages. Any help?
Pity that 1st two links in post are dead

This is incorrect.
There are resistors missing.
Please look up the correct way to use the ESP8266

I am yet to find a set of instructions that will help me run AT commands on my ESP8266 12E. Tried this set of instructions with my device, the fully charged power bank that I had connected to the voltage regulator ran out in a matter of minutes, the ESP module became hot. And all I got were jumbled letters when I grounded the reset, at each baud rate. There are so many different sets of instructions online regarding AT commands, funny thing is, none seem to be consistent.

Apart from GPIOs difference, are there any other significant differences between ESP8266-12 and ESP8266-01?

Thanks!

The ESP8266-01 commonly called ESP-01 has only 8Mbit of Flash.

The wiring is totally wrong, and may blow the board up.

Can you please point out what is wrong ?

Thanks a lot. Everything worked smoothly.

I'm about to buy some
ESP-12 do reproduce this tuto, my goal is to send sensor data to distant
server.

What ESP-12 module is best
?

i found different versions
such as : ESP-12F ; ESP-12E and also ESP-12S

I found that link to buy
'F' version:

http://s.aliexpress.com/VfauyeuU

Can you advice me which version i should buy ?

Man I'm bumbled with my ESP8266 12, I tried everything now even this guide.

If I power the VCC and GND with 3.3V the LED flashes once then turns off, When I connect all the pins as shown in this instructable the light does not flash , This guide shows how to hook it up exactly how other guides on the internet does. are these modules known to be faulty ?, Ive been at this for hours! Not sure if the module is faulty or not.

I had success without connecting my GPIO2 to VCC just the CH-PD to 3.3v and bringing the the GPIO0 to GND. Also my i found my baud rate was different.. maybe the stock firmware has something different rate set-up. As for your leds... my unit just blinked once and stayed off while in bootloader mode.

Thanks Keith, I eventually got it right. I thought the GPIO 0 pin had to be permanently connected to GND when starting it up in programming mode. After I put in a push button inbetween GPIO 0 and GND and only bring it down to GND when turning it on solved the issue. I follow this sequence Press reset on FTDI, Hold down the programming button, Power the ESP on then release the programming button, press reset on the FTDI again. Then it allows me to upload. I also created a video hopefully someone finds it usefull

https://www.youtube.com/watch?v=NQqxaBEZjcs

Hardware

Hardware: --ESP-12e (uploading code in ESP12E)

Settings in IDEModule: ?Generic ESP8266 Module?
Flash Size: 4MB/1MB (what it should be?)
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz?
Upload Using: --->SERIAL
Reset Method: --->ck

C:\Users\vishal\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.9/esptool.exe -vv -cd ck -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\vishal\AppData\Local\Temp\arduino_build_1597/ESPdroneFinalest.ino.bin
esptool v0.4.9 - (c) 2014 Ch. Klippel ck@atelier-klippel.de
setting board to ck
setting baudrate from 115200 to 115200
setting port from COM1 to COM3
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

My connection are
https://www.instructables.com/id/Getting-Started-with-the-ESP8266-ESP-12/?ALLSTEPS

GPIO 0--GND (WHILE UPLOADING)
GPIO 15-->GND
GPIO 2-->VCC
CH_PD-->VCC

Hi, Why others using 10K resistor, I used your instructiona and my boards LED doesnot light any more.

I have been trying to use the esp8266 e12 wifi module to respond to AT commands now currently i dont have the usb to ttl converter so m using the arduino uno as usb to serial converter,i have connected the reset to the gnd in arduino board, but still while making all the connections and trying to flash the esp failed! i have connected tx and rx of esp to the tx and rx of arduino respectively..howevr i have used the 3.3v of the arduino to power the esp...on opening the serial monitor in arduino ide all the baud rates except 74880..on that baud rate while connecting the rst pin to gnd a msg poped "ets Jan 8 2013,rst cause:2, boot mode:(1,7)" and it is also not accepting any AT commands...pls help im in a fix....

More Comments