Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,373
» Latest member: babo4220
» Forum threads: 3,653
» Forum posts: 18,869

Full Statistics

Online Users
There are currently 29 online users.
» 0 Member(s) | 10 Guest(s)
AhrefsBot, Amazonbot, Applebot, DotBot, Facebook, Google, bot, facebookexternalhit

Latest Threads
Connect um330 and kc828 a...
Forum: DIY Project
Last Post: admin
1 minute ago
» Replies: 25
» Views: 3,377
Problema a cargar .bin al...
Forum: KC868-A2
Last Post: admin
7 hours ago
» Replies: 1
» Views: 8
"SmartLife" wifi transmit
Forum: TA
Last Post: admin
7 hours ago
» Replies: 7
» Views: 33
Kc868a newbie questions
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
7 hours ago
» Replies: 5
» Views: 110
KINCONY IN KSA
Forum: DIY Project
Last Post: admin
7 hours ago
» Replies: 1
» Views: 9
flash Kincony software to...
Forum: DIY Project
Last Post: admin
7 hours ago
» Replies: 1
» Views: 10
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: cmeyer5
Yesterday, 02:34 PM
» Replies: 140
» Views: 25,860
T16M not responding on US...
Forum: T16M
Last Post: admin
01-05-2026, 12:14 PM
» Replies: 3
» Views: 22
kc868-ag mqtt yaml
Forum: KC868-AG / AG Pro / AG8 / Z1
Last Post: admin
01-05-2026, 05:09 AM
» Replies: 3
» Views: 20
N20 CT Shorting terminal ...
Forum: N20
Last Post: admin
01-05-2026, 05:08 AM
» Replies: 1
» Views: 11

  4-20mah sensor wiring example
Posted by: aucirc - 09-16-2024, 01:26 PM - Forum: KC868-AIO - Replies (3)

I'm considering the KC868-AIO - I need several water level sensors and interested in using the 4-20mah version of this (as the accuracy is better over longer distances)
https://aliexpress.com/item/1005006338737673.html

It's a two-wire sensor, but I can't find any examples of how this should be connected to the KC868-AIO?  As these work best with 24V should the KC868-AIO be powered with 24V also?

Print this item

  KC868 A32 Firmware 2.2.4 binding
Posted by: iozzi_giorgio - 09-16-2024, 11:27 AM - Forum: KC868-A32/A32 Pro - Replies (2)

good morning I tried to load the KCS 2.2.4 firmware on the KC868_A32 rev. 1.4 board. in programming I can't connect the input to the output (bind). in the input screen I only see "reverse". I also tried to load a previous version of KCS. I saw the video on YouTube but I couldn't solve it. I also tried with different browsers. can you help me?



Attached Files Thumbnail(s)
           
Print this item

  AG PRO / KCS Firmware / IR Learning / Node Red
Posted by: chmabu - 09-16-2024, 07:27 AM - Forum: KC868-AG / AG Pro / AG8 / Z1 - No Replies

Hi,

running the AG PRO with the latest firmware.

1. IR Learning - KCS
If I put the firmware to learning via KCS Web frontend, the Samsung TV IR signals are not recorded. Even no beep is played.
If I use Tuya the IR is recorded.

2. IR Learining - Node Red
In addition I found a video on youtube where the Inject node was used to put IR in learning.
Now I checked the HTTP and the MQTT protocoll. There is no explanation on these protocols how to do this.

3. MQTT Problems
I enabled the MQTT to a remote MQTT server.
Using the MQTT-Explorer I can see the Topic with STATE created. So, apparently AG and MQTT server connection is ok.

BUT: STATE is always empty! Also when I send  {"get _datas" : {"value": true}} -  nothing is responded.

Print this item

  KinCony Video Contest: Share Your Project, Earn Rewards!
Posted by: admin - 09-16-2024, 02:00 AM - Forum: News - Replies (1)

KinCony Video Submission Campaign: Showcase Your Project and Get Rewarded!
Dear Valued KinCony Customers,
We’re excited to launch a new campaign where you can share how you’re using KinCony products in your projects and help inspire other users! Simply create a short, real-life video showcasing KinCony products in action, and in return, you’ll receive rewards and have your video featured on our official KinCony YouTube channel.
Video Submission Requirements:

  1. Record in vertical format using your smartphone.
  2. The video should be between 15 seconds and 1 minute long.
  3. Show the real wiring connections of the product.
  4. Highlight the actual control features in action.
  5. Capture the real environment where the product is used, such as home settings, outdoor farms, or other real-world IoT project environments.
