ESP8266 NodeMCU Module GPIO

 

ESP8266 NodeMCU Devkit GPIO Pin Map

 

 

IO indexESP8266 pinIO indexESP8266 pin
0 [*]GPIO167GPIO13
1GPIO58GPIO15
2GPIO49GPIO3
3GPIO010GPIO1
4GPIO211GPIO9
5GPIO1412GPIO10
6GPIO12  

 

 


 ESP8266 NodeMCU Module GPIO Functions

class=”docutils” style=”height: 360px;” border=”1″ width=”527″ align=”center”>

gpio.mode()Initialize pin to GPIO mode, set the pin in/out direction, and optional internal weak pull-up.
gpio.read()Read digital GPIO pin value.
gpio.serout()Serialize output based on a sequence of delay-times in ยตs.
gpio.trig()Establish or clear a callback function to run on interrupt for a pin.
gpio.write()Set digital GPIO pin value.
gpio.pulseThis covers a set of APIs that allow generation of pulse trains with accurate timing on
multiple pins.
gpio.pulse.buildThis builds the gpio.
gpio.pulse:startThis starts the output operations.
gpio.pulse:getstateThis returns the current state.
gpio.pulse:stopThis stops the output operation at some future time.
gpio.pulse:cancelThis stops the output operation immediately.
gpio.pulse:adjustThis adds (or subtracts) time that will get used in the min / max delay case.
gpio.pulse:updateThis can change the contents of a particular step in the output program.

 

Note : [*] D0(GPIO16) can only be used as gpio read/write. No support for open-drain/interrupt/pwm/i2c/ow.


 

Pr-Request

 

GPIO pin set as input

  • if you have questions like How set GPIO pin as input in ESP8266? then refer the below contents

 

Required for ESP8266 NodeMCU Module GPIO

  • ESP8266 Any module or NodeMCU Development Kit(Any Version)
  • ESPlorer
  • Wires (Optional)

Note : if your using ESP8266 module only you need to know basic connection diagram of ESP8266

 

Code

 

-- set pin index 1 to GPIO mode, and set the pin to high.
pin=3 --gpio-0
gpio.mode(pin, gpio.INPUT)
while true do
print("GPIO Read PIN Status : "..gpio.read(pin))
end

 


GPIO pin set as output

  • Set GPIO pin as output using gpio.mode()ย  function.
  • Example : gpio.mode(pin, gpio.INPUT)

 

Code

pin = 3
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin,HIGH)
--gpio.write(pin, LOW)

 

 


GPIO pin status monitor

  • GPIO pin monitor status is very useful, because if you wanna monitor the pin status based on do the some process can easily.
  • Example : continuously monitor the gpio input button pin and based on button pin low/high level trun on/off the led.

 

Required

  • ESP8266 Any module or NodeMCU Development Kit(Any Version)
  • ESPlorer
  • Wires (Optional)

Note : if your using ESP8266 module only you need to know basic connection diagram of ESP8266.

 

Basic connection Diagram

Note : this below diagram for flash nodeMCU Firmware to ESP8266. We use the same circuit. But GPIO-0 Should be High or float Mode

 

Code

--www.aruneworld.com/embedded/esp8266/esp8266-nodecmu

button_pin=3 --GPIO-0
gpio.mode(button_pin, gpio.INPUT)

while true do
    print("GPIO Read PIN Status : "..gpio.read(button_pin))
    tmr.delay(1000000)
end

 

 


 

Please turn AdBlock off, and continue learning

Notice for AdBlock users

Please turn AdBlock off