Skip to content

Arduino library of driving IO expander chips for the ESP SoCs

License

Notifications You must be signed in to change notification settings

H-sw123/ESP32_IO_Expander

 
 

Repository files navigation

Arduino Lint pre-commit Build Test Apps

ESP32_IO_Expander

ESP32_IO_Expander is an Arduino library designed for driving IO expander chips using ESP32 SoCs.

ESP32_IO_Expander encapsulates various components from the Espressif Components Registry. It is developed based on arduino-esp32 and can be easily downloaded and integrated into the Arduino IDE.

Features

  • Supports various IO expander chips.
  • Supports controlling individual IO pin (using pinMode(), digitalRead(), and digitalWrite() functions).
  • Supports controlling multiple IO pins simultaneously.

Supported Drivers

Driver Version
esp_io_expander 1.0.1
TCA95xx (8bit) 1.0.1
TCA95xx (16bit) 1.0.0
HT8574 1.0.0

Dependencies Version

Name Version
ESP32_IO_Expander v0.x.x
arduino-esp32 >= v2.0.9

How to Use

For information on how to use the library in the Arduino IDE, please refer to the documentation for Arduino IDE v1.x.x or Arduino IDE v2.x.x.

Examples

  • Test Functions: Demonstrates how to use ESP32_IO_Expander and test all functions.

Detailed Usage

#include <ESP_IOExpander_Library.h>

// Create an ESP_IOExpander object according to the chip type
ESP_IOExpander *expander = new ESP_IOExpander_TCA95xx_8bit(EXAMPLE_I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_000,
                                                           EXAMPLE_I2C_SCL_PIN, EXAMPLE_I2C_SDA_PIN);

// Control a single pin (0-31)
expander->pinMode(0, OUTPUT);
expander->digitalWrite(0, HIGH);
expander->digitalWrite(0, LOW);
expander->pinMode(0, INPUT);
int level = expander->digitalRead(0);

// Control multiple pins (IO_EXPANDER_PIN_NUM_0 - IO_EXPANDER_PIN_NUM_31)
expander->multiPinMode(IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, OUTPUT);
expander->multiDigitalWrite(IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, HIGH);
expander->multiDigitalWrite(IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, LOW);
expander->multiPinMode(IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, INPUT);
uint32_t level = expander->multiDigitalRead(IO_EXPANDER_PIN_NUM_2 | IO_EXPANDER_PIN_NUM_3);

// Release the ESP_IOExpander object
delete expander;

About

Arduino library of driving IO expander chips for the ESP SoCs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 75.9%
  • C 22.7%
  • Other 1.4%