ESP8266 Part 1 – Make it blink! (EN)

Auf der Suche nach dem deutschen Tutorial ? Hier klicken!

The ESP8266 WiFi Modul has been around for some time now and it’s popularity is still unbroken. No suprise: for less than 5$ you can get a simple module that enables your project to talk to the internet and for about 10$ you can get a breadboard-friendly board, which includes a USB-to-Serial Converter IC so it can be programmed directly via USB. In this tutorial series i’m going to show you how you can build your own Internet of Things Project with the ESP8266. Lets get started!

1. Overview

 

There wasn’t much documentation and information about the ESP8266 available when the first modules hit the market, luckily for us that has since changed and by now you can even program it directly from the Arduino IDE. The latest breakout boards are suitable for the use on breadboards and even include level shifters, 3.3V voltage regulators and usb ports which make the programming super easy.

In this article i’m going to show you how to program a ESP8266 on a breakout board with the Arduino IDE. You need the following parts:

 

2. Install the right drivers

esp_treiber

CH340G on the NodeMCU Dev Board 1.0

In order to get your ESP8266 to talk to your computer you may need a special driver, depending on the usb-to-serial converter chip used on your board and the operating system on your computer. Take a look at the engraved name of the chip on your breakout board or take look in the datasheet to find out which driver you need. Then find the suitable one on the internet or take a look at this (not complete) list :

USB-to-Serial ICWindowsMac OS XLinuxBoards
CH340GTreiber ab Windows 7Signierter Treiber Schon enthaltenNodeMCU Dev Board V1.0
FTDIFTDI TreiberFTDI TreiberFTDI Treiber
CP2102CP2102 Treiber ab WinXPCP2102 Treiber ab WinXPCP2102 Treiber ab WinXPUSB-to-Serial Konverter

You got a board with a driver not listed here ? Leave a comment and i will add it to the list.

 

3. Prepare the Arduino IDE

esp_install1

Add additional board manager URLs

In order to program the ESP8266 with the Arduino IDE you first have to install the ESP 8266 core. The newly introduced Board Manager in version 1.6.4 of the Arduino IDE makes this very easy.

Just add the following URL under Preferences/Additional Board Manager URLs:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Then you can search for the ESP8266 package under Tools/Board/Board Manager and install it. After the installation you are nearly ready to program your ESP8266.

4. Connect to you computer

esp_boards1Congratulations if your  board as a USB port, just connect it to your computer and choose the right Board&Port in the settings and you are done.

If your board hasn’t got a usb port like the Adafruit Huzzah Board your first have to connect it to your USB-to-Serial-Converter.

Check the documentation of your board to set it up. You can find the documentation for the Adafruit Huzzah Board on the Adafruit Learning Platform.

 

5. Make it blink!

Most of the ESP8266 Modules have a LED on GPIO 0. Lets make it blink!

You can modify the standard blink sketch or write your own. Just use the Variable BUILTIN_LED as the pin.

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     
}

void loop() {
  digitalWrite(BUILTIN_LED, LOW);                            
  delay(1000);                      
  digitalWrite(BUILTIN_LED, HIGH);  
  delay(1000);
} 

Last step: Upload your sketch to the board. The ESP8266 has to be in bootload mode to be programmed. The NodeMCU Dev Board 1.0 comes with a auto reset function that takes care of this automatically if you press on Upload inside of the Arduino IDE. To program the Adafruit Huzzah Board you have to do this manually. But don’t worry, it is pretty easy :

  1. Press and hold the GPIO0 button -> the red LED lights up
  2. Press Reset
  3. Release Reset
  4. Release the GPIO0 button -> the red LED remains dimly lit
  5. Now the ESP8266 is in Bootload mode

Upload your Sketch on the ESP8266.

 

This may take a while, because the Arduino IDE compiles and uploads a whole firmware each time you change the sketch, so be patient 😉

If everything worked out you now should see the LED on your board blink!

That’s it for the first tutorial! If you have problems or you found a mistake in this tutorial (i’m not a native speaker 😉 ) just share it in the comments. Thank you very much!

Next time we are going to connect our ESP8266 to the internet and send some simple sensor data into the cloud. Stay tuned!

Das könnte Dich auch interessieren...

Kommentar verfassen

%d Bloggern gefällt das: