Handson Technology ESP8266 WiFi Manual Download Page 22

6.

 

NodeMCU GPIO for Lua 

 

The GPIO(General Purpose Input/Output) allows us to access to pins of ESP8266 , all  the pins of ESP8266 accessed 
using the command GPIO, all the access is based on the I/O index number on the NoddMCU dev kits, not the internal 
GPIO pin, for example, the pin ‘D7’ on the NodeMCU dev kit is mapped to the internal GPIO pin 13, if you want to 
turn ‘High’ or ‘Low’ that particular pin you need to called the pin number ‘7’, not the internal GPIO of the pin. When 
you  are  programming  with  generic  ESP8266  this  confusion  will  arise  which  pin  needs  to  be  called  during 
programming,  if  you  are  using  NodeMCU  devkit, it has come  prepared for  working  with  Lua  interpreter which can 
easily program by looking the pin names associated on the Lua board. If you are using generic ESP8266 device or any 
other  vendor  boards  please  refer  to  the  table  below  to  know  which  IO  index  is  associated  to  the  internal  GPIO  of 
ESP8266. 

 

Nodemcu 
dev kit 

ESP8266 Pin 

Nodemcu dev 
kit 

ESP8266 Pin 

D0 

GPIO16 

D7 

GPIO13 

D1 

GPIO5 

D8 

GPIO15 

D2 

GPIO4 

D9 

GPIO3 

D3 

GPIO0 

D10 

GPIO1 

D4 

GPIO2 

D11 

GPIO9 

D5 

GPIO14 

D12 

GPIO10 

D6 

GPIO12 

 

 

 

D0 or GPIO16 can be used only as a read and write pin, no other options like PWM/I2C are supported by 
this pin. 

 

In our example in chapter 5 on blinking the blue LED, the blue LED in connected to GPIO2, it is defined as 
Pin4 (D4) in Lua script. 

 
 

 

7.

 

Web Resources: 

 

  ESP8266 Lua Nodemcu WIFI Module 

  ESP8266 Breadboard Friendly Module 

  ESP8266 Remote Serial WIFI Module 

  PL2303HX USB-UART Converter Cable 

 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

22 

www.handsontec.com 

Summary of Contents for ESP8266 WiFi

Page 1: ...tion offering as a bridge from existing micro controller to WiFi and is also capable of running self contained applications This module comes with a built in USB connector and a rich assortment of pin...

Page 2: ...266 Support 5 Blink Test 7 Connecting via WiFi 9 4 Flashing NodeMCU Firmware on the ESP8266 using Windows 12 Parts Required 12 Pin Assignment 12 Wiring 13 Downloading NodeMCU Flasherfor Windows 13 Fla...

Page 3: ...512K normal Integrated TCP IP protocol stack Processor Tensilica L106 32 bit Processor speed 80 160MHz RAM 32K 80K GPIOs 17 multiplexed with other functions Analog to Digital 1 input with 1024 step re...

Page 4: ...o install ESP8266 library to work in Arduino IDE environment Install the Arduino IDE 1 6 4 or greater Download Arduino IDE from Arduino cc 1 6 4 or greater don t use 1 6 2 or lower version You can use...

Page 5: ...Install button to install the ESP8266 library package Once installation completed close and re open Arduino IDEfor ESP8266 library to take effect Setup ESP8266Support Whenyou verestartedArduinoIDE sel...

Page 6: ...eedisagoodplacetostart lateronyoucantryhigherspeedsbut115200isagood safe place tostart Gotoyour Windows Device Manager tofind out which Com Port USB Serial CH340 isassigned to Selectthe matching COM s...

Page 7: ...proceed the above Com Port setting The CH340 driver can be download from the below site https github com nodemcu nodemcu devkit tree master Drivers Blink Test We ll begin with the simple blink test E...

Page 8: ...Whenyoureleasethe RST button theblueindication willblink once thismeansitsreadyto bootload Once the ESP board is in bootload mode upload the sketch via the IDE Figure 3 2 Figure3 1 Connection diagram...

Page 9: ...module The sketch will start immediately you ll see the LED blinking Hooray Connecting viaWiFi OK once you ve got the LED blinking let s go straight to the fun part connecting to a webserver Create a...

Page 10: ...rial println host Use WiFiClient class to create TCP connections WiFiClient client const int httpPort 80 if client connect host httpPort Serial println connection failed return We now create a URI for...

Page 11: ...en up the IDE serial console at 115200 baud to see the connection and webpage printout That s it pretty easy right This section is just to get you started and test out your module 11 www handsontec co...

Page 12: ...tafewlinesofcodeyoucanestablishaWiFiconnection control the ESP8266 GPIOs turning your ESP8266 into a web server and a lot more In this tutorial we are going to use another ESP8266 module with pin head...

Page 13: ...pply ground Downloading NodeMCU Flasher for Windows After wiring your circuit you have to download the NodeMCU flasher This is a exe file that you can download using one of the following links Win32 W...

Page 14: ...essimmediately showingtheModuleMACaddressif successful connected After finishing this flashing process it should appear a green circle with a check icon at lower left corner Your ESP8266 module is now...

Page 15: ...and install the latest version It requires JAVA SE version 7 and above installed In order to complete the sample project presented in this Guide you need to flash your ESP8266 with NodeMCUfirmware Ref...

Page 16: ...lt dark Eclipse IDEA Visual Studio Undo Redo editors features Code Autocomplete Ctrl Space Smart send data to ESP8266 without dumb send with fixed line delay check correct answer from ESP8266 after ev...

Page 17: ...s your scripts are highlighted with your code syntax Below the Code Window you have 12 buttons that offer you all the functions you could possible need to interact with your ESP8266 Here s the ones yo...

Page 18: ...ng Your Lua Script Below is your script to blink an LED Right now you don t need to worry how this code works but how you can upload it to your ESP8266 lighton 0 pin 4 gpio mode pin gpio OUTPUT tmr al...

Page 19: ...our ESPlorer IDE and follow these instructions 1 Press the Refreshbutton 2 Select the COM port for your FTDI programmer 3 Select yourbaudrate 4 Click Open Then in the top left corner of your ESPlorer...

Page 20: ...The next step is to save your code to your ESP8266 At the left bottom corner click the button Save to ESP In your output window it should start showing exactly which commands are being sent to your ES...

Page 21: ...file format to remove all the files saved in your ESP8266 You can type any commands and send them to your ESP8266 through that window After uploading your code to your ESP8266 unplug your ESP8266 from...

Page 22: ...a interpreter which can easily program by looking the pin names associated on the Lua board If you are using generic ESP8266 device or any other vendor boards please refer to the table below to know w...

Reviews: