blog.hirnschall.net
home

Contents

Subscribe for New Projects

Introduction

In recent years the ESP8266 has become one of my go-to choices for smart home/IoT devices or projects requiring WiFi. It is cheap (around $1.5 on Amazon)1, has WiFi, and can be programmed using the Arduino IDE, making it an easy replacement for Arduinos if we need WiFi connectivity.

While the ESP8266 can be used with the original AT firmware as a WiFi module for other microcontrollers like an Arduino, we will concentrate on writing our own replacement firmware in this post. Our firmware lets us replace the Arduino with an ESP module, simplifying programming and assembly and reducing cost.

This post shows how to setup the Arduino IDE to work with the ESP8266 module and how we can use a spare Arduino as a USB to serial converter for programming the ESP module. It is part of a complete ESP8266 reference you can find here.

Programming ESP8266 with Arduino IDE

An esp8266 is a cheap and easy way to add WiFi connectivity to your Arduino projects. However, an esp8266 can replace the Arduino entirely for smaller projects, making the project way cheaper, much smaller, and easier to program. As the esp module lacks a serial to USB converter, we'll use an Arduino to program it.

Arduino IDE setup

As mentioned above, we'll use the arduino IDE to program the esp8266. (Download Arduino IDE here) We first have to add the esp board. To do so, navigate to File>Preferences and add:

http://arduino.esp8266.com/stable/package_esp8266com_index.json
adding esp8266 board module source to arduino ide
Figure 8.1: Adding an additional Boards Manager URL

Next, we need to install the esp board using the boards manager (Tools>Board:"">Boards Manager...). Search for esp8266 and press install.

installing esp8266 board module to arduino ide
Figure 8.2: Installing the esp8266 board

Ok, after selecting "generic esp8266  module" as seen in the figure below we are all set and can continue with wiring everything up!

selecting esp8266 board module in the arduino ide
Figure 8.3: Selecting the esp8266 board

Connect ESP8266 to Arduino

We can enter programming mode by pulling the esp's gpio 0 pin low on boot. That is, disconnect the esp from GND, connect the esp's gpio 0 to GND, and reconnect the esp module to GND. Suppose you have connected the Arduino and opened a serial monitor on the connected port beforehand. In that case, you should see a message from the esp indicating that it has entered programming mode. It is also crucial that we connect the Arduino's reset pin to ground. 

Fig. 8.4 below shows a pushbutton labeled "FLASH" to connect gpio 0 to ground during the boot process. You do not have to use a button to do so. I usually use a spare jumper wire to make the connection and disconnect it from GND if I want to boot the esp normally.

wiring diagram for programming an esp8266 esp-01, esp-07 and esp-12 module with Arduino ide
Figure 8.4: Schematic for programming an esp8266 using an Arduino uno

This sketch uses an esp8266 esp12 board. If you want to program an esp module:

Programming the ESP8266

We can now hit upload like we would programming an Arduino board. Once finished, disconnect the gpio 0 pin and restart the esp module.

More Info

This post is part of a complete ESP8266 reference/guide. You can find more information on how to use your ESP8266 module effectively at blog.hirnschall.net/esp8266/.

Get Notified of New Articles

Subscribe to get notified about new projects. Our Privacy Policy applies.
Sebastian Hirnschall
Article by: Sebastian Hirnschall
Updated: 25.06.2023

References

Visited on 26.06.2023:
[1] Stefan Frings: ESP8266 und ESP8285 WLAN Module
[2] https://github.com/esp8266/Arduino/tree/master/libraries/EEPROM
[3] https://github.com/esp8266/Arduino/tree/master/libraries/esp8266/examples/LowPowerDemo
[4] Erik H. Bakke: ESP8266 WiFi power reduction – Avoiding network scan, 2017
[5] Erik H. Bakke: Reducing WiFi power consumption on ESP8266, part 1, 2017
[6] Erik H. Bakke: Reducing WiFi power consumption on ESP8266, part 2, 2017
[7] Erik H. Bakke:Reducing WiFi power consumption on ESP8266, part 3, 2017
[8] Espressif: ESP8266ex datasheet
[9] Espressif: ESP8285ex datasheet
[10] AI-Thinker: ESP-01/07/12 Series Molules User's Manual, v1.3, 2017
[11] AZ-Delivery: ESP8266-01S Modul Datenblatt
[12] Doit: ESP-1 WiFi Module, v1.0, 2017
[13] Michel Deslierres: ESP8266 Watchdogs in Arduino, 2017
[14] Espressif: ESP8266 Hardware Design Guide, 2023

License

The content published on this page (with exceptions) is published under the CC Attribution-NonCommercial 3.0 Unported License. You are free to share on commercial blogs/websites as long as you link to this page and do not sell material found on blog.hirnschall.net/* or products with said material.

Amazon Links

1: As an Amazon Associate I earn from qualifying purchases.