Intro: Get Your ESP8266-12 Ready for AT Commands
ESP8266 is a System on Chip (SoC) which is widely used on Internet of Things (IoT) for its "tiny in size and low in price". I purchased two of this chip at VolumeRate.com for $5.42 each six months ago and until last week I decided to play with it, to twist my mind with codes :D
There are so many tutorials out there to get started with this ESP8266 such as :
- Instructables : Getting Started with the ESP8266 ESP-12
- Instructables : Esp8266 firmware update
I read them all and tried the different wiring methods but I still could not get it run the AT commands through Serial connection. Three days I kept tinkering until it finally works. I am so delighted. Seems like the ESP8266 has so many versions of default setting from manufacturer.
Then I decided to write this instructables so that other people who encounter the same problem with their ESP8266 modules can solve it faster.
Here I use ESP8266-12 complete with the breadboard adapter and 3.3V power regulator. It is said that you can safely connect it to the 5V power supply but surely not recommended. It is also said that this wifi module will draw more current than that your PC/Laptop usb port can provide. But I think it will not draw too much power on AT commands which are mostly used for setting up the module. And yes I plug it in 3.3V on my Arduino UNO which is powered by my laptop usb port :D [do this at your own risk as I did it at mine].
On the second picture, you'll see that GPIO4 and GPIO5 labels are swapped on adapter board. Some site says that the board fix it. I will figure it out on my next project :D
Step 1: Soldering
Firstly I solder the ESP-12 on adapter board. You should take deep breath then hold your breath to solder those tiny pins. Ha ha .. not really, but sure you need a good quiet place and steady breathing to get a good soldering result.
Secondly, I solder the 3.3V power regulator at the bottom of the board.
Then comes the pin headers. On my first ESP-12, I soldered the pin headers normally. Later I found that it is not breadboard friendly because the adapter board takes the whole width of breadboard. No way for jumper wires to connect to ESP-12 pins unless you put some wires from the bottom of the board to the open space.
Second try, I mod the pin headers so that they come out half on top and half on the bottom of the board. I put the headers from the bottom heading top and solder from the top [image #1]. Then use cutter or wire cutter or tweezers to remove the black plastic that holds the pins [image #2]. I saw that the bottom headers are longer then the top headers, while we do need the top headers long enough to connect with the female header jumper wires. So I would say that you should put the headers from top to bottom and then solder the bottom part of the pins [image #3]. Now we can sit the ESP-12 on breadboard and also connect the pins using female header jumper wires.
On image #4 you see that I solder a 104 (0.1 uF) decoupling capacitor across VCC and GND, that's when I was desperate making this module to work (-_-" ) some articles said that we only need it when we have several unwanted auto-resets. Finally I removed the cap and keep it in the box. Who knows I might need it later ...
Step 2: Wiring
Prepare 6 resistor with high value, 10K or above. I put four of them as pull-up resistors (connect to 3.3V) and two of them as pull-down resistors (connect to GND). I do need these resistors to make it works while some people don't.
- GPIO15 (grey) -> pull-down
- GPIO2 (blue) -> pull-up
- GPIO0 (purple) -> pull-up
- CH_PD (green) -> pull-up
- REST (orange) -> pull-up
- TXD (black) -> Arduino TX (pin D1)
- RXD (white) -> Arduino RX (pin D0)
- VCC (red) -> breadboard V+ rail
- GND (brown) -> breadboard GND rail
- Arduino 3.3V (red) -> breadboard V+ rail
- Arduino GND (black) -> breadboard GND rail
If you are lucky enough, you should be able to run AT Commands by now. If you are not, don't be sad, you have the chance to explore the fun of flashing firmware later. Just keep reading ;-)
Step 3: Arduino Serial Monitor
- Plug your Arduino to USB port.
- Open your Arduino IDE.
- Open the "Tools" menu.
- Select your board : Arduino/Genuino Uno.
- Select your Arduino COM port.
- Open Serial Monitor.
- On the bottom right part select "Both NL & CR"
- Then select your serial baud rate. My esp-12 default is 9600. Some got 115200 for default.
Some people get "Ready" on their serial monitor screen but I don't. To test if it works or not, type "AT" (without double quotes) and press enter. If it works, you will get a reply message "OK". Then you can continue with other AT Commands listed here:
If it doesn't reply "OK" to you, then continue to next step.
Step 4: Putty Terminal Emulator
Here I use Putty Terminal Emulator on Windows 10.
- Pick "Serial" on the radio button.
- Type in your Arduino COM port on "Serial line".
- Type in "76800" baud rate on "Speed". This is default speed for ESP8266 boot message.
- Press the "Open" button.
By looking at your boot message, you can search what kind of problem that prevent your ESP-12 communicating through AT Commands. In my case I got this message :
ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x40100000, len 25020, room 16 tail 12 chksum 0xef ho 0 tail 12 room 4 load 0x00000000, len 0, room 12 tail 0 chksum 0xef load 0x00000000, len 0, room 4 tail 0 chksum 0xef csum 0xef csum err ets_main.c
Searching on the net, I found the solution the next day saying that we should flash the firmware with SPI mode : DOUT (Dual Read Operation). I was following the instructables by RaviP6 for flashing esp8266 firmware and I flashed successfully, only that AT Commands still not working and I got that error message at boot. Back to the flasher tool, there is no "DOUT" option as mentioned can fix the problem. Keep searching the net and I found another more advance flasher tool with more options.
Step 5: Flashing a Firmware
- For flashing a new firmware to ESP-12 we need to put the GPIO0 to pull-down resistor (purple wire).
- Download ESP Flash Download Tool V1.2 to your local drive and unpack it on a folder.
- Download ESP8266_AT_V00180902 Command Firmware and unpack it on the same folder with Flasher Tool so that it will be easier to find.
- Run Flash_Download_Tool_v1.2.exe
- Pick your downloaded firmware into Download Path Config.
- Set the ADDR : 0x00000.
- Set the SPI Mode : DOUT.
- Set your Arduino COM Port.
- Set the baud rate 115200 (or 9600).
- Press the start button.
Hopefully everything goes well or you might get another version of ESP-12 with different problem to solve :D
Now put back the GPIO0 wire (purple) to pull-up resistor and reset your ESP-12.
Go back to Step 3 (Arduino Serial Monitor) to see if the AT Commands is now working or not.
Good luck, Pals. Please share in comment section if you encounter different problem or you have solution to any ESP-12 Getting Started problem ^_^