How to Participate:
  1. Submit your video in MP4 format along with your KinCony official store account email address and username to kincony.iot@gmail.com, or upload it to Google Drive and email us the download link.
  2. We will review your submission within 2 business days and, if approved, upload it to our YouTube channel to share your project with the community.
Get Rewarded: As a token of appreciation, we will provide you with a discount coupon for your next purchase on the KinCony website. Coupon values range from 5 USD to 10 USD, depending on the quality of the video.
We believe that your video can help more users understand and utilize KinCony products in their own projects. We look forward to seeing your submissions and sharing your success with the KinCony community!

Print this item

  a16 as basis for a security system
Posted by: lcrisp - 09-16-2024, 12:50 AM - Forum: KC868-A16 - Replies (16)

I was planning to use my A16 to form a security system, and while door sensors are easy enough, I'm just a touched confused over how to connect alarms, buzzers, and a motion detector...

A four-wire motion detector needs two of it's wires to be connected to a 12v power supply (I think?) and it's two alarm wires can be connected directly to one of the dry digital inputs.

I believe that I'll then need to connect the siren and alarm to the mosfet outputs via two relays, which will then also have to be connected to their own power supplies?

Am I correct in this assumption? I purchased three 12v power supplies with the board, but I'm now worried that I'll need to purchase another one just to hook everything up! Am I correct in assuming that none of them can be powered via the board's 12v power supply? Can any of them be connected to a 12v power supply in sequence. *Especially valid because an alarm shouldn't ever be sounding (drawing power from a supply) at the same time as a buzzer.

And thus far I've connected it to Home Assistant via Esphome, but because my wireless networks have been hacked before I'd rather limit the A16's exposure to potential hacking attempts. Is there any other way to connect the A16 to Home Assistant so that it doesn't need to be constantly connected via ethernet?

Print this item

  Free sample request
Posted by: Tran Song HUng - 09-15-2024, 03:59 PM - Forum: Apply for free sample product - No Replies

Dear KINCONY Team

I already know some microprocessor like as PIC, Atmega and now. I want to learn ESP32.
After learning hardware. I know KINCONY have support Apply for free sample.
I hope i can be lucky enough to get it.

I am waiting your feedback.

Thank you so much.  Heart

Print this item

  H32L - faulty network card
Posted by: athxp - 09-15-2024, 08:19 AM - Forum: KC868-HxB series Smart Controller - Replies (5)

hi, this morning I found H32L disconnected. the network card is turned off and has no green LEDs on. ESP32 tuya module also fails to connect. I tried changing the cable but nothing.
from the input keys the plc works correctly. I attach a screenshot, where you can see that it is not online. what could have happened?
Thank you



Attached Files Thumbnail(s)
   
Print this item

  [ESP-IDF code examples for A32 Pro]-02 Read digital input ports state
Posted by: admin - 09-14-2024, 12:47 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program reads inputs from two XL9535 I/O expander chips (I2C addresses 0x24 and 0x25)
* and one PCF8574 I/O expander (I2C address 0x23) via I2C using an ESP32-S3.
* The state of all inputs is printed in binary format to the serial monitor every second.
*
* - The XL9535 chips read inputs from channels 1-32.
* - The PCF8574 chip reads inputs from channels 33-40.
*
* I2C is initialized on GPIO 11 (SDA) and GPIO 10 (SCL) with a frequency of 40kHz.
*/

#include <stdio.h>
#include "driver/i2c.h"
#include "esp_log.h"

// I2C communication settings
#define I2C_MASTER_SCL_IO           10    // GPIO number for I2C clock line (SCL)
#define I2C_MASTER_SDA_IO           11    // GPIO number for I2C data line (SDA)
#define I2C_MASTER_FREQ_HZ          40000  // I2C frequency set to 40kHz
#define I2C_MASTER_PORT             I2C_NUM_0  // I2C port number used in this program

// I2C addresses for XL9535 chips and PCF8574
#define XL9535_ADDR_1               0x24  // Address for XL9535 (channels 1-16)
#define XL9535_ADDR_2               0x25  // Address for XL9535 (channels 17-32)
#define PCF8574_ADDR                0x23  // Address for PCF8574 (channels 33-40)

// XL9535 registers for input ports
#define XL9535_INPUT_PORT_0         0x00  // Input register for port 0 (channels 1-8)
#define XL9535_INPUT_PORT_1         0x01  // Input register for port 1 (channels 9-16)

