Hi guys,
I am reading the H3lis100dl sensor (www.st.com/resource/en/datasheet/h3lis100dl.pdf). Here is the code I am using:
for(int i = 0; i < 6; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write((40+i));
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(Addr, 1);
// Read 6 bytes of data
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
if(Wire.available() == 1)
{
data[i] = Wire.read();
}
}
This is how I read the 6 byte data containing the LSB and MSB of each axis. Here I have to start, send the register add, read and end and this has to be done six times.
But what I want is to start the communication, send the register address and wait until I have read all the 6 bytes and then end the communication. From what I have read from the datasheet at page 19/38 it seems possible. But it would be great if someone could help with visualization of the code.
Here is my attempt at it. I have made the 7th bit high and thus the address becomes 104.
Wire.beginTransmission(Addr);
// Select data register
Wire.write(104);
// Request 6 byte of data
Wire.requestFrom(Addr, 6);
// Read 6 bytes of data
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
if(Wire.available() == 1)
{
//data[i] = Wire.read(); // Not sure how to do the read for 6 bytes
}
Wire.endTransmission();