Maker|Coder|Learner and everything in between

ESP8266 101

2016-11-13

Introduction to ESP8266

ESP8266 is an answer to most of the projects that requires internet/wi-fi connectivity.

It is cheap (like 3$ cheap) and its specifications are much much better than that of atmega’s(or arduino uno’s that use atmega).
It has a 32 bit CPU running at 80MHz with 64+96 KB of iRAM+dataRAM, and SPI Flash storage of atleast 512KB!. It supports IEEE 802.11 b/g/n WiFi. The power consumption is decent.
Considering the cost this is a steal!.

credits: sparkfun

ESP8266 is a must toy for EC/CS students. The concepts of Computer Networking, Operating systems, Embedded systems and microcontrollers can be learnt hands-on using this one tiny chip!.

ESP8266 can connect to other WiFi Access Points(such as your WiFi router) as station or be the Acess Point itself(like your mobile hotspot) where other devices can connect to it and a third mode exists where it acts as both station and access point.

There are 2 ways to use ESP8266 in your project.

1
2
|--As WiFi to Serial modem using AT commands
|--Standalone mode.

Most people use it as WiFi to serial modem. ESP8266 comes with AT firmware flashed. Which means you can send AT styled Commands over UART from other controllers(like Arduino) to ESP8266.

credits:https://github.com/mrizvic/nodemcu-uart2http-exositeimage credits: mrizvic


For example to list all the wifi access points you would send AT+CWLAP from your Arduino over serial port to esp8266. Esp8266 will scan for all the access points available and reply back over serial port.

Although this is simple to use there are tradeoffs. Issue with this approach is design would need one more microcontroller to send commands to ESP(usually its the arduino). Hence adding to cost, space and power consumption.
Moreover it is a shame to waste so much processing power that comes with ESP8266 :( It is like using another vehicle to tow your car. It maybe needed in some case, but for most of the time we are better off not using it.

Standalone method uses the processor on ESP8266 itself as application processor. Hence reducing need of extra controller.
ESP8266 has 17 GPIO pins (number of exposed pins can vary from version to version for example ESP-1 had 4 GPIO and ESP12 module had 11 GPIO pins exposed).
The plus side is access to faster CPU, larger RAM and flash storage.

ESP8266 can be programmed directly using many methods out of which below ones are the famous one

NodeMCU

NodeMCU is an opensource IOT Platform. You can use lua scripting language to code the ESP8266. Lua is asyncronous like JavaScript.

Arduino interface based

ESP8266 can be programmed using Arduino IDE. This is by far the most easiest one. But if experience has taught us anything, it’s that the easy way out may not always lead to paradise. This introduces performance tradeoffs and is not prefered for some serious design.

MicroPython

Its everyone’s favourite python on ESP8266!. I am yet to check this out, but again may have performance tradeoffs.

Native SDK

This is the most powerful of all methods. Like all things with power, this too is feared by many. It has a steep learning curve, and tutorial around this are hard to find. This overcomes performance bottlenecks of the above methods.
This uses C

Espressif releases it’s SDK periodically which can be used to code ESP8266. These come in 2 version.
1
2
|--RTOS based SDK.
|--Non RTOS, callback based SDK.

I prefer using native SDK and C, well because its more fun to work at bare-metal levels.
I am still learning to work around with ESP8266 and hopefully i will try to document it as i learn.

In Next post lets install dev environment for ESP8266 and try the Helloworld of embedded world.

Till then,
Happy tinkering.

PS:
There is this new kid in the block called ESP32 check him out!.

Few Resources on Esp8266:
Here is an awesome book on ESP8266
wonderful forum everything esp8266