ESP8266 12F Self Contained WiFi Module - Connecting and Programming Guide
INTRODUCTION TO THE ESP8266 WIFI MODULE
The ESP8266 chip is packaged in a series of modules as well as development boards.
They offer a 'SOC' - system on a chip - solution to provide WiFi connectivity along with microcontroller functionality. They can also be used to add WiFI functionality to other circuits and boards, such as Arduino.
CLICK HERE TO SEE OUR VIDEO GUIDE PART 1 ON YOUTUBE
CLICK HERE TO SEE OUR VIDEO GUIDE PART 2 ON YOUTUBE
CLICK HERE FOR FIRMWARE UPDATE GUIDE (document on this website)
BASIC SETUP
The modules are based on a small board with an antenna at the top and smd tabs along the sides and one end. The tabs are spaced in millimetres, so are not compatible with common header pins, breadboards and so on. So, if you are not surface mounting them to a customised pcb, the best option is to use the module with a breakout board, which will then equip it with standard headers. To do this, buy the module with breakout board kit, which you can also get ready soldered and tested for you to use. The breakout pins will plug into a breadboard or you can connect with Dupont Leads.
CLICK HERE TO GET YOUR ESP8266 with BREAKOUT BOARD
The ESP8266 can be used in much the same way as an Arduino. It has input and output pins and by using libraries that have been made freely available on Github, can be programmed using the Arduino IDE. You can use the well known SPI and I2C interfaces as well as a variety of programming languages, so possible uses range from a simple project with minimal programming knowledge needed to full blown industrial level IoT devices. Scroll down for more information on installing Arduino libraries and settings to use, along with links for files needed.
DATA TRANSFER AND UPLOAD
Uploading data such as an Arduino program (sketch) to the ESP8266 is done using serial data. This means that to connect it to a computer (PC or MAC) you will need to use a USB to Serial module such as an FTDI breakout board. When you plug this into a PC you will see it as a virtual COM port in the device manager and it will appear in the Arduino/Tools/Ports menu. (eg COM3, COM12 etc). (Note: FTDI is not the only kind of chip for serial to USB data transfer - there are others such as the CH340G and you may need to install drivers if they do not work automatically).
To program the ESP8266 it will need to be put into UART programming mode. This involves pulling down GPIO pin 0 to ground via a resistor. During an upload the module will need to reset, change to programming mode and then change back to normal operating mode. This can either be done manually with a couple of push buttons, or can be automated using connections from the USB-Serial adaptor and a few extra components.
To upload the data, connect Rx to Tx and Tx to Rx between the two boards. Also, connect the Gnd of the programming module to the Gnd of the ESP8266. For Auto reset programming, connect RTS and DTR from the programmer to the ESP8266 as shown in the circuit below - if these are not available you will need to use the Manual Reset circuitry and method. Whichever method you choose, it is a good idea to have a reset button connected as well, so you can just start a program running again if you need to.
Tip: arduino sketches can be affected by serial speeds - your connection speed will be 115200, which is usually fine, but you may find that the Serial.begin(115200) command in sketches you copy and paste will affect data flow. Try using Serial.begin(9600) if you have problems.
CONNECTIONS & SETUP
To set up the ESP8266 for use as a microcontroller/WiFi solution, it will need some extra components, such as resistors to set some of the pins either high or low. Here are the main connections:
Vcc 3.3v
Gnd
CH-PD connects with a 10k resistor to 3.3v
Reset connects with a 10k resistor to 3.3v
GPIO0 connects with a 10k resistor to 3.3v
GPIO15 connects with a 10k resistor to Gnd
Manual Reset:
GPIO0 to Gnd via a 470R resistor and push button switch (program button)
Reset to Gnd via a push button switch (reset button)
Method:
Hold down Reset button
Hold down Program button
Release Reset button
Release Program button
Click Upload on computer
(For this to work, the 'reset method' in Arduino/Tools must be set to 'ck')
This is how you wire it up:
Automatic Reset
There is also an automatic method for uploading and resetting.
To use this, some additional circuitry will be needed using a couple of small NPN transistors.
(For this to work, the 'reset method' in Arduino/Tools must be set to 'nodemcu')
This is how you wire it up:
GPIO
From the breakout board, as pictured above, you can use digital pins:
0 | 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16
and analog input/output:
ADC with range 0v to 1v
Pins 12 | 13 | 14 have PWM capability.
For SPI use:
CLK 14 | 12 MISO | 13 MOSI
For I2C use:
12 SDA | 14 SCL
ARDUINO IDE LIBRARIES AND INFO
Go to your Arduino IDE and choose File>Preferences
Where it says Additional Board Manager URLs copy and paste this link:
https://arduino.esp8266.com/stable/package_esp8266com_index.json
Click OK
Then go to Tools>Board>Board Manager and scroll down to find ESP8266
Check you have found the latest version and click Install
When everything has finished installing, you should find a variety of options for ESP8266 in the Arduino Board menu. The module that we stock is the ESP8266 ESP12F, which has a larger flash memory and some increased functionality over some other previous boards.
Choose your com port and then the board - either 'ESPino (ESP-12 Module)' or 'Generic ESP8266 Module'
You will then need to check a couple more options, such as connection speed (probably 115200) and reset mode (ck for manual and nodemcu for automatic) and then you are ready to upload your first sketch (make sure you have a reset circuit in place, either manual or automatic).
It's a good idea to try something simple first, such as a Blink sketch to make sure everything is working and that your connection/data transfer is working. Note: the LED_BUILTIN function on the ESP8266 is inverted - on when LOW and off when HIGH.
The next step is to look in the 'examples' sketches which will have been installed when you downloaded the arduino libraries. WiFi Scan is a good one to try first, change Serial.begin to (9600) and see if it discovers your network. You can then modify these sketches and adapt them to your own use
I've experimented with some sketches to try out remote sensing and basic functionality, and they are available here for you to use and develop:
Important Note:
The ESP8266 needs 3.3v for both power and data connections.
5v can cause damage.
Set the jumper on your USB-Serial Adaptor to 3.3v and take care with all inputs not to exceed 3.3v.
For multiple gpio connections you can speed things up with a 5v/3v convertor module - also available from Q26