#include <Wire.h>
#define Slave_address 0x68
#define No_of_sample 10
#define buffer_Size No_of_sample*6
uint8_t buff[buffer_Size];
uint32_t sample_count;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
Wire.begin();
Wire.setClock(200000);
uint32_t sample_count=0;
}
void loop() {
Wire.beginTransmission(Slave_address);
Wire.write(0x3B);
Wire.endTransmission();
Wire.requestFrom(Slave_address, 6); // Request 6 bytes from slave device number two
for(uint8_t x=0;x<6;x++) {
while(Wire.available()==0);
buff[sample_count*6+x]= Wire.read(); // Receive a byte as character
}
Serial.println("ok");
sample_count++;
if(Wire.available()){
Serial.println("I2C Error");
while(1);
}
if(sample_count==No_of_sample)
{
Serial.println("Complete");
for(uint8_t row=0;row<No_of_sample;row++){
for(uint8_t col=0; col<6; col++){
Serial.print(buff[row*6+col]);
Serial.print(",");
}
Serial.println(" ");
}
}
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}