What is the ESP8266?
ESP8266 is the name of an infamous WiFi module that is a system on a chip (SoC) developed by Espressif Systems, a company based in Shanghai. Originally used with Arduino boards to WiFi-enable hardware projects, it soon became a cheap standalone Arduino-compatible development board. It can function in complete autonomy, without an additional microcontroller like Arduino board for example.
Home automation and IOT – connecting devices to a network is one ever-growing, big trend nowadays. Given its cheap price, the user friendly setup, and its huge community that contributes with open source libraries and projects, you will immediately see why this chip is receiving so much interest.
This mcu (microcontroller unit) can be used to control and monitor engineered systems and products, sensor data logging and more. All of this makes it the perfect piece of hardware for connected home automation projects. It comes in many shapes and forms, with the NodeMcu (with the newest ESP8266-E12 chip) being the most popualar development board among them.Image: NodeMcu development board is the most popular ESP8266 variant.
All ESP8266 variants have a ESP8266EX core processor and a Tensilica L106 32-bit micro controller unit. This is a low cost, high performance, low power consumption, easy to program, wireless SoC(System-On-Chip). It provides capabilities for 2.4 GHz Wi-Fi (802.11 b/g/n, supporting WPA/WPA2), general-purpose input/output (13 GPIO), Inter-Integrated Circuit (I²C), analog-to-digital conversion (10-bit ADC), Serial Peripheral Interface (SPI), I²S interfaces with DMA (sharing pins with GPIO), UART (on dedicated pins, plus a transmit-only UART can be enabled on GPIO2), and pulse-width modulation (PWM).
It has a build-in programmer and a voltage regulator, that allow flashing and powering the device via micro-USB. The system operates at 3.3V.
Here is an overview of the ESP8266 NodeMcu’s specifications:
- Tensilica L106 32-bit micro controller unit at 80 MHz (or overclocked to 160 MHz)
- 32 kB instruction RAM
- 80 kB user data RAM
- 16 kB ETS system data RAM
- Flash Memory 4Mb
- USB – micro USB port for power, programming and debugging
- 13 GPIO pins
- 802.11 b/g/n, supporting WPA/WPA2
- STA / AP modes support
- TCP / IP protocol stack, One socket
- TCP / UDP Server and Client
- Serial port baud rate configuration: 1200/2400/4800/9600/19200/38400/57600/74800/115200 bps
- Pin-compatible with Arduino UNO, Mega
- KEY button: modes configuration
- 32-bit hardware timer
- WiFi operation current: continuous transmission operation: ≈70mA (200mA MAX), deep sleep mode: <3mA
- Serial WiFi transmission rate: 110-460800bps
- Temperature: -40℃ ~ + 125 ℃
- Humidity: 10%-90% non-condensing
- Weight: about 20g (0.7oz)
- Pulse-Width Modulation (PWM)
- Interrupt capability
- 3.3V operating voltage, internal voltage regulator allows 5V on power input
- maximum current through GPIO pins: 12mA (source), 20mA (drain)
- available firmware for Arduino IDE
- Websocket libraries available
Transfer Control Protocol (TCP):
Most of us would know what this means. Yes, these are the set of rules based on which the internet works. Since ESP8266 has the ability to set up WIFI connections. At a high level Wi-Fi is the ability to participate in the TCP/IP connections over a wireless link. You can make your ESP to work on the TCP/IP protocol or the UDP protocol.
User Datagram Protocol (UDP):
UDP is also another type of internet protocol. This type of communication is faster than TCP but it is less accurate. The reason is that TCP uses an Acknowledgment during its communication but UDP does not. TCP is mostly used in networks where there is a requirement high reliability. UDP is used in places where speed has high priority than reliability. For example UDP is used in video conferencing, because there even if some pixels are not transmitted it will not affect the video quality that much but the speed is very important.
Most of the ESP8266 projects and codes work around the TCP/IP, UDP will be least bothered.
According to Wikipedia, a Websocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C.
In other words, Websocket is a protocol based on TCP that enables realtime communication between server and host, while the communication is kept alive after an initial handshake. It has a small overhead and little data is sent to keep the connection alive. It is used in chat applications, sensor data stream reading or real-time data exchange, for example.
Access Point (AP) and Station (STA):
Once you start working with ESP module, you would come across these two terms frequently. Let us say you and your friend would like to surf the internet on your smart phones but since he does not have an active internet connection you decide to turn on your hotspot and your friend connects to it. Here your phone which is sourcing the internet connection is the Access Point (AP) and your friend’s phone which is using the internet is called the Station (STA).
ESP8266 module can be used in three modes, AP mode, STA mode or in both STA and AP mode (combined).