Introduction: 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

Comments

author
lcoulon (author)2017-04-21

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 ?

author
mviljoen2 (author)2017-03-24

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.

author
KeithAZ (author)mviljoen22017-04-09

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.

author
mviljoen2 (author)KeithAZ2017-04-09

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

author
sarwdaenj (author)2017-04-08
Hardware

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

Settings in IDE

Module: ?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

author
AliY51 (author)2017-03-05

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

author
dawer_saeed (author)2015-04-11

Thankyou ankitdaf,
I was messing around with this ESP-12 and was not able to make it respond.

This instructable has helped working my ESP.

Regards.

author
BoB6 (author)dawer_saeed2015-09-07

Progress here! See my post elsewhere on the 12-e post. No one has mentioned that FOUR files need to be flashed to it - but I did and it works. How are you doing with yours?

author
Tstef (author)BoB62017-01-30

Mine didn't need flashing initially. It came with the AT firmware on it.

author
dawer_saeed (author)BoB62015-09-07

@BoB6, can you please post the link here to your post?

author
bobarry (author)dawer_saeed2015-09-05

I hooked TX to TX & rx to rx and got mine going.

author
dawer_saeed (author)bobarry2015-09-06

yeah, some USB to serial converters work like this, I have a PL2303 which works like this.

author
DebojitK made it! (author)dawer_saeed2016-05-28

Hi Dawer,

I have a PL2303 module. my connections are following

tx of TTL converter to rxd of esp, similarly rx of ttl to TXD of esp.

GPIO0 is grounded. I am not getting any out on the serial monitor (not for any speed).

You are saying i should exchange the wires right.

Can you please help.

IMG_20160529_011022_.jpgIMG_20160529_010953_.jpgIMG_20160529_010927_.jpg
author
DebojitK (author)DebojitK2016-05-28

Got to work successfully.

I forgot to reset the device after connecting to ttl. Needed to adjust the speed to 115200 baud, and then hurray...

Ai-Thinker Technology Co.,Ltd.

ready
AT


OK
AT+GMR

AT version:0.40.0.0(Aug 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK

author
NanangS6 (author)dawer_saeed2016-03-14

hi dawer_saeed, i have PL2303 too. But i cannot upload the sketch. Can you share the connection? Thanks

author
dawer_saeed (author)NanangS62016-03-14

can you please post your connections what you are doing?
it would be good if you could post a fritzing circuit diagram.

author
bobarry (author)dawer_saeed2015-09-06

Still struggling with it, making some progress. Using the common connections. Only confusion is GPIO2 which SOME say it needs connected to +3.3. NO decent docs ANYWHERE n the web. :) I'm doing Arduino only with it.

author
dawer_saeed (author)bobarry2015-09-06

Actually you dont need to hookup the GPIO2 at all to make it working.

can you share your current circuit you have made?

author
dawer_saeed (author)dawer_saeed2015-04-11

BTW, how did you figured it out, that some other GPIOS also needs to be connected to Vcc or GND?
Did you get any official document on ESP-12?

author
sdey3 (author)2017-01-07

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....

author
AhmadK80 (author)sdey32017-01-08

I had the same issue then I used 115200 and it worked with AT commands.

author
sdey3 (author)AhmadK802017-01-09

but using the 3.3v from the arduino to power up the esp affect its performance ??? cz the led on the esp isnt lighting up...and moreover i used the 115200 baud rate but all that its showing is some highly random words all jumbled togethr possesing no sense

author
Tstef (author)sdey32017-01-30

Yes, you need a better power supply in my experience. Give this article a read if you can't get it to work: http://internetofhomethings.com/homethings/?p=396

author
WilliamB211 made it! (author)2017-01-15

I designed a nice little PC board for the Esp12-e- here it is. If anyone wants the CAD files, -let me know. I have 7 circuits designed specifically for Esp12-e and IoT Home Automation-

Allie1.pngPrettyQuad.pngAvonColor.pngAvon1.PNGAvon3.PNG
author
zeilotech (author)2017-01-10

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

Thanks!

author
zeilotech (author)2017-01-10

Please how can I program the built-in MCU of the ESP8266 using my C language compiler and use it for other purposes? I appreciate all contributions to my questions.

author
haohaoone made it! (author)2017-01-08

HELLO !
This is my problem .
Can you teach me,how to solve this problem .

ESP-12E 問題.jpg
author
achachre (author)2016-12-14

can I use ld33 ic instead of lm1117

temp_1835414088.jpg
author
kmanchanda (author)achachre2017-01-03

Yes . Just see the pin configuration before using.

author
achachre (author)2016-12-14

and is there any extra driver or board in arduino ide is needed. if not then which board I choose

author
diy_bloke (author)2016-10-13

Interesting, but perhaps I can make a contribution for people who dont get any response to the AT commands: I bought an ESP8266-12E module and separate BOB, soldered it all together, followed the instructions here....no reaction on AT at all. briefly connected reset, no response, change Baudrate, 9600, 115200 back and forth, double checked my connections, tried again... no result.
Kinda curious and eager to know if maybe i had a faulty module I thought 'heck with it' connected GPIO0 to ground and flashed a program. I admitt to my surprise that worked immediately, module works fine.

