Matlab to r-pi to I2C device issue

In summary, the conversation revolves around using a 3-Axis Digital Compass IC HMC5883L I2C chip with Matlab and a Raspberry Pi. The issue at hand is that the I2C bus line is returning an incorrect address of '0x0D' instead of the expected '0x1E'. The code used to create the pi object and scan the bus line is simple, and the connections to the device have been checked and ruled out as the problem. The conversation also mentions a built-in MATLAB class for using the device with a pi, which returns an error when the address is changed to '0x0D'. It is speculated that the returned address may indicate a faulty chip, but it is also noted
  • #1
jamie.j1989
79
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
  • #2
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

Related to Matlab to r-pi to I2C device issue

1. What is Matlab?

Matlab is a high-level programming language and interactive environment commonly used in the field of science and engineering. It is often used for data analysis, visualization, and numerical computation.

2. What is an r-pi?

An r-pi, or Raspberry Pi, is a small, affordable, and versatile computer that can be used for a variety of projects, including as a platform for running Matlab code.

3. What is an I2C device?

I2C, or Inter-Integrated Circuit, is a communication protocol used for connecting electronic devices to a microcontroller or other central processing unit. An I2C device is any device that uses this protocol for communication.

4. What is the issue with using Matlab to communicate with an I2C device through r-pi?

The issue may arise due to compatibility issues between the Matlab code and the r-pi's operating system. Additionally, there may be problems with configuring the I2C communication on the r-pi.

5. How can I resolve the issue of communicating with an I2C device using Matlab and r-pi?

To resolve the issue, you can try troubleshooting the compatibility issues by checking for updates or using alternative communication methods. You can also refer to the r-pi's documentation for guidance on configuring I2C communication. Additionally, seeking help from online forums or consulting with experts may also be helpful.

Similar threads

  • Electrical Engineering
Replies
2
Views
2K
  • Computing and Technology
Replies
4
Views
3K
Back
Top