Hey Guys,.
Im pretty new still to all this. So please excuse me if there is something obvious.
So here is my question, I have been struggling with the included datasheet for an magnetoscope.
For some reason it seam like everything is working but, when i wave a magnet at it, Im not really getting the real response in the serial console.
So here is some information.
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
int reading = 0;
int Address = 30;
Wire.beginTransmission(Address);
Wire.write(byte(0x03));
Wire.write(byte(0x04));
Wire.endTransmission();
Wire.requestFrom(Address, 2);
delay(10);
if (2 <= Wire.available()) {
reading = Wire.read();
reading = reading << 8;
reading |= Wire.read();
Serial.println(int(reading));
}
delay(250);
}
with this response I get in the serial console
-5637
-5637
-5637
-5637
-5637
But then if I remove the following line "Wire.write(byte(0x03));" My output does not change.
Value from device are supposed to be expressed as two's complement.
So at first I tought it was me that didnt know how to send multple bytes to the device, but after some research i found that i was doing it right ( i think )
Then if I only put "Wire.write(byte(0x03));" I receive "0" as response.
Reading the Datasheet I see that response 0 mean that the command was invalid.
I included the datasheet to this post.
Can someone point me in the right dirrection?
The IC im using is LSM303DLHC and im using it from this "sheild"
Here is the datasheet
the following picture is a picture of the comunication of the bus. If it helps anyway helping me