Matlab to r-pi to I2C device issue

  • Context: MATLAB 
  • Thread starter Thread starter jamie.j1989
  • Start date Start date
  • Tags Tags
    Device Matlab
Click For Summary
SUMMARY

The discussion centers on interfacing a 3-Axis Digital Compass IC HMC5883L with a Raspberry Pi using MATLAB via I2C communication. The user encounters an issue where the I2C address returned is '0x0D' instead of the expected '0x1E', leading to communication errors with the sensor. The user confirms that the connections are correct and utilizes the MATLAB built-in class for the HMC5883L, but still faces errors when attempting to read from the device. The discussion suggests that an incorrectly returned address may indicate a faulty chip or misconfiguration in the I2C setup.

PREREQUISITES
  • Familiarity with MATLAB programming and its syntax.
  • Understanding of Raspberry Pi hardware and I2C communication protocols.
  • Knowledge of the HMC5883L sensor specifications and data sheet.
  • Experience with troubleshooting I2C device connections and addressing.
NEXT STEPS
  • Investigate the wiring and connections for the HMC5883L to ensure proper setup.
  • Learn about I2C addressing and how to interpret the least significant bit (LSB) for read/write operations.
  • Explore MATLAB's built-in functions for I2C communication with Raspberry Pi.
  • Research common issues and solutions related to the HMC5883L sensor communication errors.
USEFUL FOR

This discussion is beneficial for hardware developers, robotics enthusiasts, and anyone working with Raspberry Pi and I2C sensors, particularly those using MATLAB for sensor integration.

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   Reactions: berkeman

Similar threads

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