Configuration Parameter |
Selectable Option/Value |
Description |
Mode |
Normal -- Continuous |
Normal: Initialize & Deinitialize I2C driver every time a I2C block is used. Continuous: The I2C driver will be initialized only once |
I2C driver port |
0--1 |
Select driver port |
Clock Frequency (kHz) |
100--400 |
Specify clock speed of selected I2C module configuration. |
SDA pin |
|
Select pin for I2C SDA, The available list of pins will be adjusted according to the target family selected in the Target Setup Block |
SDA internal pullup |
|
Enable/disable internal pullup |
SCL pin |
|
Select pin for I2C SCL, The available list of pins will be adjusted according to the target family selected in the Target Setup Block |
SCL internal pullup |
|
Enable/disable internal pullup |
Bytes write count |
|
Specify number of bytes to write to I2C in a transaction. |
Bytes read count |
|
Specify number of bytes to read from I2C in a transaction. |
Enable I2C scan device ESP log message. |
|
Enable this to scan all i2c devices connected and display their slave addresses. To use this, feature a serial monitor is required. |
Sample time (sec) |
-1 (inherited) or specify |
Specify sample time for the block |
Transaction mode
Bytes write count |
Bytes read count |
Transaction mode |
0 |
0 |
Write transaction without any data bytes |
0 |
>0 |
Read transaction |
>0 |
0 |
Write transaction with data bytes |
>0 |
>0 |
Write transaction, then read transaction |
Port Name |
Port Type |
Date Type |
Description |
Slave address |
Vector |
uint8 |
Slave device address |
Wr(i) (uint8) |
Scalar |
uint8 |
Bytes that need to be sent to the above specific slave address |
Status |
Scalar |
uint8 |
Read or Write byte status. If error = -1 or Ok = 0 |
Rd (uint8)(i) |
Scalar |
uint8 |
Bytes that need to be read by the above specific slave address |
This block can be used to communicate with a device using I2C protocol
Target module Demo file : esp32_i2c_4_20mA_demo.slx
Subsystem ADS1115
I2C blocks used to read values from aMG ESP32 4-20mA Module
This demo shows how to use the I2C master block to get the reading from the external I2C ADC module and read the data from CMD console in every 1s.
1.aMG ESP32 4-20mA Module
Once the model is uploaded to the ESP32. It should start the data reading from the ESP32 as shown below.
Note:
Serial Monitor used: Docklight
Baud Rate: 115200