Some days ago, I wanted to program an ESP8266 module but somehow it sort-of always failed. Small program worked, but soon I added more into it, it started to fail. The upload process will get stuck and sometimes it eventually finished. But still, I could not get the program to run. If I checked through the serial console, I got the following message, or something similar.
ets Jan 8 2013,rst cause:4, boot mode:(3,7)
I also tried to do the connection more properly, by adding pull-up/down resistors and capacitor, but it did not help. Googling did not give the help that I needed until I someone mentioned to check the serial adapter. Could that be the problem?
The adapter I used was something like the following.
So then I ordered a new one like the following from China.
Ordering something from China will take approximately 2-3 weeks and I really wanted to see the project I was working on running. Could not wait! Fortunately, I stumbled upon an article showing how to use Arduino to program the ESP module. It’s basically making the Arduino as a USB-to-Serial adapter so then we can program the module. I tried the method, with some modifications, and it worked! Here I want to show how I did it.
Before we continue, according to what I read, Arduino ports work at 5V and on the other hand, ESP8266 work at 3.3V level and does not have tolerance to 5V. Signals from Arduino can potentially kill the ESP8266 module. I actually forgot to realize this and just continued with connecting the ports directly. Fortunately my ESP module still survive but your mileage may vary. So, be careful! The more proper way to handle this issue is to create a level shifter by, for example, using a voltage divider.
Using 1KΩ on R1 and 2KΩ on R2, we can get 3.3V signal from the 5V source.
Another thing to consider is the current supply to the ESP8266 module. The module may consume up to 215mA and Arduino can only supply up to 200mA. This should not be a problem for programming but if you get trouble from this, try to find a dedicated power supply for the ESP8266 module. A bread board power supply should do the trick from my experience.
So.. let’s start by creating the connections.
- Arduino TX to ESP8266 TX
- Arduino RX to voltage divider input
- Voltage divider output to ESP8266 RX
- Arduino RESET to GND
- Connect all the GNDs
- Arduino GND
- ESP8266 GND
- Voltage divider GND
- Breadboard power supply GND
- Breadboard power supply 3.3V to ESP8266 VCC
- ESP8266 CH_PD to 3.3V through 10KΩ resistor
- To enable programming mode, connect ESP8266 GPIO0 to GND through 10KΩ resistor
We should have something more or less like the following.
Once everything is ready, connect the Arduino to the USB and power up the breadboard power supply. The ESP module should be ready to program. If you use Arduino IDE, select the ESP8266 board and the USB port you use.
I have been using the above method for some time and it mostly work. Yeah, there are cases where I the programming fails somehow. I don’t know what caused that but turning the module off and on again, and try the upload again, usually did the trick.
Hope this helps.