// Function prototypes
esp_err_t i2c_master_init();
esp_err_t xl9535_read_inputs(uint8_t device_addr, uint8_t *data);
esp_err_t pcf8574_read_inputs(uint8_t *data);
void read_and_print_inputs();

void app_main() {
    // Initialize I2C master
    ESP_ERROR_CHECK(i2c_master_init());

    // Main loop to read and print input states every second
    while (1) {
        read_and_print_inputs();
        vTaskDelay(1000 / portTICK_PERIOD_MS);  // Wait for 1 second
    }
}

// Initialize I2C master interface
esp_err_t i2c_master_init() {
    i2c_config_t conf = {
        .mode = I2C_MODE_MASTER,  // Set I2C mode to master
        .sda_io_num = I2C_MASTER_SDA_IO,  // SDA GPIO pin
        .scl_io_num = I2C_MASTER_SCL_IO,  // SCL GPIO pin
        .sda_pullup_en = GPIO_PULLUP_ENABLE,  // Enable internal pull-up for SDA line
        .scl_pullup_en = GPIO_PULLUP_ENABLE,  // Enable internal pull-up for SCL line
        .master.clk_speed = I2C_MASTER_FREQ_HZ,  // Set I2C clock frequency to 40kHz
    };
    i2c_param_config(I2C_MASTER_PORT, &conf);
    return i2c_driver_install(I2C_MASTER_PORT, conf.mode, 0, 0, 0);
}

// Read inputs from XL9535 I/O expander
esp_err_t xl9535_read_inputs(uint8_t device_addr, uint8_t *data) {
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, (device_addr << 1) | I2C_MASTER_WRITE, true);
    i2c_master_write_byte(cmd, XL9535_INPUT_PORT_0, true);
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, (device_addr << 1) | I2C_MASTER_READ, true);
    i2c_master_read_byte(cmd, &data[0], I2C_MASTER_ACK);  // Read port 0 (channels 1-8 or 17-24)
    i2c_master_read_byte(cmd, &data[1], I2C_MASTER_NACK); // Read port 1 (channels 9-16 or 25-32)
    i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_PORT, cmd, 1000 / portTICK_PERIOD_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}

// Read inputs from PCF8574 I/O expander
esp_err_t pcf8574_read_inputs(uint8_t *data) {
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, (PCF8574_ADDR << 1) | I2C_MASTER_READ, true);
    i2c_master_read_byte(cmd, data, I2C_MASTER_NACK);
    i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_PORT, cmd, 1000 / portTICK_PERIOD_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}

// Function to read and print the state of inputs from XL9535 and PCF8574 chips
void read_and_print_inputs() {
    uint8_t xl9535_data_1[2];  // Data buffer for XL9535 (channels 1-16)
    uint8_t xl9535_data_2[2];  // Data buffer for XL9535 (channels 17-32)
    uint8_t pcf8574_data;      // Data buffer for PCF8574 (channels 33-40)

    // Read inputs from the first XL9535 (channels 1-16)
    if (xl9535_read_inputs(XL9535_ADDR_1, xl9535_data_1) == ESP_OK) {
        printf("1-16 input states: %02X%02X\n", xl9535_data_1[1], xl9535_data_1[0]);  // Print in binary
    } else {
        printf("Error reading from XL9535 (channels 1-16)\n");
    }

    // Read inputs from the second XL9535 (channels 17-32)
    if (xl9535_read_inputs(XL9535_ADDR_2, xl9535_data_2) == ESP_OK) {
        printf("17-32 input states: %02X%02X\n", xl9535_data_2[1], xl9535_data_2[0]);  // Print in binary
    } else {
        printf("Error reading from XL9535 (channels 17-32)\n");
    }

    // Read inputs from the PCF8574 (channels 33-40)
    if (pcf8574_read_inputs(&pcf8574_data) == ESP_OK) {
        printf("33-40 input states: %02X\n", pcf8574_data);  // Print in binary
    } else {
        printf("Error reading from PCF8574 (channels 33-40)\n");
    }
}
   

Print this item

  [ESP-IDF code examples for A32 Pro]-01 Turn ON/OFF relay
Posted by: admin - 09-14-2024, 12:38 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This program controls two PCA9555 I/O expander chips via I2C to control a total of 32 relays.
* The first PCA9555 (at I2C address 0x21) controls relays 1-16, while the second PCA9555 (at I2C address 0x22)
* controls relays 17-32. The relays are turned ON (LOW) and OFF (HIGH) in sequence.
*
* Each PCA9555 chip has two ports: port 0 controls relays 1-8 (or 17-24), and port 1 controls relays 9-16 (or 25-32).
*
* The program will initialize both chips and turn all relays OFF initially, then turn each relay ON one by one.
* After a delay, all relays are turned OFF again.
*/

