I am a beginner with Arduino.
I am trying to write and read i2c using an ESP32 board.
i2c writing has been done.
But I couldn't read the register.
I want 0x0A to be called at registor address 0x09.
The source code is as below.
The logic analyzer results are as follows.
#include <Wire.h>
byte ADDRESS_SLAVE = 0X3B;
byte REGISTER_XY = 0X09;
byte READ_LENGTH = 1;
void setup()
{
Wire.begin();
Wire.setClock(100000); // set I2C 'full-speed'
Serial.begin(115200);
}
void loop()
{
Wire.beginTransmission(0X3B);
Wire.write(0X09); // set register for write
Wire.write(0X0A); // set register for write
Wire.endTransmission(); // false to not release the line
Wire.beginTransmission(0X3B); // Begin communication with slave address (0X3B)
Wire.write(0X09); // set register for read
Wire.endTransmission(false); // Send the restart condition
Wire.requestFrom(0X3B, 1); // Perform read request from slave address 0X3B and read 1 byte from the register that it is pointed at (0X09)
byte READ = Wire.read(); // Read the byte that was received
delay(1000);
}