Hi Guys,
I am trying to read some registers using I2C but for some odd reason I am not getting any values returned. I am using Atmega328 (Arduino) to read the values.
data sheet of sensor is given on below link.
https://www.first-sensor.com/cms/upload/datasheets/DS_Standard-LMI_E_11823.pdf
I can run the I2c scanner and read the sensor address '5C' successfully, which is a valid address according to the data sheet. Which gives me confidence that my connections are correct. My code to read the values is given below.
#include <Wire.h>
int X0,X1;
void setup(void) {
Serial.begin(9600); // Initialize the serial port.
Wire.begin();
}
void loop(void) {
Wire.beginTransmission(0x5C);
Wire.write(0xB8);
Wire.write(0x20);
Serial.println( Wire.endTransmission());
Wire.beginTransmission(0x5C);
Wire.requestFrom(0xB9, 2);
if(Wire.available()) {
X0 = Wire.read();
X1 = Wire.read();
}
Serial.print("X0= ");
Serial.print(X0);
Serial.print(" X1= ");
Serial.println(X1);
delay(500);
}
I am trying to read some registers using I2C but for some odd reason I am not getting any values returned. I am using Atmega328 (Arduino) to read the values.
data sheet of sensor is given on below link.
https://www.first-sensor.com/cms/upload/datasheets/DS_Standard-LMI_E_11823.pdf
I can run the I2c scanner and read the sensor address '5C' successfully, which is a valid address according to the data sheet. Which gives me confidence that my connections are correct. My code to read the values is given below.
#include <Wire.h>
int X0,X1;
void setup(void) {
Serial.begin(9600); // Initialize the serial port.
Wire.begin();
}
void loop(void) {
Wire.beginTransmission(0x5C);
Wire.write(0xB8);
Wire.write(0x20);
Serial.println( Wire.endTransmission());
Wire.beginTransmission(0x5C);
Wire.requestFrom(0xB9, 2);
if(Wire.available()) {
X0 = Wire.read();
X1 = Wire.read();
}
Serial.print("X0= ");
Serial.print(X0);
Serial.print(" X1= ");
Serial.println(X1);
delay(500);
}