Getting Started with ESP8266


Adafruit Huzzah ESP8266

Wanting to try out the ESP8266, but reading about the difficulties connecting to and interfacing with the bare module, I opted for the Adafruit Huzzah ESP8266 breakout board.

The breakout board takes care of various things, making it easier to work with ESP8266:

  • reset and user button
  • onboard LED
  • level-shifting
  • regulated output voltage
  • breadboard friendly pinout

The breakout board costs about $10, making it an ideal, hassle-free, first experience with the ESP8266.

Connecting to the ESP8266

To connect to the ESP8266 and pass commands to the Lua interpreter, a console cable is required.

Ideally the console cable has four connectors:

  • Power (V+)
  • Ground (GND)
  • Receive (RX)
  • Transmit (TX)

In some cases however, only three connectors could be present on the console cable, omitting the power connection. In that case, the ESP8266 needs to be powered separately. Powering the ESP8266 from an external power supply can be done using a 3.5-16V power supply connected to the V+ and GND pins. When applying power, the onboard LEDs (red and blue) will briefly light up and turn off again.

Screen Shot 2016-03-13 at 16.28.56

Once the cable is connected and the ESP8266 powered on, a serial terminal can be used to access the interpreter. On Windows you could use PuTTY to do that, I’m using “screen” on OSX.

After connecting, press the reset button on the ESP8266 board and the following should appear:

I was wondering about the error message displayed. It is however normal and expected. The file init.lua is a file that is executed when powered on. It can be used to have the ESP8266 automatically connect to the network every time it’s booted for example.

First commands


Let’s start with the “Hello World” of electronics: blinking an LED.

On the command line interpreter, type the following commands. The “–” are used to indicate a comment.

The prompt won’t return due to the infinite loop. The only way to abort, is to use the reset button.


Let’s take this a step further and connect to the network using Wifi.

That’s all there is to it. To verify the ESP8266 is connected, it’s possible to request its IP address:


Commands entered as above are lost when the ESP is restarted. To make them persistent, they need to be saved to a file.

The file that is attempted to be read every time the module is powered on, is called “init.lua”.

Using the following commands, code can be persisted:

If you make a mistake and your module is stuck in an infinite loop, the only way to stop it, is to flash the module. This will erase the init file and allow you to reprogram it.

Flash Firmware


NodeMCU Firmware

The first thing you’ll need is a firmware file. There are different types of firmware available for the ESP. In this guide, I will cover NodeMCU.

Download the latest firmware file from The latest version at the time of writing is 0.9.6.


The second thing you’ll need is a flashing application. I mostly came across “EspTool”, which is a Pyhton script.

You can download it using the following command:

Make sure you have PySerial installed for EspTool to work properly:

Extract the downloaded package and install it.


To be able to flash the ESP module, it needs to be put in programming mode. This is achieved by pressing the reset button while holding the GPIO0 button. You’ll know you are in programming mode when the red LED remains lit on.

On the command line, run EspTool and provide the correct serial interface and firmware file. The flashing process should take about a minute.

If the prompt does not reappear, try pressing the reset button. You should now see the new version being reported.


Even though programming is possible via the command line interface, there are tools available to facilitate the process. One of those tools is ESPlorer, a Java application with syntax highlighting and many more features such as sending code or writing files on the ESP8266.

ESPlorer can be downloaded from Make sure Java is installed or the application won’t run.

Screen Shot 2016-03-13 at 00.15.33 Screen Shot 2016-03-13 at 15.47.36

Example: IoT Doorbell

As an example application, I created a simple, internet-connected doorbell. When the GPIO0 button is pressed, an event is sent using the IFTTT Maker channel, triggering a notification on my smartphone.

On IFTTT, create a new recipe and set up the necessary trigger and action.

Screen Shot 2016-03-13 at 16.05.50

Program the ESP8266 to trigger when the GPIO0 button is pressed, with the following code:

Keep in mind this is my first real ESP program and it’s probably far from perfect. For some reason the trigger keeps happening after the initial one, even though the state of the button is restored. As a workaround, I restart the ESP after triggering the notification. Will update the code when I manage to fix that glitch.

The result, is as expected. A notification appears on my phone within a few seconds of pressing the button.


And that’s it! First IoT project using the ESP8266 complete!


© Frederick Vandenbosch, 2014-2019. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.