Quick introduction to the ESP8266 wifi module
IoT (Internet of things) is a hot topic these days. Simply put, IoT refers to a network of small interconnected devices that can communicate with each other.In last few years, we have seen steady flow of inexpensive and powerful programable embedded devices/boards. Arduino is an excellent example. These days every other gadget or device wants to have the ability to connect to internet wirelessly. In this article I will introduce you to the ESP8266 module which you can use in your next IoT inspired project.
What is a ESP8266 module ?ESP8266 is an IC created by Espressif Systems, which offers wifi networking cabilities. A module, simply integrates this IC with some other components and becomes an easy to use component.In this article I have described the most common form of ESP8266 which comes as a 8 pin module.
Some of its most important features are:
- Low cost (USD 2 -5 per piece !)
- Works in normal as well as access point mode.
- Low voltage operation (3.3v).
- Serial interface to program/communicate with the module.
- Has everything required for wifi networking (supply only power).
- 64KBytes of instruction RAM, 96KBytes of data RAM and 64KBytes boot ROM.
- Two GPIO pins (support PWM).
- Ability to be programmed/flashed via serial interface.
- Can be easily interfaced with a microcontroller or used standalone.
- Choice of different firmwares.
Programming the ESP8266 moduleThis is where the module really shines. There are two popular firmwares it can support, Espressif firmware and NodeMCU . the Espressif firmware is AT commands based. Some modules come with this firmware pre-loaded. The NodeMCU firmware basically adds a Lua interpreter to the module. It then becomes possible to use NodeMCU's rich API to send Lua scripts to the module over serial port. I find it simply amazing to be able to program such a small device using a language like Lua. This also gives me an opportunity to learn Lua. There is also Micro Python firmware for the module which I haven't expored much.
Toolchains are available for loading different types of firmwares to the module. Loading firmware is done over serial port by connecting GPIO0 pin of the module to GND. In the next section I will be discussing procedure to load the NodeMCU firmware into ESP8266 module and using it.
Burning the NodeMCU firmwareYou will need the following things:
- USB to UART Serial converter (should support 3.3v)
- A breadboard
- Jumper cables
- The latest version of NodeMCU firmware
- NodeMCU flasher tool for windows (since I am using windows)
- Putty for windows (or any other program that allows communicating with COM port)
|ESP8266 PIN||Serial converter PIN|
|VCC||To 3.3v PIN|
Once the firmware update is over, you can disconnect the ESP8266 module. Now disconnect GPIO0 from GND, and connect the module back to the serial converter as before. Start Putty.exe and select a 'serial' connection as shown below. Then click on 'Open'. You should be able to see a terminal window with a '<' prompt. Try following command:
majorVer,minorVer,devVer = node.info(); print("Firmware: "..majorVer.."."..minorVer.."."..devVer)You should see the version number of the Node MCU firmware. This indicates that you have successfuly installed NodeMCU firmware on your ESP8266 module.
What next ?What I really like the most about this module is it allows you to program in a higher-level language without much hassle. Burning firmware and interfacing is also super easy. In some ways I find it more interesting than Arduino (especially if I can get a module with more GPIO pins). Once you have the firmware installed, you should take out some time to visit the API documentation page and play with your module. The interactive Lua enviornment is a joy to work with, in my opinion. You can experiment and learn a lot.
You will quickly realize that when you disconnect the module, your programs are lost. In my next article, I will post information on saving Lua scripts directly to the module itself. Then it is possible to auto-run your Lua script everytime the module is switched on. Keep reading my website for more on this awesome device.
Copyright (c) 2007-2019 Ashish Patil . Please read FAQ for more details.