lzw655/esp32_io_expander

uploaded 8 months ago
ESP32 IO Expander Driver which encapsulates various components using C++

readme

# ESP32_IO_Expander

ESP32_IO_Expander is a versatile library designed to drive IO expander chips with ESP32. It is based on [Arduino-ESP32](https://github.com/espressif/arduino-esp32) (or [ESP-IDF](https://github.com/espressif/esp-idf)) and utilizes [Espressif Components Registry](https://components.espressif.com/), with various components encapsulated using C++.

## Features

* Supports both Arduino-ESP32 and ESP-IDF SDKs.
* Compatible with various IO expander chips.
* Provides support to control individual IO pins in the same way as Arduino (using pinMode(), digitalRead(), and digitalWrite() functions).
* Allows simultaneous control of multiple IO pins.

## How to Use

```cpp
#include <ESP_IOExpander_Library.h>

// Create an ESP_IOExpander object according to the chip type
ESP_IOExpander *expander = new ESP_IOExpander_TCA95xx_8bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_000, I2C_SCL_PIN, 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;
```

## Arduino Example

* [test](examples/test): Demonstrates how to use ESP32_IO_Expander and test all functions.

## SDK Versions

The following tables show the supported SDK versions for ESP32_IO_Expander at different versions.

| **ESP32_IO_Expander** | **Arduino-ESP32** | **ESP-IDF** |
| :-------------------: | :---------------: | :---------: |
|        v1.x.x         |     >= v2.0.9     |  >= v4.4.5  |

## Supported Drivers

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

changelog

# ChangeLog

## v1.0.0 - 2023-07-27

### Enhancements:

* Supports both Arduino-ESP32 and ESP-IDF SDKs.
* Support for various IO expander chips.
* Support to control individual IO in the same way as Arduino
* Support to control multiple IOs at the same time.

## v1.0.1 - 2023-07-28

### Fixed:

* Modify title of output log in test_apps
* Add comments for APIs

### Enhancements:

* Add `getHandle()` API
* Update CI for building `test_apps`
* Update CI for `pre-commit`

## v1.0.2 - 2023-08-10

### Fixed:

* Use namespace for `CheckResult`

### Enhancements:

* Upload into Espressif Registry

## v1.1.0 - 2023-08-14

### Fixed:

* Change library name to `ESP32_IO_Expander`

Links

Supports all targets

License: Apache-2.0

To add this component to your project, run:

idf.py add-dependency "lzw655/esp32_io_expander^1.1.0"

or download archive

Dependencies

  • ESP-IDF >=4.4.5
  • Stats

    • Downloaded in total
      Downloaded in total 41 times
    • Downloaded this version
      This version: 32 times

    Badge

    lzw655/esp32_io_expander version: 1.1.0
    |