ESP8266 Getting Started

From West London Hackspace Wiki
Jump to: navigation, search

The easiest way to get started is with the NodeMCU module because it deals with the supply voltage, USB-serial and brings the connections out to breadboard-friendly pins. Other similar development modules such as the ESP-201-DEV will work just as well.


Obtain a NodeMCU module or ESP-201-DEV or similar - most modules that provide voltage regulation and USB-serial will probably suffice.

It probably also goes without saying that you'll also need a computer (Windows, Mac or Linux, though these examples will be Windows-oriented until such time as people with other platforms add to them) and a USB to micro-USB cable as you'd use to charge most phones (needs to be a good one though, cheap or novelty cables may not be able to handle enough current which won't do any damage but may cause the boards to misbehave).

Install the Arduino IDE 1.6.5 (at the time of writing there are problems using later versions with ESP8266 board support). You can download it from [1] and if you're feeling flush donate but you can bypass that with the 'Just Download' link. If you're on Windows the "Windows ZIP file for non admin install" is recommended as you just unzip it into a folder on your PC. Later on you can put new versions into separate folder and even keep multiple copies with different combinations of drivers. Put that folder somewhere like C:\Arduino for now.

Now install the external board support for the ESP8266 series. Run the Arduino IDE (arduino.exe) and open File / Preferencies and under Additional Boards Manager URLs add Then under Tools / Boards / Board Manager find esp8266 by ESP8266 Community and hit install. It's usually hidden right at the bottom of the list and the Install button only appears once you've selected it. You'll need to be connected to the internet and it's over 150MB in size.

Install the appropriate USB-serial driver for your module. You may find that if you just plug it into your computer the correct driver will load automatically. If not then for the NodeMCU it's the Silicon Labs CP210x USB/Serial driver [2] for the NodeMCU or for the ESP-201-DEV the CH341 driver from here [3] which seems safe. Never install drivers from those 'helpful' driver download sites as you'll find all sorts of surprises come with them.

Finally with the board connected, back in the Arduino IDE under Tools select the board type - the Generic ESP8266 Module seems to work better than specific selections though you then need to select all the parameters. So you should have:

Board: "Generic ESP-8266 Module
Flash Mode: "DIO"
Flash Frequency: "40 MHz"
Upload Using: "Serial"
CPU Frequency: "80 MHz"
Flash Size: "512K (64K SPIFFS)"
Reset Method: "nodemcu"
Upload Speed: "115,200"

...and of course select the serial port as required.

First steps

Like installing Arduino libraries, when ESP board support is loaded via Boards Manager it additionally installs a suite of example programs. A good one to prove everything's working is WiFiscan from the ESP8266WiFi group under File / Examples which simply scans for nearby WiFi access points every ten seconds and sends the list of results to the serial post so you can see it on the Serial Monitor screen of the Arduino IDE.

So open the example and if you like take a moment to look at the code. Open the serial monitor (Tools / Serial Monitor), so you can see the results. When you start writing your own programs you'll also use this window for debugging. Now click Upload in the Arduino IDE and the program should compile and load - several lines of orange dots in the console window is a good sign - after which the ESP should reboot and start scanning for access points, listing them in the serial monitor.

On some modules before uploading you'll first need to put it into flash programming mode. Press and hold the Flash button, press and release Reset and then release Flash. You might see some garbage in the serial monitor window as you do this.

If you want to try this watch these pages for some more detailed step-by-step instructions, and I'm working on an education exercise with some RGB LED rings.