Saturday 26 December 2015

Getting Started with ESP8266-ESP 12

Introduction
     Hi all, I have made this tutorial from my experience of using ESP8266-ESP12. This is a serial-wifi module which is capable of connecting to wifi supported devices, mainly used for home automation and industrial parameter monitoring remotely. This module is cheap and very easy to use. 

Things Required
     Breakout board(optional)
     Breadboard
     Berg Connectors

Basic Setup
     This very low cost module can be bought from the following link ESP8266 Inkocean. This module is not breadboard friendly and it comes as a SMT package. To interface it with breadboard you can buy a readily available breakout board.

The break out board had a footprint for 3.3v regulator sot89, which i left unsoldered. since ESP can be powered without it. The pins of ESP are not 5v tolerant. So NEVER TRY TO CONNECT 5V directly to your board, by doing so may spoil the IC. It is better to use AMS1117 3.3v voltage converter for providing enough power to the wifi module.  Once all this setup is completed. Then we require a FTDI cable that works with 3.3v since ESP is not 5v tolerant, be careful in choosing the FTDI cable .
The above cable is the one i am using for communicating with my serial-wifi module to my Laptop.

Wiring the module
      For establishing the communication between your PC and ESP module. You need to use 8 pins of ESP 8266- ESP 12.

 
Once the above connections are made, you are ready to start the UART communication through AT commands. The module with old firmware should ne connected with 115200 baud rate with default UART settings. For newer firmware the baud rate is 9600.

There are several commands for accessing wifi AP, setting hotspot, scanning the available hotspot etc. The first command to send to the wifi module is "AT". In response to the above command the module transmit "OK".

AT+CWLAP - Lists the available access points

AT+CWJAP? - Checks whether wifi is connected to any access point
AT+CWJAP="SSID","Password"

AT+CIFSR - Sending this command will return IP address of the wifi module

AT+CWMODE? - This command checks the Wifi mode of the module. The module is capable of connecting STA and AP mode separately as well as combined.

AT+CWSAP="ssid","pwd",channel,encryption
  • encryption:
    • 0 = OPEN
    • 2 = WPA_PSK
    • 3 = WPA2_PSK
    • 4 = WPA_WPA2_PSK

    The above command is used to set your own hotspot. The channel can be any number between 10