I have followed a tutorial to create a tilt compensated compass using the HMC5883L compass and the ADXL345 accelerometer.
Both are stored as variables.
Is it possible to define them as a complete unit?
ie if I was using the following in my code
#define compassAddress 0x32 >> 1
How do i go about assigning both components a single address to reference from that address.
Excuse the terminology, it may be incorrect. I did a lot of googling trying to find an answer but realised I dont even know how to ask the question
Hopefully it will make sense to someone
With the ALT ADDRESS pin high, the 7-bit I2C address for the device is 0x1D, followed by the R/W bit.
This translates to 0x3A for a write and 0x3B for a read.
An alternate I2C address of 0x53 (followed by the R/W bit) can be chosen by grounding the ALT ADDRESS pin (Pin 12).
This translates to 0xA6 for a write and 0xA7 for a read.
So you've two different addresses, with wholly different data coming from each part.
3A/3B you get one's part info, 3C/3D you get the other.
Talk to both using normal library kind of calls.
No1Daemon:
I have followed a tutorial to create a tilt compensated compass using the HMC5883L compass and the ADXL345 accelerometer.
Both are stored as variables.
Is it possible to define them as a complete unit?
How do i go about assigning both components a single address to reference from that address.
I'm trying to guess why you're trying to do this, and I couldn't think of a reason. If you want to represent both devices as a single conceptual thing in your code, you could define a class to encapsulate them both. Or if classes aren't your thing you could just define a struct to contain the two addresses, and another struct to contain both sets of results, and a function to read the results from the devices.
At the end of the day all it does is the HMC outputs a bearing and then the ADXL corrects it for tilt and outputs a tilt compensated bearing.
All I require is to get the tilt compensated bearing with one call basicaly.
Suspected it would be hard to see wy I needed this, especially if you are experiences with code as I am not.