2025-05-18 10:06:27 +03:00
2025-05-18 10:06:27 +03:00
2025-04-24 11:54:16 +03:00
2025-04-24 09:34:04 +03:00
2025-05-18 10:06:27 +03:00

Empowering Innovation

Unlocking Unlimited Possibilities with Our Modular IoT Devices

At FABLAB Bahrain, we're revolutionizing the world of IoT devices with our cutting-edge, ESP32C3-based modules. Not only do they come pre-programmed as I2C slave devices, ready to be controlled via a simple interface, but they're also designed to be fully programmable and reconfigurable by end-users themselves. Our comprehensive library provides an intuitive way for developers to customize and fine-tune their products, whether it's changing addresses or integrating BLE or WiFi connectivity. But that's not all - we've also made it possible for users to upload their own firmware, empowering them to transform our modules into anything they can imagine. From smart home automation to industrial control systems, our devices are the perfect building blocks for your next innovation project. With our modular design and open-source approach, you'll have complete freedom to shape your IoT vision

I2C Communication Library

I2CRelay is an 8-relay module built around the ESP32-C3 Super Mini, featuring an I2C interface that allows it to be controlled by another MCU, enabling easy integration into complex control systems. Additionally, when paired with an ESP32-C3-based controller, it can leverage Wi-Fi and Bluetooth LE connectivity, expanding control options beyond wired I2C communication for wireless operation and enhanced flexibility in IoT and robotics applications. This combination of compact size, low power consumption, and versatile communication protocols makes the module indispensable for remote and automated control of multiple devices, offering scalable and reliable switching solutions for smart homes, industrial automation, and advanced robotics.

Table of Contents

  1. Technical Drawings
  2. Features
  3. Hardware Components Used
  4. Installation
  5. Versatility
  6. Usage
  7. API Overview
  8. Example Serial Commands
  9. Notes
  10. Credits
  11. License
  12. Project Image

Technical Drawings


Key Features of the 8-Relay Module with ESP32-C3 Super Mini

  • 8-Channel Relay Control: Enables switching of up to 8 high-power devices independently.
  • ESP32-C3 Super Mini Integration: Compact, powerful RISC-V processor with built-in Wi-Fi and Bluetooth 5.0 for versatile connectivity.
  • I2C Communication Interface: Allows easy control from another MCU with minimal wiring and reliable data transfer.
  • Wireless Control Capability: Supports Wi-Fi and Bluetooth when paired with an ESP32-C3-based controller, enabling remote and flexible device management.
  • Low Power Consumption: Efficient power usage suitable for battery-powered and IoT applications.
  • Compact and Lightweight Design: Ideal for space-constrained projects and embedded systems.
  • High Reliability and Safety: Optocoupler isolation and built-in protection circuits to safeguard both the relay module and connected devices.
  • Wide Application Range: Perfect for home automation, industrial control, robotics, and smart IoT solutions.

Hardware Components Used

  • 8-Channel Relay Module.
  • Esp32C3 Super Mini.
  • Flywheel.

Installation

  1. Download or clone this repository.
  2. Copy the I2CRelay, and related library folders to your Arduino libraries directory.
  3. Restart the Arduino IDE.

Files

The library is composed of two files, each with a specific role:

  1. I2CRelay.h

    • Defines the I2CRelay class, which extends the functionality to control relays over I2C.
  2. I2CRelay.cpp

    • Contains the implementation of methods for the I2CRelay class.

Versatility

The I2CRelay library offers broad versatility for automation through its configurable I2C addressing, expandable relay control, and cross-platform compatibility. User-friendly commands and customizable hardware pins simplify integration into diverse projects, from IoT and home automation to industrial control. Its efficient, non-blocking operation and persistent configuration via EEPROM ensure a scalable and reliable relay control system.


API Overview

Function Description Example Usage
I2CRelay(uint8_t sda, uint8_t scl) Constructor: set I2C SDA/SCL pins (optional, defaults to board pins) I2CRelay relay(8, 3);
void begin() Initialize the I2C bus relay.begin();
void scan(Stream &out = Serial) Scan and print all I2C devices on the bus relay.scan();
void setSlaveAddress(uint8_t oldAddr, uint8_t newAddr, Stream &out = Serial) Change the slaves I2C address relay.setSlaveAddress(0x08, 0x09);
void setSlaveName(uint8_t addr, const char name, Stream &out = Serial)* Change the slaves device name relay.setSlaveName(0x08, "MyRelay");
String requestSlaveInfo(uint8_t addr) Get info string from the slave String info = relay.requestSlaveInfo(0x08);
bool setRelay(uint8_t addr, uint8_t relayNum, uint8_t state) Set relay (18) ON/OFF (state: 1=ON, 0=OFF) relay.setRelay(0x08, 3, 1);
bool setAllRelays(uint8_t addr, uint8_t state) Set all relays ON/OFF (state: 1=ON, 0=OFF) relay.setAllRelays(0x08, 0);
bool setRelayTimer(uint8_t addr, uint8_t relayNum, uint32_t ms) Set relay (18) ON for given ms, then auto-OFF relay.setRelayTimer(0x08, 2, 2000);
bool setAllRelaysTimer(uint8_t addr, uint32_t ms) Set all relays ON for given ms, then auto-OFF relay.setAllRelaysTimer(0x08, 3000);

Parameter Notes

  • addr: I2C address of the slave (e.g. 0x08)
  • relayNum: Relay number 18
  • state: 1 = ON, 0 = OFF
  • ms: Duration in milliseconds
Description
No description provided
Readme MIT 160 KiB
2025-04-24 16:13:08 +03:00
Languages
C++ 100%