ESP8622 Then there was trouble

michael Arduino, Michael

First some context.  I’ve been working on hacking my electronic dog door.  I will show the complete hack later on.  But part of the project is to start connecting things to the internet so that I can monitor and control them remotely.  The dog door might seem like a somewhat rediculious example of an item that needs to be connected to the internet of things. But no one wants their dog having accidents in the house. By tracking and notifying me of when the dog goes in and out it could help avoid a problem, like if the door stopped working and the dog is forced to “go” indoors.  And it’s a test case.  Out of necessity it is the first item I’m working on. But eventually I will have lights and door locks and other things controllable from my phone.

There is a TON of noise on the web about the ESP8622 and all of it’s flavors.  I don’t want to rehash detail that is already out there.  But for my own record and so I can reference back here later, and to help others avoid the same pitfalls, I’ll quickly cover my experience setting up the tiny wifi module.

My son loves Thomas the Tank Engine and almost every episode the narrator will say “And then there was trouble”.  Thomas is little but he does get in to a lot of troube.  This little wifi unit does too. And if you’re not careful it can puff a little smoke like Thomas does.

Actually this little module has been competely infuriating.  I initially ordered 2 modules.  I bricked the first one to where it would only return error messages back.  The second one I accidentally burned up. At that point I almost just gave up completely.  But then I ordered 3 more… and bricked the first one of those as well. So here are my pitfalls:

Pitfall 1 – 5v vs 3.3v = smoke


I knew that the unit had to be powered with 3.3v instead of 5v.  That warning is everywhere.  But when I attached it to my FTDI board so I could work on it directly (instead of thru arduino) at some point I looked over and smoke was coming up from it.  My pitfall was simple and should have been avoided.


I assumed the 3v3 pin would be 3.3v. I should have checked the voltage before hooking it up. I checked it after and it was 5v. Here’s why:


By default that FTDI board comes prejumpered to 5v. I had to cut the trace and solder a jumper to the 3.3v.

Pitfall 2 – Setting the baud rate

Incorrectly setting the baud rate can brick the unit and make it only return an endless string of error messages.  DO NOT use AT+IPR.

Pitfall 3 – Setting the baud rate

Incorrectly setting the baud rate cab brick the unit by making it so you can’t communicate with it.  My mistake was two fold.  The main one was using AT+UART= instead of AT+UART_CUR=. The latter only sets it temporarily so you can test the setting first.  That way if you set it to a setting where you can’t get it back, you just cycle power.  Then once you have a setting that you know works you can do AT+UART_DEF.  Once I did the AT_UART= I was never able to communicate with it again.  The correct setting for me is AT+UART_DEF=9600,8,1,0,0.

Other Troubles

The other troubles I had were just getting around the AT commands and getting a lot of ERRORs back.  For example if you do it out of the gate AT+CWLAP will just return ERROR.  Maybe this is fixed in newer firmware.  But I found an order of things that seemed to help.  Without going through all the sends and responses, I’ll just list the order of commangs that got me connected to my wifi network:

OK [Then switch the serial monitor to 9600 and test that it's working with..]
[Lists of wifi networks]

If I did the CWLAP before changing the CWMODE it returned an error.  And I was also unable to connect to my network without first listing the networks.

I still don’t have this unit working via arduino, but I’m on the right track.


You can unbrick these modules by reflashing the firmware. Oh man was that trouble!

First, I’m on a mac and most of the flashing tools are made for windows. But that’s acutally not too bad since there is a flasher for linux. The real problem was finding the right firmware. Some sites have links to these SDKs which I think actually have usable firmware in the bin folder.  But which ones are you supposed to use with the ESP01 model?  And you have to use multiple files and flash them into different memory locations.  There’s a chart but it’s still very confusing.  Also I want the same firmware that my other non-bricked units have.  On my units doing AT+GMR shows this:

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

To find this same firmware was near impossible. Some websites take you to a chinese website where everything is in chinese. Others take you to the downloads area where again they have SDK zips. I wanted a single file to flash to the firmware.  And I finally found it here: File:V1.3.0.2 AT – ElectroDragon With the esptool installed and that file I was able to do:

sudo python --baud 921600 --port /dev/tty.usbserial-A700fbUH write_flash -fm dio 0x000000 v1.3.0.2\ AT\ Firmware.bin

I was able to restore the two bricked units to “factory”.

Some tips on that esptool. First tip – you can find your port by doing:

ls /dev/tty.*

Next tip – when you’re doing it have the firmware binary in the same folder as the esptool. Whether you copy and paste or type it in, only go to where the filename starts.  Type the first couple characters of it like “v1.3” and then hit tab. Mac Terminal will autocomplete and you can avoid trying to figure out all of the escape commands for the spaces.

Last tip – when flashing, as other sites have said, connect GPIO0 to gnd. Do the command. Then unplug the USB, remove GPIO0 from gnd and leave it floating. Then plug it back in and check it.


Just a whole mess of links to pages I used to figure it all out: – A thread on the esp forum where I posted about the firmware flashing issues. – A useful page on flashing the firmware using esptool. – Another useful page flashing with a mac. And some useful comments as well. – esp forum thread that says not to do AT+IPR. – Page about wiring to FTDI – don’t forget to check the voltage. – decent page on wiring for flashing firmware. – Kevin Darrah’s youtube series on the ESP8622. The 3rd video was the best one for me.