So maybe some modules just don't come with the Expressif AT commands flashed into them. Now having said that, i didnt try the baudrates between 9600 and 115200 but i guess I should have seen at least some gibberish in the serial monitor if being off with the baudrate was the only problem

author
manolotarr (author)diy_bloke2016-11-28

Hola, un ejemplo mas de uso facil de ESP8266. Saludos mam@tinet.org

author
diy_bloke (author)manolotarr2016-11-29

Thank you, but i didnt have a problem with i2c, nevertheless, tnx

author
ericCycles (author)diy_bloke2016-10-22

were you seeing the led flash when it powered up? My led isn't lighting up. I'll try flashing a program next.

author
diy_bloke (author)ericCycles2016-10-23

I dont think I saw it flash on powerup (when there is no program in it)

author
Tiagod38 (author)diy_bloke2016-10-21

hello!

I'm having the same problem here, and I think the lack of a firmware might be my problem too!

But at this moment I do not have the USB/Serial converter, so I'm using Arduino to communicate with ESP. Is there a way to flash the ESP through Arduino?

author
diy_bloke (author)Tiagod382016-10-21

yes, You'll be using the USB-TTL part of the arduino.
However just a correction.. you do not need/want a USB to serial converter but a USB to TTL and the Arduinoboard has one. Make sure though that connect via a levelshifter and that you remove the Atmegachip. Which I presume you already did for your current communication with the ESP

author
Tiagod38 (author)diy_bloke2016-10-21

hummmm... this may be another reason. I was using the 3.3v from Arduino to feed the ESP (there are a lot of examples on web that worked with it).

I'm going to try first a separate power source. If it doesn't work, I'll try to flash it using UNO.

Thank you!

PS - I'm using the Logic Level shifter... so the connections should be TX → TX, or TX → RX?

author
diy_bloke (author)Tiagod382016-10-21

well hence my advice/ the 3.3 Volt of the arduino is insuffucient.

when you use the arduino's usbt to ttl interface you need to connect tx to tx-pin and rx to rx-pin via the levelshufter. that might seem illogical but the Tx of the converter goes to the Rx of the atmega, if you connect that subsequently to the Rx of the ESP then in fact the Tx of the converter goes to rx of the esp

author
Tiagod38 (author)diy_bloke2016-10-21

Got it!

I thought it was unnecessary once the maximum DC current that the ESP drains is 170mA (below the limit of 200mA, of Arduino).

I'll try it.

Thank you very much!

author
diy_bloke (author)Tiagod382016-10-21

but first you may want to make sure you feed the ESP through a decent PSU (3.3V) as it can be a bit hungry and if it doesnt get enough juice then it may do a continous reset

author
VishalK38 (author)2015-12-30

Hi,

I am not able to type any AT commands in Arduino Serial Monitor or in Putty. I am using 9600 baudrate.

When I connect REST to GND, I see the messages [System Ready, Vendor:www.ai-thinker.com]. But I am not able sent any commands.

This is my configuration.

Tx of ESP8266 -> Rx of CP2102

Rx of ESP8266 -> Tx of CP2102

GND of ESP8266 & GND of CP2102 -> GND of LD33V

VCC of ESP8266 -> VOut of LD33V

GPIO15 -> GND

CH_PD -> VCC

GPIO2 and GPIO0 -> VCC

Any inputs on this will be much appreciated :)

author
saadmamlouk (author)VishalK382016-09-12

first u have to check the baud-rate of your esp , probably it's working on 115200

after connecting don't forget after typing AT to press CTRL M then J

author
PaulI19 (author)VishalK382016-02-02

You should check if your ESP board supports 9600 baud rate. Most of them only support 115200 baud rate, unless you upgrade the firmware.

author
PaunA (author)PaulI192016-04-30

Thank you so so much. I didn't know what was I doing wrong. I had everything properly installed and it wasn't working. Changing the baud rate from 9600 ---> to 115200 immediately fixed the problem.

author
MohaimenA (author)VishalK382016-02-06

Try to connect RX of ESP to RX of serial, and TX of ESP to TX of serial. all other as you are connecting now.

author
ankitdaf (author)VishalK382016-01-02

This might be an issue with the Reset pin, did you try pulling it up ?

author
VishalK38 (author)ankitdaf2016-01-02

Yes I tried connecting RST-> VCC. But it was still giving repeated System ready messages.

author
epgibbons (author)2016-09-06

I had to set baud rate to 115200 for esp-12f.

Before AT+CWJAP command I had to use AT+CIPMUX=1

author
epgibbons (author)epgibbons2016-09-06

Note that I find that AT+CIPMUX=1 needs to be done on each reset

About This Instructable

771,453views

464favorites

License:

More by ankitdaf:Turn your CC2541 based HM-10 Bluetooth Smart Module into an iBeaconGetting Started with the Daflabs ESP8266 ESP-12 Breakout BoardGetting Started with the ESP8266 ESP-12
Add instructable to: