My image

Getting Started With the ESP8266 Chip

The ESP866 is a tiny WiFi chip that has the huge advantage to come at a ridiculous price point: $5. And the best is that this chip also has a small processor onboard, so it can actually function in complete autonomy, without an additional Arduino board for example. Compare that to the cost of a traditional Arduino + WiFi module solution (around $40), and you will immediately see why this chip is receiving so much interest these days.

All of this makes it the perfect piece of hardware for connected home automation projects. In this article, which is the first one in a series of articles dedicated to the ESP8266, we’ll stick to the basics. We will see how to choose an ESP8266 module, what other components you need, how to configure the chip, and finally how to connect it to your WiFi network. To program the chip, we’ll simply be using the well-known Arduino IDE. Let’s start!

How to Choose Your ESP8266 Module

We are first going to see how to choose the right ESP8266 module for your project. Indeed, there are many on the market, and it’s quite easy to get lost between all the choices.

The first one that you probably heard of is the small ESP8266 Serial Wireless Transceiver module:

This module is the most famous one, as it is really small and only costs $5. However, the number of accessible GPIO pins (outputs or inputs pins) are quite limited. It is also difficult to plug it on a breadboard.

But there are many other modules on the market, that gives you access to all the pins of the ESP8266. For example, I really like the ESP8266 Olimex module which is also cheap (around $10):

This module can easily be mounted on a breadboard, and you can easily access all the pins of the ESP8266. This is the one I will use for the rest of this article, but you can perfectly follow along with any ESP8266 module.

Hardware Requirements

Let’s now see what we need to make the ESP8266 chip work. Indeed, it is usually wrongly assumed that you just need this little chip and nothing else to make it work, and we are going to see that it is not true.

First, you will need some way to program the ESP8266. You can use an Arduino board for that, but for me the really great thing about the ESP8266 is that it can function completely autonomously. So for to program the chip, I will use a USB FTDI programmer. Note that it has to be compatible with the logic level of the ESP8266 chip, so 3.3V. I used a module that can be switched between 3.3V and 5V:

You will also need a dedicated power supply to power the chip. This is a point that is often forgotten and that leads to  a lot of issues. Indeed, if you are for example trying to power the ESP8266 chip from the 3.3V coming from the FTDI board or from an Arduino board, it simply won’t work correctly. Therefore, you need a dedicated power supply that can deliver at least 300 mA to be safe. I used this breadboard power supply that can deliver up to 500 mA at 3.3V:

This is a list of all the components that will be used in this guide:

Hardware Configuration

We are now going to see how to configure the hardware for the first use of your ESP8266 board. This is how to connect the different components:

And this is how it will look like at the end:

Make sure that you connected everything according to the schematics, or you won’t be able to continue. Also make sure that all the switches of your components (FTDI module & power supply) are set to 3.3V, or it will damage your chip.

Also, connect one wire to the pin 0 (GPIO 0) of the ESP8266. Don’t connect it to anything else for now, but you will need it later to put the chip in programming mode.

Configuring Your ESP8266 Chip

We are now going to configure your ESP8266 chip using the Arduino IDE. This is a great way to use the chip as you will be able to program it using the well-known Arduino IDE, and also re-use several existing Arduino libraries.

If this is not done yet, install the latest version of the Arduino IDE. You can get it from:

http://www.arduino.cc/en/main/software

Then, you need to take a few steps to be able to configure the ESP8266 with the Arduino IDE:

  • Start the Arduino IDE and open the Preferences window.

  • Enter the following URL: http://arduino.esp8266.com/package_esp8266com_index.json into Additional Board Manager URLs field.

  • Open Boards Manager from Tools > Board menu and install the esp8266 platform.

Now, we are going to check that the Arduino IDE is correctly working, and connect your chip to your local WiFi network.

To do so, we need to write the code first, and then upload it to the board. The code is will be quite simple: we just want to connect to the local WiFi network, and print the IP address of the board. This is the code to connect to the network:

// Import required libraries
#include "ESP8266WiFi.h"

// WiFi parameters
const char* ssid = "your_wifi_name";
const char* password = "your_wifi_password";

void setup(void)
{ 
// Start Serial
Serial.begin(115200);

// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Print the IP address
Serial.println(WiFi.localIP());

}

void loop() {

}

You can simply copy the lines of code above, and copy them into the ESP8266 Arduino IDE that you downloaded before. Of course, put your own WiFi name & password in the code. Save this file with a name of your choice.

Now, also go in Tools>Boards, and select the board you are using. If you are not sure about which board to choose, simply choose “Generic ESP8266 Module”. Also select the correct Serial port that corresponds to the FTDI converter your are using.

After that, we need to put the board in bootloader mode, so we can program it. To do so, connect the pin GPIO 0 to the ground, via the cable we plugged into GPIO 0 before. Then, power cycle the board but switching the power supply off & then on again.

Now, upload the code to the board, and open the Serial monitor when this is done. Also set the Serial monitor speed to 115200. Now, disconnect the cable between GPIO 0 and GND, and power cycle the board again. You should see the following message:

WiFi connected
192.168.1.103

If you can see this message and an IP, congratulations, your board is now connected to your WiFi network! You are now ready to build your first projects using the ESP8266 chip & this modified Arduino IDE.

How to Go Further

You now have a completely usable ESP8266 module, so basically what you can do next only depends on your imagination! You can for example use this chip to build a WiFi motion sensor, to control a relay remotely, and also to send data to a remote cloud platform.

I will post articles about applications of this board in the coming weeks, but in the meantime don’t hesitate to experiment with this amazing little WiFi board and share your projects in the comments!