Blink

 blink_wififritsing

This will be the first example. Let’s start with an easy one.
Let’s blink a led.
This example is using 2 transistor be able to use serial monitor from arduino as well.

This example explains blink by using a USB-TTL connector that support DTR and Reset (RST).Use this blink_manual_flash example if your USB-TTL connector does not support DTR and Reset .

If you have 2 NPN transistors available, this is the recommended example of blink, otherwise you might choose this example

Shopping list
– 1 ESP8266 (for example version ESP01)
– 2 resistors (10K ohm or 12K ohm or what you have on shelf)
– 2 transistor NPN (2N3904 or 2N2222 or S8050)
– 1 led (I use a red one)
– 1 USB to TTL (I use FT232RL)
– 12 wires
– 1 breadboard
– a 3.3V power source (I use an battery in this example, power from your USB TTL will most likely might NOT work)

Hardware
TTL to ESP01 blink NPN

The wires should be connected like this
[table caption=”” width=”500″ colwidth=”20|100|50″ colalign=”left|left|left|left|left”]
USB TTL, ESP8266 ESP-01, Breadboard
GND, GND,
,GND, GND
TX, RX,
RX, TX,
RTS,,Second Transistor E-leg
DTR,,First Transistor E-Leg
,RST,First Transistor C-leg
,GPIO0,Second Transistor C-leg
,CH_PD,+3.3V
,VCC,+3.3V
,,
Led longleg, GPIO2,
Led shortleg, GND,
Battery,, GND (-)
Battery,, 3.3V (+)
,,
First Transistor E-leg, First Resistor, Second Transistor B-leg
First Transistor B-leg, Second Resistor, Second Transistor E-leg
[/table]
For anyone who prefer an electronic schema, this is the part how to connect the ESP8266 to TTL using 2 resistors and 2 transistors

ESP8266 upload with NPN schema

Coding
Actually this is the same example as you may find in Files->Examples->01 Basics-> Blink.
ledPin = 2 means that we are using GPIO2.

[cpp]
int ledPin = 2;
void setup() {
pinMode(ledPin, OUTPUT);
}

void loop() {
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
[/cpp]

Uploading
Press upload in the Arduino IDE, arduino will compile and upload. After the sketch is uploaded, the led will blink for one second on and off.

Blinking
When you have uploaded the sketch, you may remove all the wires required for uploading.
This is what is left.ESP8266 ESP01 blink

15 thoughts on “Blink

    1. i have done all connection but using arduino uno. But there is an error while loading program if i connect Rx to Tx and Tx to Rx.But if i have done vice versa ,program get uploaded but my led not blinked this time.What is the problem ?
      I have used github library for esp8266,but i am confused which library i select generic esp,nodemcu esp and many more?? i havve esp8266 which i bought for $3.
      If I am using serial monitor to send “AT ” directly to essp8266,it is not responding.What is the probblem????

  1. Hello,

    I did this setup… and I managed to upload the sketch. Nevertheless, I must pull GND manually every time as soon as I click UPLOAD and reconnect it again for it to work (I discovered this almost by chance).

    1. It is not supossed to work automatically everytime you want to upload thanks to the transistors and resistors trick?

    2. Does the value of the resistors matter? I didn’t have 10K oms, so I used 560 Ohms.

    Thanks,

  2. Your shortcodes aren’t working for tables and code, can you please fix it? It’s a bit annoying to have to create a CSV just to see the connections you are making.

  3. Nice tutorial man! Thanks! For the first time in a week I managed to make some progress with programming my ESP01!

    I still get an error though:

    error: failed reading byte
    warning: espcomm_send_command: cant receive slip payload data

    Any ideas what this means?

    I also noticed that in your diagram you connect the RST pin from ESP8266 to the C leg of the second transistor. And you also connect GPIO0 to the C leg of the first transistor. However in the table you have, you’re saying that the RST pin should go to the first transistor and GPIO0 should go to the second. Which one is correct?

Leave a Reply