echo '' ;

Archives

ESP8266 NodeMCU Module – GPIO

 

ESP8266 NodeMCU Devkit GPIO Pin Map

 

 

IO index ESP8266 pin IO index ESP8266 pin
0 [*] GPIO16 7 GPIO13
1 GPIO5 8 GPIO15
2 GPIO4 9 GPIO3
3 GPIO0 10 GPIO1
4 GPIO2 11 GPIO9
5 GPIO14 12 GPIO10
6 GPIO12

 

 


 ESP8266 NodeMCU Module GPIO Functions

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.pulse This covers a set of APIs that allow generation of pulse trains with accurate timing on
multiple pins.
gpio.pulse.build This builds the gpio.
gpio.pulse:start This starts the output operations.
gpio.pulse:getstate This returns the current state.
gpio.pulse:stop This stops the output operation at some future time.
gpio.pulse:cancel This stops the output operation immediately.
gpio.pulse:adjust This adds (or subtracts) time that will get used in the min / max delay case.
gpio.pulse:update This 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

  • 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)

 

Result

 

 


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

 

 


 

ESP32 ArduinoCore Interface – Basic Example

When programming the ESP32 using the Arduino IDE, you typically use the ESP32 Arduino core, which provides a set of libraries and APIs to facilitate development. In this tutorial, we can discuss ESP32 ArduinoCore Interface Basic Example of Serial, GPIO, Timer, etc

Explore the fundamental features of the ESP32 microcontroller through an introductory example utilizing the ArduinoCore interface. This tutorial covers Serial communication, GPIO configuration for digital input and output, and Timer usage for precise timing operations. Ideal for beginners and hobbyists, this basic example demonstrates how to implement essential functionalities such as blinking an LED, reading button inputs, and handling timer interrupts, providing a solid foundation for further exploration and development with the ESP32 platform.”

Read more… →

ESP32 Lua-RTOS Module – PIO

The PIO (Programmable Input/Output) module in the ESP32 Lua-RTOS is a versatile feature that allows users to configure and control the GPIO pins of the ESP32 microcontroller dynamically. It provides an interface for performing various operations such as digital input, digital output, and pulse-width modulation (PWM) generation, among others.

Functionalities and Capabilities

  1. Digital Input/Output: The PIO module allows users to configure GPIO pins as digital inputs or outputs. Digital inputs can be used to read the state of external sensors or switches, while digital outputs can drive external devices such as LEDs, relays, or motors.
  2. Interrupt Handling: It supports interrupt handling on GPIO pins, allowing users to trigger actions based on changes in pin states. This feature is useful for implementing event-driven applications where real-time responses to external events are required.
  3. Pull-up/Pull-down Resistors: The PIO module enables users to enable or disable the internal pull-up or pull-down resistors on GPIO pins, ensuring stable and reliable signal readings.
  4. Pulse-Width Modulation (PWM): It provides support for generating PWM signals on GPIO pins, allowing users to control the intensity of analog devices such as LEDs, motors, or servos.
  5. Pin Configuration: Users can dynamically configure the functionality and characteristics of GPIO pins using the PIO module, including setting pin modes (input/output), configuring interrupt triggers, and adjusting PWM parameters.
  6. Low-Level Access: The PIO module offers low-level access to GPIO pins, allowing users to directly manipulate pin states and registers for advanced control and customization.
  7. Resource Management: It provides mechanisms for managing GPIO pin resources efficiently, preventing conflicts and ensuring proper allocation of resources across different tasks or modules.

Overall, the PIO module in the ESP32 Lua-RTOS enhances the flexibility and versatility of the ESP32 microcontroller, enabling users to implement a wide range of GPIO-based applications with ease and efficiency. Whether for simple digital I/O tasks or more complex PWM generation and interrupt handling, the PIO module offers powerful capabilities for interacting with external devices and sensors in Lua-RTOS projects.

Read more… →