#include <stdio.h>
#include <string.h>
#include "driver/i2c.h"
#include "esp_log.h"

// I2C communication settings
#define I2C_MASTER_SCL_IO           10    // GPIO number for I2C clock line (SCL)
#define I2C_MASTER_SDA_IO           11    // GPIO number for I2C data line (SDA)
#define I2C_MASTER_FREQ_HZ          100000 // Frequency for I2C clock (100kHz)
#define I2C_MASTER_PORT             I2C_NUM_0 // I2C port number used in this program

// I2C write/read settings
#define WRITE_BIT                   I2C_MASTER_WRITE // I2C write mode
#define READ_BIT                    I2C_MASTER_READ  // I2C read mode
#define ACK_CHECK_EN                0x1     // Enable I2C ACK checking
#define ACK_CHECK_DIS               0x0     // Disable I2C ACK checking
#define ACK_VAL                     0x0     // I2C ACK value
#define NACK_VAL                    0x1     // I2C NACK value

// PCA9555 I2C addresses (chip 1: controls relays 1-16, chip 2: controls relays 17-32)
#define PCA9555_ADDR_1              0x21    // I2C address for the first PCA9555 (1-16 relays)
#define PCA9555_ADDR_2              0x22    // I2C address for the second PCA9555 (17-32 relays)

// PCA9555 Register addresses
#define PCA9555_REG_OUTPUT_0        0x02    // Output register for port 0 (controls relays 1-8 or 17-24)
#define PCA9555_REG_OUTPUT_1        0x03    // Output register for port 1 (controls relays 9-16 or 25-32)

// Function declarations (prototypes)
esp_err_t i2c_master_init(); // Initializes the I2C master
esp_err_t pca9555_write_byte(uint8_t device_addr, uint8_t reg_addr, uint8_t data); // Writes a byte to a PCA9555 register
void control_relays(); // Main function to control the relays

// Main application entry point
void app_main() {
    // Initialize I2C master interface
    ESP_ERROR_CHECK(i2c_master_init());

    // Set both PCA9555 chips' all pins as output and turn all relays OFF initially (0xFF = all HIGH = OFF)
    ESP_ERROR_CHECK(pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_0, 0xFF)); // Turn off relays 1-8
    ESP_ERROR_CHECK(pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_1, 0xFF)); // Turn off relays 9-16
    ESP_ERROR_CHECK(pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_0, 0xFF)); // Turn off relays 17-24
    ESP_ERROR_CHECK(pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_1, 0xFF)); // Turn off relays 25-32

    // Start controlling relays (turn on one by one, then off)
    control_relays();
}

// Function to initialize the I2C master
esp_err_t i2c_master_init() {
    // I2C configuration structure
    i2c_config_t conf = {
        .mode = I2C_MODE_MASTER,       // Set the I2C mode to master
        .sda_io_num = I2C_MASTER_SDA_IO, // Set the SDA GPIO pin
        .scl_io_num = I2C_MASTER_SCL_IO, // Set the SCL GPIO pin
        .sda_pullup_en = GPIO_PULLUP_ENABLE, // Enable internal pull-up for SDA line
        .scl_pullup_en = GPIO_PULLUP_ENABLE, // Enable internal pull-up for SCL line
        .master.clk_speed = I2C_MASTER_FREQ_HZ, // Set I2C clock frequency to 100kHz
    };
    // Apply I2C configuration to I2C master port
    i2c_param_config(I2C_MASTER_PORT, &conf);
    // Install the I2C driver for the master port
    return i2c_driver_install(I2C_MASTER_PORT, conf.mode, 0, 0, 0);
}

// Function to write a byte of data to a specified register of the PCA9555
// device_addr: I2C address of the PCA9555 chip (0x21 or 0x22)
// reg_addr: Register address to write to (e.g., output register 0 or 1)
// data: The byte of data to write (e.g., relay states: HIGH = OFF, LOW = ON)
esp_err_t pca9555_write_byte(uint8_t device_addr, uint8_t reg_addr, uint8_t data) {
    // Create a new I2C command link
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    // Start the I2C communication
    i2c_master_start(cmd);
    // Send the PCA9555's I2C address with the write bit
    i2c_master_write_byte(cmd, (device_addr << 1) | WRITE_BIT, ACK_CHECK_EN);
    // Send the register address where the data should be written
    i2c_master_write_byte(cmd, reg_addr, ACK_CHECK_EN);
    // Send the actual data to be written to the register
    i2c_master_write_byte(cmd, data, ACK_CHECK_EN);
    // Stop the I2C communication
    i2c_master_stop(cmd);
    // Execute the I2C command and return the result
    esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_PORT, cmd, 1000 / portTICK_PERIOD_MS);
    // Delete the I2C command link after use
    i2c_cmd_link_delete(cmd);
    return ret;
}

