Module: gpio

Module to access pins for general purpose input/output. Also supports reading pins voltage via ADC and setting pins via PWM.
Source:

Classes

GPIOPin

Members

(static) ANALOG

Flag for GPIOPin.getValue. Retrieves voltage of pin via ADC (0 = 0V, 1 = board voltage).
Source:

(static) BUTTON :Number

The pin number for the user defined button = 27. Only defined on the neonious one.
Type:
  • Number
Source:

(static) DIGITAL

Flag for GPIOPin.getValue. Retrieves level of pin (exact 0 or 1).
Source:

(static) HIGH :Number

High level = 1
Type:
  • Number
Source:

(static) INPUT

Pins set to this type are input pins.
Source:

(static) INPUT_PULLDOWN

Pins set to this type are input pins with the internal pulldown resistor active.
Source:

(static) INPUT_PULLUP

Pins set to this type are input pins with the internal pullup resistor active.
Source:

(static) LED_GREEN :Number

The pin number for the green LED = 2. Only defined on the neonious one.
Type:
  • Number
Source:

(static) LED_RED :Number

The pin number for the red LED = 1. Only defined on the neonious one.
Type:
  • Number
Source:

(static) LOW :Number

Low level = 0
Type:
  • Number
Source:

(static) OUTPUT

Pins set to this type are output pins.
Source:

(static) OUTPUT_OPENDRAIN

Pins set to this type are output pins where level 1 is defined as not connected. Great for implementing busses. To use these, you need to use an external pull-up.
Source:

(static) pins :Array.<GPIOPin>

Access all pins via this array. The index is the pin number.
Type:
  • Array.<GPIOPin>
Source:

Methods

(static) getFrequency() → {Number}

Returns the frequency of the PWM pins.
Source:
Returns:
in Hz, default: 100 Hz
Type
Number

(static) getValues(callback)

Retrieves the levels of all pins which are set to input at once, via bit array.
Parameters:
Name Type Description
callback GPIOGetValuesCallback the callback called with the input levels
Source:

(static) setFrequency(frequency)

Set the frequency of the PWM pins.
Parameters:
Name Type Description
frequency Number in Hz, default: 100 Hz
Source:

(static) setValues(bits, bitsHiopt)

Allows to set all pins which are set to output at once, via bit array. PWM pins are not modified.
Parameters:
Name Type Attributes Description
bits Number the values for the first 32 pins as bit array
bitsHi Number <optional>
the values for the pins 33-39. Only required on plain ESP32-WROVER, as the bit numbering on the device is clumbersome: Even though there are less usable pins as with the neonious one, there are more pin numbers.
Source:

Type Definitions

GPIOGetValueCallback(errnullable, valueopt)

Callback for retrieval of the level or voltage (ADC) of an input pin
Parameters:
Name Type Attributes Description
err Error <nullable>
optional error. If not null, the next parameters are not set
value Number <optional>
if DIGITAL was used exactly 0 or 1, if ANALOG was used a value from 0 (= 0V) to 1 (= board voltage).
Source:

GPIOGetValuesCallback(errnullable, bitsopt, bitsHiopt)

Callback for retrieval of the levels of all input pins at once.
Parameters:
Name Type Attributes Description
err Error <nullable>
optional error. If not null, the next parameters are not set
bits Number <optional>
the values for the first 32 pins as bit array
bitsHi Number <optional>
the values for the pins 33-39. Only set on plain ESP32-WROVER, as the bit numbering on the device is clumbersome: Even though there are less usable pins as with the neonious one, there are more pin numbers.
Source:

Events

fall

Fired on GPIOPin, when the pin is set to INPUT, INPUT_PULLUP or INPUT_PULLDOWN and the level of the pin falls to 0
Source:

rise

Fired on GPIOPin, when the pin is set to INPUT, INPUT_PULLUP or INPUT_PULLDOWN and the level of the pin rises to 1
Source: