NodeMCU ESP8266
What is ESP8266?
The Chips
The ESP8266 series, or family, of Wi-Fi chips is produced by Espressif Systems, a fabless semiconductor company operating out of Shanghai, China. The ESP8266 series presently includes the ESP8266EX and ESP8285 chips.
ESP8266EX (simply referred to as ESP8266) is a system-on-chip (SoC) which integrates a 32-bit Tensilica microcontroller, standard digital peripheral interfaces, antenna switches, RF balun, power amplifier, low noise receive amplifier, filters and power management modules into a small package. It provides capabilities for 2.4 GHz Wi-Fi (802.11 b/g/n, supporting WPA/WPA2), general-purpose input/output (16 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). The processor core, called "L106" by Espressif, is based on Tensilica's Diamond Standard 106Micro 32-bit processor controller core and runs at 80 MHz (or overclocked to 160 MHz). It has a 64 KiB boot ROM, 32 KiB instruction RAM, and 80 KiB user data RAM. (Also, 32 KiB instruction cache RAM and 16 KiB ETS system data RAM.) External flash memory can be accessed through SPI. The silicon chip itself is housed within a 5 mm × 5 mm Quad Flat No-Leads package with 33 connection pads — 8 pads along each side and one large thermal/ground pad in the center.
ESP8285 is a variation of ESP8266 with 1 MiB of embedded flash memory.
Now, if you're looking for something a bit more capable, check out ESP32 — it has more memory, more GPIO, hardware encryption, Bluetooth, and all sorts of other additional bells and whistles.
The MCU Architecture and Pinouts
PINOUTS:
The Modules
Vendors have consequently created a multitude of compact printed circuit board modules based around the ESP8266 chip. Some of these modules have specific identifiers, including monikers such as "ESP-WROOM-02" and and "ESP-01" through "ESP-14"; while other modules might be ill-labeled and merely referred to by a general description — e.g., "ESP8266 Wireless Transceiver." ESP8266-based modules have demonstrated themselves as a capable, low-cost, networkable foundation for facilitating end-point IoT developments. Espressif's official modules are presently ESP-WROOM-02 and ESP-WROOM-S2. The Ai-Thinker modules are succinctly labeled ESP-01 through ESP-14. (Note: many people refer to the Ai-Thinker modules with the unofficial monikers of "ESP8266-01" through "ESP8266-14" for clarity.) See the ESP8266 article on Wikipedia for more information about popular ESP8266 modules.
- Current models:
Model Flash memory Antenna Size (mm) ESP-WROOM-02 2 MiB PCB trace 20 × 18 × 3 ESP-WROOM-02D 2 MiB PCB trace 20 × 18 × 3.2 ESP-WROOM-02U 2 MiB I-PEX 18 × 14.3 × 3.2 ESP-WROOM-S2 2 MiB PCB trace 23 × 16 × 3 ESP-WROOM-02D is simply a small revision of ESP-WROOM-02 with compatibility for both 150-mil and 208-mil flash memory chips. ESP-WROOM-02U has an I-PEX/U.FL antenna connector in lieu of a PCB trace inverted meandered-F antenna. - Additional resources:
- Current models:
Model Flash memory Antenna Size (mm) ESP-01S 1 MiB PCB trace 24.7 × 14.4 × 11 ESP-01M 1 MiB PCB trace 18 × 18 × 2.8 ESP-07S 4 MiB I-PEX 17 × 16 × 3 ESP-08S 4 MiB (None) 17.6 × 16.2 × 3 ESP-12F 4 MiB PCB trace 24 × 16 × 3 ESP-12S 4 MiB PCB trace 24 × 16 × 3 - Older models: ESP-01, ESP-7, ESP-08, ESP-09, ESP-10, ESP-11, ESP-12, ESP-12E, and ESP-13.
- Discontinued models: ESP-02, ESP-03, ESP-04, ESP-05, ESP-06, and ESP-14.
- Ai-Thinker wiki: ESP8266 section
- Current models:
Model Flash memory Antenna Size (mm) ESP-1 1 MiB Ceramic & I-PEX 24.5 × 14 × 3 ESP-F 4 MiB PCB trace 24 × 16 × 3 ESP-M1 1 MiB I-PEX 15 × 12.3 × 3 ESP-M2 1 MiB PCB trace 20 × 12.3 × 3 ESP-M3 1 MiB PCB trace 26.8 × 16 ESP-S 4 MiB PCB trace 24 × 16 × 3 - ESP8285 is used in ESP-1, ESP-M1, ESP-M2, and ESP-M3.
- Discontinued model: ESP-E.
- Current models:
Model Flash memory Antenna Size (mm) WT8266-S1 2 MiB PCB trace 18.64 × 15 × 3.13 WT8266-S2 2 MiB Ceramic & I-PEX 18.6 × 15 × 3.05 - Additional resources:
The Development Boards/Modules
ESP8266 based development boards/modules often incorporate a surface-mount PCB module, a on-board USB-to-serial bridge, and breakout to 0.1 inch pitch connections. For example, the NodeMCU Development Kits use Ai-Thinker modules, the Adafruit Feather HUZZAH uses an Ai-Thinker ESP-12S module with a SiLabs CP2104 USB-to-serial bridge chip, and the WEMOS D1 Mini version 2.3 uses an Ai-Thinker ESP-12S module with a WinChipHead CH340G USB-to-serial bridge chip. Other development boards don't use an intermediary module and instead directly incorporate the chip itself on-board — for example, WEMOS D1 Mini Pro uses ESP8266EX and WEMOS D1 Mini Lite uses ESP8285.
Where can I learn more about it?
Forums & Chat
- Official Espressif forums (BBS.Espressif.com)
- ESP8266 community forum (ESP8266.com)
- #ESP8266 IRC channel on Freenode
Readings & Resources
- Espressif ESP8266 resources page ⭐
- Espressif support: ESP8266 series documentsIncludes ESP8266EX & ESP8285 chips, ESP-WROOM-02 & ESP-WROOM-S2 modules, and the ESP-Launcher development board.
- ESP8266 community forum
- NURDspace wiki: ESP8266
- Electrodragon wiki: ESP8266 category
- ESP8266 reverse engineering wiki (Archive.org backup)
- ESP8266.ru: Russian developer community
- LetsControlIt.com (previously ESP8266.nu wiki)
- Ray Burnette's ESP-01 module using Arduino IDE tutorial
- Hackster.io ESP tag (project oriented)
- Hackaday.io ESP8266 tag (project and tutorial oriented)
- Hackaday.com ESP8266 tag (news oriented)
- Instructables ESP8266 search (project oriented)
- @ESP8266 on Twitter
Software Platforms, Firmwares & Frameworks
- Espressif AT firmware
- Espressif FreeRTOS firmware
- ESP8266 core for Arduino
- Sming — Open source framework for high efficiency native ESP8266 development.
- Simba OS — Embedded programming platform. / docs, supported boards
- ESP-Open-SDK — Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips.
- ESP-Open-RTOS — Open source FreeRTOS-based ESP8266 software framework.
- Lua:
- NodeMCU
- NodeMCU custom builds
- NodeLua — Lua interpreter with Web IDE.
- Python:
- JavaScript:
- Forth:
- Lisp:
- ESP-Lisp
- Lisps in JavaScript under Mongoose OS (inefficient; not practical)
- Basic:
- Visual programming:
- Networking:
- ESP-LINK — Wi-Fi/serial bridge, outbound TCP, and Arduino/AVR/LPC/NXP programmer.
- ESP_WiFi_Repeater — Wi-Fi NAT router. / video
- ESP_SLIP_Router — Serial Line IP (RFC1055) router.
- USB: ESPUSB — Software-only ESP8266 USB device. / wiki, forum
- Spacial:
- Geolocating with ESP8266 (PDF)
- ESPLocalizer — ESP8266, IMU (orientation), barometer, and battery.
- ESPWebFramework — A Web framework for ESP8266.
- Frankenstein — Alternative firmware for ESP8266 modules.
- See also: Electrodragon wiki: ESP8266 code guide category, ESP8266 community wiki: loading firmware
Where can I get it?
Disclaimer: Vendors are listed for informational purposes only. Buyers should use prudence and careful judgement when ordering. Before ordering, read all product descriptions and check vendor ratings when possible. Prices listed below are approximate and do not include shipping costs. Furthermore, prices listed below may be outdated, so be diligent and check for yourself.
- Adafruit:
- AnalogLamb:
- Ai-Thinker ESP-01S ($4.99)
- Ai-Thinker ESP-12E ($2.69)
- Electrodragon:
- Ai-Thinker ESP-01S ($2.60)
- Ai-Thinker ESP-01M ($2.60)
- Ai-Thinker ESP-07S ($2.60)
- Ai-Thinker ESP-12F ($2.60)
- Ai-Thinker ESP-12S ($2.60)
- Espressif ESP-WROOM-02 ($2.20)
- Espressif ESP-Launcher Development Kit ($20.00)
- Grid Connect:
- Espressif ESP-WROOM-02 ($2.70 each; minimum qty 10)
- Espressif ESP-WROOM-S2 ($2.70 each; minimum qty 10)
- Espressif ESP-Launcher Development Kit ($30.00)
- Seeed Studio Bazaar:
- Smart Prototyping:
- Ai-Thinker ESP-12S ($4.99)
- Amica NodeMCU ($6.99)
- SparkFun:
- Ai-Thinker ESP-01 ($6.95)
- SparkFun ESP8266 Thing ($15.95)
- SparkFun ESP8266 Thing — Dev Board ($15.95)
- Search for ESP8266
- WEMOS Electronics:
- WEMOS D1 Mini Pro ($5.00)
- WEMOS D1 Mini ($3.50)
- WEMOS D1 Mini Lite ($3.00)
- Watterott Electronic:
- Ai-Thinker ESP-01 (€4.30)
- Ai-Thinker ESP-05 (€4.30)
- Ai-Thinker ESP-07S (€4.30)
- Ai-Thinker ESP-12F (€3.85)
- Ai-Thinker ESP-14 (€4.30)
- Espressif ESP-WROOM-02 (€4.00)
- Ai-Thinker T5 Black Board (€8.25)
- ArduCAM ESP8266 UNO (€16.50)
- AliExpress: Search for ESP8266
- Alibaba (bulk): Search for ESP8266
EXAMPLES:
Connect to the wireless network
print(wifi.sta.getip())
--nil
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
print(wifi.sta.getip())
--192.168.18.110
Arduino like IO access
pin = 1
gpio.mode(pin,gpio.OUTPUT)
gpio.write(pin,gpio.HIGH)
gpio.mode(pin,gpio.INPUT)
print(gpio.read(pin))
HTTP Client
-- A simple http client
conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, pl) print(pl) end)
conn:connect(80,"121.41.33.127")
conn:send("GET / HTTP/1.1\r\nHost: www.nodemcu.com\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
HTTP Server
-- a simple http server
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
conn:send("
Hello, NodeMcu.
")
end)
end)
PWM
function led(r,g,b)
pwm.setduty(1,r)
pwm.setduty(2,g)
pwm.setduty(3,b)
end
pwm.setup(1,500,512)
pwm.setup(2,500,512)
pwm.setup(3,500,512)
pwm.start(1)
pwm.start(2)
pwm.start(3)
led(512,0,0) -- red
led(0,0,512) -- blue
Blinking Led / HELLO WORLD ! in MCU & MPU WORLD
lighton=0
tmr.alarm(0,1000,1,function()
if lighton==0 then
lighton=1
led(512,512,512)
-- 512/1024, 50% duty cycle
else
lighton=0
led(0,0,0)
end
end)
Bootstrap
--init.lua will be excuted
file.open("init.lua","w")
file.writeline([[print("Hello World!")]])
file.close()
node.restart() -- this will restart the module.
Use timer to repeat
tmr.alarm(1,5000,1,function() print("alarm 1") end)
tmr.alarm(0,1000,1,function() print("alarm 0") end)
tmr.alarm(2,2000,1,function() print("alarm 2") end)
-- after sometime
tmr.stop(0)
A pure lua telnet server
-- a simple telnet server
s=net.createServer(net.TCP,180)
s:listen(2323,function(c)
function s_output(str)
if(c~=nil)
then c:send(str)
end
end
node.output(s_output, 0)
-- re-direct output to function s_ouput.
c:on("receive",function(c,l)
node.input(l)
--like pcall(loadstring(l)), support multiple separate lines
end)
c:on("disconnection",function(c)
node.output(nil)
--unregist redirect output function, output goes to serial
end)
print("Welcome to NodeMcu world.")
end)
Interfacing with sensor
-- read temperature with DS18B20
t=require("ds18b20")
t.setup(9)
addrs=t.addrs()
-- Total DS18B20 numbers, assume it is 2
print(table.getn(addrs))
-- The first DS18B20
print(t.read(addrs[1],t.C))
print(t.read(addrs[1],t.F))
print(t.read(addrs[1],t.K))
-- The second DS18B20
print(t.read(addrs[2],t.C))
print(t.read(addrs[2],t.F))
print(t.read(addrs[2],t.K))
-- Just read
print(t.read())
-- Just read as centigrade
print(t.read(nil,t.C))
-- Don't forget to release it after use
t = nil
ds18b20 = nil
package.loaded["ds18b20"]=nil
Source: https://cdn-images-1.medium.com/max/1388/1*_WSqG1NE4ofI_dM6eSOfuA.png
Source:https://www.google.co.in/search?q=esp8266+architecture&safe=strict&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiU8rPHvaHcAhWDfysKHQ3kBwQQ_AUICigB&biw=1692&bih=873#imgrc=RP97KzgNsCC2-M:
Source: http://nodemcu.com/
It is truly a well-researched content and excellent wording. about PCB Clone Service. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks.
ReplyDeleteAmazingly helpful which you have shared here. I am impressed by the details and also it is a significant article for us. Continue imparting this sort of info, Thank you.vlsi training institutes in bangalore
ReplyDeleteYou have done good work by publishing this article here.consulting firms I found this article too much informative, and also it is beneficial to enhance our knowledge. Grateful to you for sharing an article like this.
ReplyDelete