// Function to control the relays on both PCA9555 chips
void control_relays() {
    uint8_t relay_state_0 = 0xFE; // Relay 1 ON (LOW), others OFF (HIGH) for port 0
    uint8_t relay_state_1 = 0xFF; // All OFF (HIGH) for port 1 initially

    // Control the first PCA9555 chip (relays 1-16)
    // Port 0 controls relays 1-8
    for (int i = 0; i < 8; ++i) {
        ESP_LOGI("Relay Control", "Setting relay %d ON (chip 1, port 0)", i + 1);
        // Write relay states to port 0 of the first PCA9555 (1-8 relays)
        pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_0, relay_state_0);
        relay_state_0 = (relay_state_0 << 1) | 0x01; // Shift to the next relay
        vTaskDelay(100 / portTICK_PERIOD_MS); // Delay between relay actions
    }

    relay_state_0 = 0xFE; // Reset state for port 0, relay 9 ON

    // Port 1 controls relays 9-16
    for (int i = 0; i < 8; ++i) {
        ESP_LOGI("Relay Control", "Setting relay %d ON (chip 1, port 1)", i + 9);
        // Write relay states to port 1 of the first PCA9555 (9-16 relays)
        pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_1, relay_state_0);
        relay_state_0 = (relay_state_0 << 1) | 0x01; // Shift to the next relay
        vTaskDelay(100 / portTICK_PERIOD_MS); // Delay between relay actions
    }

    relay_state_0 = 0xFE; // Relay 17 ON (LOW), others OFF (HIGH) for port 0

    // Control the second PCA9555 chip (relays 17-32)
    // Port 0 controls relays 17-24
    for (int i = 0; i < 8; ++i) {
        ESP_LOGI("Relay Control", "Setting relay %d ON (chip 2, port 0)", i + 17);
        // Write relay states to port 0 of the second PCA9555 (17-24 relays)
        pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_0, relay_state_0);
        relay_state_0 = (relay_state_0 << 1) | 0x01; // Shift to the next relay
        vTaskDelay(100 / portTICK_PERIOD_MS); // Delay between relay actions
    }

    relay_state_0 = 0xFE; // Reset state for port 1, relay 25 ON

    // Port 1 controls relays 25-32
    for (int i = 0; i < 8; ++i) {
        ESP_LOGI("Relay Control", "Setting relay %d ON (chip 2, port 1)", i + 25);
        // Write relay states to port 1 of the second PCA9555 (25-32 relays)
        pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_1, relay_state_0);
        relay_state_0 = (relay_state_0 << 1) | 0x01; // Shift to the next relay
        vTaskDelay(100 / portTICK_PERIOD_MS); // Delay between relay actions
    }

    // After a short delay, turn all relays OFF
    vTaskDelay(1000 / portTICK_PERIOD_MS);
    // Set all relays on both chips to OFF (HIGH)
    pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_0, 0xFF); // Turn off relays 1-8
    pca9555_write_byte(PCA9555_ADDR_1, PCA9555_REG_OUTPUT_1, 0xFF); // Turn off relays 9-16
    pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_0, 0xFF); // Turn off relays 17-24
    pca9555_write_byte(PCA9555_ADDR_2, PCA9555_REG_OUTPUT_1, 0xFF); // Turn off relays 25-32
}
   

Print this item

  [arduino code examples for A32 Pro]-11 How to use digital input port trigger relay
Posted by: admin - 09-14-2024, 12:12 AM - Forum: KC868-A32/A32 Pro - Replies (2)

Code:
/*
  Made by KinCony IoT: https://www.kincony.com

  Program functionality:
  This program uses ESP32-S3 to read inputs from two PCA9555 I/O expander chips (I2C addresses 0x24 and 0x25)
  for channels 1-32, and control corresponding relays using two PCA9555 I/O expander chips (I2C addresses 0x21 and 0x22)
  for controlling 32 relays (1-32). When input1 is triggered, relay1 is activated; when input2 is triggered,
  relay2 is activated, and so on.

  The I2C bus is initialized on GPIO pins 11 (SDA) and 10 (SCL) with a frequency of 100kHz.
*/

