Get to know ESP8266

Revolutionary ESP8266



This is a low cost wifi module from a chinese manufacturer named Shanghai-based Chinese manufacturer, Espressif. As usual won't be explaining the blah blah but it is good practice to read so can read from this wikipedia link

Overview

The board looks like this your variant may vary as I have AI Thinker version (or the Black one). Still the pins on all the boards will remain the same pins or these pins will be common in all of them.
Here a pic of all the versions of this board.

List of all the variants of ESP8266
Adafruit also has something to offer as ESP8266 thing it's worth checking it. Ok so here's my variant
with all the pins labeled. For the first time it was confusing to hold the board which way while memorizing the pins just notice a small capacitor above pin 1 from there you can remember where is pin 1. 

ESP8266 v1 with all the pins and labelled 

A List of cautions 

The ESP8266 is 3.3V and it's pins are not 5V tolerant if you have 5v arduino or by any means you are giving it 5V it will burn your board. !!!!!BE CAREFUL!!! 

Ok wondering what to do how to turn down the voltage and all , well you have many ways will list 3 of them:
  1. Voltage divider circuit (can read here)
    1. Problem in calculating do here.
    2. Make sure u don't use too high resistance as it will drop the amperage
    3. Use voltmeter to check for conditions (3.3v and (500mA to 800mA) ) 
  2. Voltage Regulator like LD1117
    1. If using some other IC make sure it gives atleast 800mA as this board draws a lot of amps
  3.  Buy a power distribution board like this it takes 9V Input and gives both 3.3v and 5v (makes job easy)
YwRobot Power Board


Again a beginer question why can't I just directly plug it into the vcc of arduino and use it. Well my brother u can't if you do it there will be two cases:
1. Either your board will keep restarting 
2. Or your arduino won't be functioning properly

Reason: ESP8266 draws a lot of amps for it's functionality and arduino pins can't give you that much power.

A pro tip 

If your board is restarting continuously or while sending the AT commands (will be telling shortly) as it will increase the load. Just add a decoupling capacitor of 0.1 micro farad between the ground and vcc pins and place it as close as possible. Like i did  

how to add  0.1 micro farad decoupling capacitor


Enough of tips and advice lets jump to code 

How to access the board via programmer

As in previous post i showed you the FTDI or USB to serial connector and how to connect it with arduino . So we will be using the same programmer to connect the ESP. 

If your board has a 3.3v pin as mine then it will be easy to connect (good ones have it).
So I connected the ESP like this 

Connecting FTDI  with ESP8266 explained
  
A soon as you connect your FTDI to the computer the RED led (Power Indicator) will start glowing and a BLUE led (Data Indicator) will glow momentarily. 

BAUD Rates

The baud rates are simply number of bits per second
Different serial devices have different baud rates
for ESP8266 it is either 9600 or 115200,

Accessing board via AT commands using Arduino IDE Serial Monitor

Though the board has various firmwares that can be loaded into it especially nodeMCU it is based on Lua programming language and hosts lots of features. This enables ESP8266 board to be used as a standalone board which can be attached with any sensor and can push the data to it. But I won't be covering nodeMCU in this tutorial. 


Connect the board to computer and open up the arduino IDE and open up serial monitor ( press ctrl + shift+ M or you can go to Tools-> Serial Monitor ).
  1. Set the ending as NL & CR (that means take carriage and new line)
  2. Set the baud rates at 115200  and give AT command if gives OK then that's your baud rate else change the baud rate at 9600 and then try AT command. It should look like this.


AT command at 9600 baud rate
What is AT command it means ATTENTION and it shows that the board is responding correctly.

How to change the baud rate if your's is 115200, it is pretty high baud rate

  1. Type AT+CIOBAUD=9600
  2. It should return OK.
  3. Now change the baud rate on serial monitor to 9600.
  4. Then again check with AT is the board responding or not if it didn't try again few times as board takes time to change if still not then just reboot the device.

Check the version number of the firmware

  1. Type AT+GMR

AT+GMR commands output
How to connect to wifi
  1. First change the mode of ESP set it to either mode = 0 or mode =2 by issuing the command AT+CWMODE=0 or AT+CWMODE=2.
  2. Now scan the wifi present in the area AT+CWLAP. This will list all the access point to you
  3. Connect to your wifi using the command AT+CWJAP="Homing Signal","12345678". In my case my wifi name is homing signal and the password is  12345678.

How to check the current IP
  1. Type AT+CIFSR will return the allocated IP address

You can do loads of stuff with this board like creating your own webserver or a simple access point for other devices to connect.

Need to learn and see more commands

Here is complete list of AT commands for ESP 8266 .




Deepankar

My Name is Deepankar Agrawal. A lover of new technologies and i like tinkering with new device and softwares. Hope You are enjoying the tutorials of Raspberry pi. Feel free to contact me :)

No comments:

Post a Comment