Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WiFi SoC ESP8266

Talks very basics of ESP8266 wiFi SoC and LUA Script

WiFi SoC ESP8266

  1. 1. Adding Wi-Fi to our Embedded Systems By Devesh Samaiya devesh.samaiya@pilani.bits-pilani.ac.in
  2. 2. Why Add Wi-Fi? ● Having network connectivity is good for any computing system. It opens plenty of new possibilities and adds to a systems utility. ● Can fetch data from anywhere in the WWW. ● Can push data to cloud or any specific server for storage, computation or monitoring.
  3. 3. How? ● We need a piece of external hardware that can convert the Wi-Fi data into a data format understood by common micro-controller, example UART, SPI, I2C etc. ● The external hardware must have all the network protocol stack, RF front ends, Encryption- Decryption algorithm built into it.
  4. 4. Options! ● Plenty are there. ● Almost every SoC manufacturer have their own Wi-Fi SoC. ● We will talk about the one which is easily available, lowest cost, easy to use, supported by community of users.
  5. 5. ESP8266 ● $5 Micro-controller with Wi-Fi capability. ● Can be programmed just like any other MCU, it has GPIO, SPI, I2C, UART, I2S. ● It has 802.11 b/g/n. ● Integrated TCP/IP Protocol stack. MAC/ Baseband Processor. ● Integrated TR Switch, Balun, LNA, Power Amplifier, matching network. ● Integrated PLL, regulator, DCXO, PMU. DCXO – digitally controlled Oscillator, PMU – Power management unit
  6. 6. ESP8266 Continued. ● Designed and distributed by a fab-less Chinese company named Espressif Systems. ● Comes in a QFN-32 package, smaller than a fingernail. ● Supported by a large user community online. ● Various breakout modules are available in market at a cost as low as Rs. 300.
  7. 7. ESP8266 Interfacing ● We will be using ESP-01 Module. RXD Receive Data Vcc 3V3, DO NOT Connect 5V GPIO0 Also, used to enter into Flash Mode, Active Low RST Reset GPIO 2 General Purpose I/O CH_PD Chip Enable, Active High GND Ground TXD Transmit Data
  8. 8. ESP8266 Interfacing
  9. 9. AT Commands There are many other commands for every other task ESP8266 can perform. Remembering so many AT commands with all the correct parameter is hardly possible, we need a more familiar system like C Language, Arduino Sketch or Any other easy to write and read script.
  10. 10. NodeMCU and LUA Script ● ESP8266 is made to understand its AT Commands. ● For larger programs AT commands based program becomes complex to read and write. ● NodeMCU is a very useful ESP8266 firmware. ● Allows writing of easy to understand LUA scripts for ESP8266 applications.
  11. 11. Which is easy to remember? wifi.sta.getip() AT+CIFSR wifi.setmode(wifi.STATION) AT+CWMODE = 1 [1 Indicates STATION] LUA Script Style AT Commands Using LUA is easy for application programmer for larger more complex programs.
  12. 12. How to flash Node MCU firmware to ESP8266? ● Use this sofware utility -“ESP8266 Flasher”
  13. 13. LUA Script for Web Client 1 wifi.setmode(wifi.STATION) 2 wifi.sta.config("AndroidAP","esp8266") 3 wifi.sta.connect() 4 tmr.delay(100000000) -- wait 1,000,000 us = 1 second 5 print(wifi.sta.status()) 6 print(wifi.sta.getip()) 7 conn=net.createConnection(net.TCP, false) 8 conn:on("receive", function(conn, pl) print(pl) end) 9 conn:connect(80,"121.41.33.127") 10 conn:send("GET / HTTP/1.1rnHost: www.nodemcu.comrn" .."Connection: keep-alivernAccept:*/*rnrn") Once written, this script can be permanently stored in ESP8266 flash memory and can be called to run any time using any external serial interface. Let's say the file name is client.lua, you can call this script by sending =dofile('client.lua') over serial interface.
  14. 14. Programming the Flash ● Use ESPlorer sofware. Tie GPIO0 to Ground. ● Write your LUA script and press SEND to ESP to run the script. ● Use SAVE to ESP to permanently flash the script onto memory. ● NodeMCU firmware always executes init.lua upon reset/ power on. In'init.lua' write everything you need to run upon start-up.
  15. 15. Things to learn yourself ● Blynk (blynk.cc) ● ESP8266 using Arduino IDE ● LUA script in detail.
  16. 16. Keep on Making!

×