#include <PCA95x5.h>
#include <Wire.h>

// Initialize the PCA9555 objects for reading inputs (channels 1-32)
PCA9555 input_ioex1;  // For channels 1-16 (I2C address 0x24)
PCA9555 input_ioex2;  // For channels 17-32 (I2C address 0x25)

// Initialize the PCA9555 objects for controlling relays (channels 1-32)
PCA9555 output_ioex1; // For relays 1-16 (I2C address 0x21)
PCA9555 output_ioex2; // For relays 17-32 (I2C address 0x22)

void setup() {
    // Start serial communication for debugging
    Serial.begin(115200);
    delay(10);

    // Initialize the I2C bus with GPIO 11 as SDA and GPIO 10 as SCL, 100kHz frequency
    Wire.begin(11, 10, 100000);

    // Configure the input PCA9555 chips (for inputs 1-32)
    input_ioex1.attach(Wire, 0x24);  // I2C address 0x24 for inputs 1-16
    input_ioex1.polarity(PCA95x5::Polarity::ORIGINAL_ALL);  // No polarity inversion
    input_ioex1.direction(PCA95x5::Direction::IN_ALL);  // Set all pins as inputs

    input_ioex2.attach(Wire, 0x25);  // I2C address 0x25 for inputs 17-32
    input_ioex2.polarity(PCA95x5::Polarity::ORIGINAL_ALL);  // No polarity inversion
    input_ioex2.direction(PCA95x5::Direction::IN_ALL);  // Set all pins as inputs

    // Configure the output PCA9555 chips (for relays 1-32)
    output_ioex1.attach(Wire, 0x21);  // I2C address 0x21 for relays 1-16
    output_ioex1.polarity(PCA95x5::Polarity::ORIGINAL_ALL);  // No polarity inversion
    output_ioex1.direction(PCA95x5::Direction::OUT_ALL);  // Set all pins as outputs
    output_ioex1.write(PCA95x5::Level::H_ALL);  // Initialize all relays to OFF (HIGH)

    output_ioex2.attach(Wire, 0x22);  // I2C address 0x22 for relays 17-32
    output_ioex2.polarity(PCA95x5::Polarity::ORIGINAL_ALL);  // No polarity inversion
    output_ioex2.direction(PCA95x5::Direction::OUT_ALL);  // Set all pins as outputs
    output_ioex2.write(PCA95x5::Level::H_ALL);  // Initialize all relays to OFF (HIGH)

    delay(50);  // Wait for initialization to complete
}

void loop() {
    // Read the input states from the first PCA9555 chip (inputs 1-16)
    uint16_t inputs_1_16 = input_ioex1.read();
   
    // Iterate through each input (1-16) and control corresponding relay output
    for (int i = 0; i < 16; ++i) {
        bool input_state = bitRead(inputs_1_16, i);  // Read the state of each input (0 = triggered, 1 = not triggered)
        if (input_state == 0) {  // If the input is triggered (pressed, i.e., LOW)
            output_ioex1.write((PCA95x5::Port::Port)i, PCA95x5::Level::L);  // Activate corresponding relay (LOW)
        } else {
            output_ioex1.write((PCA95x5::Port::Port)i, PCA95x5::Level::H);  // Deactivate relay (HIGH)
        }
    }

    // Read the input states from the second PCA9555 chip (inputs 17-32)
    uint16_t inputs_17_32 = input_ioex2.read();
   
    // Iterate through each input (17-32) and control corresponding relay output
    for (int i = 0; i < 16; ++i) {
        bool input_state = bitRead(inputs_17_32, i);  // Read the state of each input (0 = triggered, 1 = not triggered)
        if (input_state == 0) {  // If the input is triggered (pressed, i.e., LOW)
            output_ioex2.write((PCA95x5::Port::Port)i, PCA95x5::Level::L);  // Activate corresponding relay (LOW)
        } else {
            output_ioex2.write((PCA95x5::Port::Port)i, PCA95x5::Level::H);  // Deactivate relay (HIGH)
        }
    }

    delay(100);  // Small delay for stability
}
arduino ino file download: 
.zip   11-input-trigger-output.zip (Size: 1.26 KB / Downloads: 446)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download: 
.zip   11-input-trigger-output.ino.merged.zip (Size: 187.31 KB / Downloads: 419)

Print this item