MATLAB Matlab to r-pi to I2C device issue

  • Thread starter Thread starter jamie.j1989
  • Start date Start date
  • Tags Tags
    Device Matlab
Click For Summary
The discussion centers on using the HMC5883L I2C chip with a Raspberry Pi and MATLAB. The user successfully sets up the connection but encounters an issue with the I2C address. Instead of the expected default address '0x1E', the I2C scan returns '0x0D'. Despite verifying connections, changing the address in the MATLAB class to '0x0D' allows communication but results in an error indicating a mismatch in expected register values. Using the default address '0x1E' leads to an error stating no device is found. The conversation raises the question of whether the incorrect address suggests a faulty chip, while also noting the peculiarities of I2C addressing, particularly regarding the least significant bit that indicates read or write transactions.
jamie.j1989
Messages
76
Reaction score
0
I have a 3-Axis Digital Compass IC HMC5883L I2C chip, I just want to use it to learn how to talk to sensors via a Matlab to raspberry-pie to I2C chip link. The set up from Matlab to the pi is straight forward and simple, the issue I'm having seems to be the address I'm being returned when scanning the I2C bus line, I get an address of '0x0D' instead of the data sheets default of '0x1E'. There are two lines of code, the creation of the pi object 'rpi', and the function to scan the bus line is simply

rpi = raspi()
scanI2CBus(rpi, 'i2c-1' )

the argument 'i2c-1' tells the pi which bus line to scan, it is the only bus line available. Connections to the device are simple and have been checked and double checked, so I'm straight ruling that out. There is a built in MATLAB class for using this device with a pi, when I change the address it uses in this class to '0x0D' it clearly talks to the device but returns the error,

Error using hmc5883l/testDevice (line 246)
Error communicating with the HMC5883L sensor. The value read from ID_A, ID_B and ID_C registers do not match expected
values.

If I use the default address '0x1E' I get an error informing me that there is know device on the bus with that address.

Does an incorrectly returned address normally mean a faulty chip?
 
Physics news on Phys.org
Remember that I2C addressing is a bit strange. The LSB of the address indicates whether the transaction is a Read or a Write.
 
  • Like
Likes berkeman

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K