I2C Slave Nodes
The i2c slave library allow users to create i2c slave.
Config Nodes
i2c config
Handles settings for communication using I2C.
Inputs
- I2C Port : Selects which I2C hardware port to use — I2C0 or I2C1. This depends on your hardware setup and which pins are connected to your peripherals.
- SDA Pin : Specify the SDA pin for communication
- SCL Pin : Specify the SCL pin for communication
- Slave Address : The unique 7-bit or 10-bit address assigned to an I2C slave device for identification during communication.
- Address Mode : Specifies the format of the slave address in I2C communication, either 7-bit or 10-bit addressing.
- SDA Pullup Enable : Activate the pull-up resistor on the SDA (data) line
- SCL Pullup Enable : Activate the pull-up resistor on the SCL (clock) line
Proc Nodes
i2c slave transfer
<b>Enable the ESP32 to send or receive data as an I2C slave. This node handles bidirectional communication with an I2C master, allowing the ESP32 to respond to requests or transmit data when asked.</b><br>1️ ESP32 as a Sensor Module<br>Set the ESP32 as a slave device, responding to a Raspberry Pi master requesting temperature readings or other sensor data.<br>2️ ESP32 as a Configuration Receiver<br>Accept configuration bytes sent from a master controller to update settings on the ESP32, like WiFi credentials or control parameters.<br>3️ ESP32 as a Data Logger<br>Receive data from an external master device, and store the data for later processing — ideal for distributed sensor setups.
Inputs
- I2C port : Selects which I2C hardware port to use — I2C0 or I2C1. This depends on your hardware setup and which pins are connected to your peripherals.
- Read / Write : <br>Read: Pulls data from the device — useful for sensors or data logs.<br>Write: Sends data to the device — like sending commands or configurations.
- Data : Define the data payload to send (for write operations) or prepare an empty buffer (for read operations). The data type can vary depending on whether the node is in read or write mode.
- Recieve length : Define the number of bytes the master expects to receive from the slave during an I2C read operation.
Outputs
- data : Define the data payload to send (for write operations) or prepare an empty buffer (for read operations). The data type can vary depending on whether the node is in read or write mode.
i2c slave write
<b>Respond to an I2C master by sending data from the ESP32 acting as a slave device. This node prepares the ESP32 to deliver data whenever the master requests it.</b><br>1️ ESP32 as a Sensor Node<br>Send temperature or humidity data from the ESP32 to a Raspberry Pi master when it polls for new readings.<br>2️ ESP32 as a Status Reporter<br>Respond with a custom status message — like READY or ERROR — when the master checks the ESP32’s state.<br>3️ ESP32 as a Smart Peripheral<br>Provide dynamic data (e.g., light intensity from a connected LDR) to a master controller on demand, simplifying sensor integration.
Inputs
- I2C port : Selects which I2C hardware port to use — I2C0 or I2C1. This depends on your hardware setup and which pins are connected to your peripherals.
- Write Data : Provide the data to send as a 16-bit unsigned integer (uint16) — supporting values from 0 to 65535. This is useful for devices expecting register data in two bytes (e.g., motor controllers or configuration registers).
- Size : Define how many bytes to write as an 8-bit unsigned integer (uint8) — supporting values from 0 to 255 bytes.
- Ticks to wait : Set the maximum time to wait for the write to complete, preventing timeout errors on slower devices or a busy I2C bus.
Outputs
- Bytes written : Provide the data to send as a 16-bit unsigned integer (uint16) — supporting values from 0 to 65535. This is useful for devices expecting register data in two bytes (e.g., motor controllers or configuration registers).
i2c slave read
<b>Listen for data sent by an I2C master, allowing the ESP32 to receive and process incoming information while acting as a slave device.</b><br>1️ ESP32 as a Configuration Receiver<br>Receive WiFi credentials or other settings from a master device, allowing the ESP32 to reconfigure itself dynamically.<br>2️ ESP32 as a Command Receiver<br>Listen for control commands — like START or STOP — from another ESP32 Device, triggering actions on the ESP32.<br>3️ ESP32 as a Data Logger<br>Collect incoming data (e.g., sensor readings from another device) for local storage or processing, enabling distributed logging setups.
Inputs
- I2C port : Selects which I2C hardware port to use — I2C0 or I2C1. This depends on your hardware setup and which pins are connected to your peripherals.
- Read Data : Retrieve data from an I2C slave device to the I2C master.
- Size : Define how many bytes to write as an 8-bit unsigned integer (uint8) — supporting values from 0 to 255 bytes.
- Ticks to wait : Set the maximum time to wait for the write to complete, preventing timeout errors on slower devices or a busy I2C bus.
Outputs
- Bytes read : Define how many bytes to retrieve from the I2C device in a single transaction. This is typically determined by the device’s datasheet — common values include 1 byte for status checks, 2 bytes for sensor data (e.g., temperature readings), or multiple bytes for larger datasets (e.g., EEPROM memory).