espressif/esp32_io_expander

0.1.0

uploaded 1 month ago
ESP32_IO_Expander is a library designed for driving IO expander chips using ESP32 SoCs

readme

[![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/pre-commit.yml) [![Build Test Apps](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/build_test.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/build_test.yml)

**Latest Arduino Library Version**: [![GitHub Release](https://img.shields.io/github/v/release/esp-arduino-libs/ESP32_IO_Expander)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/releases)

**Latest Espressif Component Version**: [![Espressif Release](https://components.espressif.com/components/espressif/ESP32_IO_Expander/badge.svg)](https://components.espressif.com/components/espressif/ESP32_IO_Expander)

# ESP32_IO_Expander

ESP32_IO_Expander is a library designed for driving [IO expander chips](#supported-drivers) using ESP32 SoCs.

ESP32_IO_Expander encapsulates various components from the [Espressif Components Registry](https://components.espressif.com/). It is developed based on [arduino-esp32](https://github.com/espressif/arduino-esp32) or [esp-idf](https://github.com/espressif/esp-idf), 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.
* Supports building on the Arduino IDE and the ESP-IDF framework.

## Supported Drivers

|                                               **Driver**                                               | **Version** |
| ------------------------------------------------------------------------------------------------------ | ----------- |
| [esp_io_expander](https://components.espressif.com/components/espressif/esp_io_expander)               | 1.0.1       |
| [TCA95xx (8bit)](https://components.espressif.com/components/espressif/esp_io_expander_tca9554)        | 1.0.1       |
| [TCA95xx (16bit)](https://components.espressif.com/components/espressif/esp_io_expander_tca95xx_16bit) | 1.0.0       |
| [HT8574](https://components.espressif.com/components/espressif/esp_io_expander_ht8574)                 | 1.0.0       |
| CH422G                                                                                                 | x           |

## Dependencies Version

### Arduino

|                          **Name**                           | **Version** |
| ----------------------------------------------------------- | ----------- |
| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v3.0.0   |

### ESP-IDF

|                    **Name**                     | **Version** |
| ----------------------------------------------- | ----------- |
| [esp-idf](https://github.com/espressif/esp-idf) | >= v5.1     |

## 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](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries) or [Arduino IDE v2.x.x](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-installing-a-library).

### Examples

* [Test Functions](examples/TestFunctions): Demonstrates how to use ESP32_IO_Expander and test all functions.
* [Test CH422G](examples/TestCH422G): Demonstrates how to use ESP32_IO_Expander with the CH422G chip.

### Detailed Usage

```cpp
#include <ESP_IOExpander_Library.h>

// Create and initialize 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);
expander->init();
expander->begin();

// 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;
```

Links

Supports all targets

License: Apache-2.0

To add this component to your project, run:

idf.py add-dependency "espressif/esp32_io_expander^0.1.0"

or download archive

Stats

  • Archive size
    Archive size ~ 23.63 KB
  • Downloaded in total
    Downloaded in total 1.2k times
  • Downloaded this version
    This version: 1.2k times

Badge

espressif/esp32_io_expander version: 0.1.0
|