AW9523 I2C I/O Expander

The AW9523 component allows you to use the AWINIC Technology 16 x GPIO I2C I/O expander in ESPHome using the I²C Bus for communication.

The AW9523 is a 16 x multi-function I/O port expander. Each I/O can be configured in LED drive or GPIO mode (input or output).

The AW9523 has a standard I2C interface. Note: The device does not support internal pull-up or pull-down resistors on its I/O pins. You will need to add external resistors if you need them. After power on all 16 I/O ports are configured as GPIO outputs by default. When configured as inputs, each input is continuously monitored for state changes.

When the I/O ports are in LED drive mode, the AW9523 can set the current of each output up to a maximum of 37mA.

Once configured, you can use any of the 16 pins (0-15) within your projects. Within ESPHome they emulate a real internal GPIO pin and can therefore be used with many of ESPHome’s components such as the GPIO binary sensor or GPIO switch.

# Example configuration entry
aw9523:
  - id: aw9523_1

# Individual outputs
switch:
  - platform: gpio
    name: "AW9523 Pin 0"
    pin:
      aw9523: aw9523_1
      number: 0

output:
  - platform: aw9523
    aw9523: aw9523_1
    id: aw9523_pin_1
    max_current: 10 mA
    pin: 1

# Individual inputs
binary_sensor:
  - platform: gpio
    name: "AW9523 Pin 2"
    pin:
      aw9523: aw9523_1
      number: 2
      mode:
        input: true

Configuration variables

  • id (Required, ID): The id to use for this aw9523 component.
  • address (Optional, int): The I²C address of the device. Defaults to 0x58. On some M5Stack products the address is 0x59 (check the documentation for the product incorporating this expander).

Pin configuration variables

  • aw9523 (Required, ID): The id of the aw9523 component of the pin.

  • number (Required, int): The pin number. Valid range is 0-15.

  • inverted (Optional, boolean): If all read and written values should be treated as inverted. Defaults to false.

  • mode (Optional, Pin Mode): A pin mode to set for the pin. One of:

    • INPUT - Configure the pin as an input.
    • OUTPUT - Configure the pin as an output.

Examples

GPIO Switch Example

switch:
  - platform: gpio
    name: "Relay 1"
    pin:
     aw9523: aw9523_1
      number: 0
      mode:
        output: true

GPIO Binary Sensor Example

binary_sensor:
  - platform: gpio
    name: "Button 1"
    pin:
      aw9523: aw9523_1
      number: 1
      mode:
        input: true

GPIO Output with Inverted Logic

switch:
  - platform: gpio
    name: "LED Strip"
    pin:
      aw9523: aw9523_1
      number: 2
      mode:
        output: true
      inverted: true

Output with maximum current


light:
  - platform: monochromatic
    name: "AW9523 #03"
    output: aw9523_pin_3

output:
  - platform: aw9523
    aw9523: aw9523_1
    id: aw9523_pin_3
    max_current: 10 mA
    pin: 3

See Also