Cannot run WiFi sketch on ESP-01 I can upload simple sketch on my ESP-01 like:

void setup() {
  Serial.begin(115200);
  Serial.println("Hello there"); 
}
void loop() {
  Serial.println("Hello from loop");
  delay(1000);
}


I also ran successfully the sample ESPWebServer -> HelloServer

But if just modify my sketch to include #include &lt;ESP8266WiFi.h&gt;

#include &lt;ESP8266WiFi.h&gt;

void setup() {
  Serial.begin(115200);
  Serial.println("Hello there"); 
}
void loop() {
  Serial.println("Hello from loop");
  delay(1000);
}


I got this result in the serial monitor:

  ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld


My ESP-01 is connected to my computer through FT232RL FTDI with the following cabling:


FTDI GND - GND
ESP TX - FTDI RX
ESP RX - FTDI TX
ESP VCC - VCC 3.3V
ESP GND - GND
ESP CH_PD - VCC
ESP GPIO2 - VCC
ESP GPI00 - GND to upload sketch, VCC to run sketch


Here is a picture of my cabling (the USB of both the TTL and power supply MB102 are connected to my laptop):



Also, regularly my sketch fails to load correctly:

-Sometimes it does not load at all and I get this after compilation before uploading starts:

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed


- Sometimes it fails at the end of the upload:

Uploading 256064 bytes from C:\Users\20000263\AppData\Local\Temp\arduino_build_32221/ESP01-Basic.ino.bin to flash at 0x00000000
................................................................................ [ 31% ]
................................................................................ [ 63% ]
................................................................................ [ 95% ]
..........warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed


Any idea about what is wrong ?
FTDI adapters often don't provide enough current to run the power-hungry wifi features of the ESP8266. So as soon as you fire up wifi, you brownout the chip and cause it to reset.

Use a battery, a dedicated ESP8266 flasher, a 3.3v LDO, or something besides the on-board 3.3v connection the USB-Serial adapter provides.