Cannot program ESP8266 :(

Blue led is blinking after powering up the module, the red one stays on, I can even connect to it via wifi. But I cannot program it. I tried Arduino IDE, different firmware flashers (Like NodeMCU, XTCOM). I'm using Arduino Mega.
Here's my initial setup:

VCC - 3.3 V on Arduino
RST - nothing
CH_PD - 3.3 V on Arduino
TX - RX on Arduino (TX is transmitting data to RX, so I don't need a voltage divider, right?)
RX - voltage divider (R1 = 10K, R2 = 20K) - TX on Arduino
GPIO0 - GND on Arduino
GPIO2 - nothing
GND - GND on Arduino

Then I tried uploading a sketch from the Arduino IDE and got the following error:
warning: espcomm_sync failed
error: espcomm_open failed
After trying different IDEs, programmers, serial port I tried firmware flashers to at least see if I can communicate with it. NodeMCU for example just
showed "Waiting MAC" with GPIO0 to ground and without.
I also tried connecting TX to TX and RX to RX but got the same results. Tried connecting RX through a voltage divider as well.
With this setup the blue led was constantly on. I remembered reading somewhere that that could happen due to insufficient power supply,
so I also tried connecting both pins without the voltage dividers (the blue led is still blinking after the power up so hopefully I didn't burn them).
I also tried connecting GPIO0 to 3.3V and not connecting it to anything at all, connecting RST to 3.3V, connecting GPIO2 to ground as well.
On Mega there are 4 sets of TX and RX pins, so I tried them all out TX/RX0,1,2 and 3.
Still no idea what's going on :frowning:

Here is the picture. Did it according to this tutorial:

I also tried using two 1.5V AAA batteries instead of Arduino's power supply like this:
VCC --- battery +
RST ---
CH_PD --- battery +
TX --- arduino RX
RX --- arduino RX
GPIO --- battery -
GPIO2 ---
GND - battery -
Apart from this I connected the GND on arduino to battery's - to ensure common ground. I'm not sure though if there's any difference depending on which of the 3 GND pins on Arduino you connect. Also tried swapping TX and RX. Tried another voltage divider with 100 ohm and 220 ohm as well as connecting TX and RX directly.
The only difference I noticed when using a separate power supply is that when you connect the GND on Arduino to the common ground, even though GPIO0 isn't "grounded" the blue led on ESP8266 doesn't blink and I can't see the SSID from my phone/PC. If you leave it like this:

VCC --- battery +
RST ---
CH_PD --- battery +
TX ---
RX ---
GPIO ---
GPIO2 ---
GND - battery -

it works just the same. Led is blinking during the power up and you can connect to the access point.
Any ideas? :frowning:

Did you measure the 3.3volt rail.
AFAIK, a Mega can only supply 50mA, and your module needs 60-200mA.

I had some problems at the beginning like you:

1- use a 7111 3.3V regulator to power the ESP.
2- do not used voltage divider, the ESP RX handel to manage with Arduino Tx 5V, its all good (I tried 2 resistance divider & the transistor way, both fails). The arduino Rx accepts the 3,3V from ESP Tx.
3-The SSID of the network you may want to connect should have EXACTLY 10 digits (and I used 8 digits as paswd, but not sure how robust the firmware is for pswrd, 8 digits works)
4-used AI-v0.9.5.0 AT Firmware and the AT commands works and connect to another AP,
5- used nodemcu_float_0.9.6-dev_20150704 and also kicks, so with the ESPlorer.
6-Watch out the arduino Tx and Rx pins, the are confusing, dont get wrong with this, probable is the wiring is the opossite we all may think, because its confusing.

Hope it helps.

Been in working mode (GPIO0=high), when you reset (power off and then On), the blue led should blink about twice, since the 1st thing the ESP does is to send the firmware version via Serial.

i know this does not directly answer your question, but you also might consider programming directly from the IDE rather than using a Arduino Mega as a broker.

No Arduino is needed, just use the IDE.

that is the road that I have taken with the esp8266 and it has worked very well.

you will need a USB->TTL serial converter to do this, but these cost less than $12

there is a really good end-to-end set of instructions including parts needed, wiring and software at:

i followed this tutorial's instructions and everything worked flawlessly up to and including actually logging data to the cloud.

food for thought