I am having a very odd problem getting the value of I2C registers on this sensor. I have used I2C many times before, and am sure that I am structuring the commands propperly. My issue is that when I try to get the value of a register, I instead get back the address of the register, rather than the data in the register.
Has anyone else encountered this problem? Any suggestions out there?
Wire.beginTransmission(0x0F); //start transmission to device
is wrong (you start another write but don't end it). And the "device" variable is not declared. If you use a variable to hold the device's address, use it in the "Wire.beginTransmission()" calls too.
Edit: In the current version of the IDE it's called "Wire.read()" and not "Wire.receive()".
Oops, that "device" variable should contain 0x0F. I've tried running the program with that line included and commented out, because I've seen I2C reads implemented in Arduino both ways. However neither work.
I was using Arduino 0022, I just tired in Arduino 1.0 however it produced the same results.
For some reason, when I try getting the data off of this register I do get the correct data, rather than the address. Any ideas why this would be the case?
We are also doing development in PIC, and in that environment I get exactly the data I am expecting, using the equivalent commands. This mystery is killing me!
You're trying to read the ID register. This has a default value but the datasheet also mentions that another ID may be configured. Maybe your device has a different ID set? Maybe they changed it to be the address of the device? Have you tried other registers? Does only the one I've chosen return correct (other than the address) values?
Thanks for the reply. I understand what you are saying, however other registers such as the CTRL_REG1 returns 11011 (the address) instead of 0 (the reset value). Also, on the PIC microcontroller I do get the device ID that I am expecting.
Do you have external pull-ups applied? The internal work in many cases but often they are too high to let the signal reach correct levels. See this page for details: