3
$\begingroup$

I'm new to embedded devices and am trying to understand how to use i2cget (or the entire I2C protocol really).

I'm using an accelerometer MMA8452, and the datasheet says the Slave Address is 0x1D (if my SAO=1, which I believe is referring to the I2C bus being on channel 1 on my raspberrypi v2).

From the command line, I enter

sudo i2cget -y 1 0X1d

It returns

0X00

I think that means I'm attached to the correct device.

So now, I'm trying to figure out how do I get actual data back from the accelerometer?

The i2c spec says

i2cget [-y] i2cbus chip-address [data-address [mode]]

So I have tried

sudo i2cget -y 1 0x1D 0x01

where 0x01 is the OUT_X_MSB. I'm not sure entirely what I'm expecting to get back, but I figured if I saw some data other than 0x00, I might be able to figure that out.

Am I using ic2get wrong? Is there a better way to learn and get data from i2c?

The datasheet for my accelerometer chip is at http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Accelerometers/MMA8452Q.pdf

$\endgroup$

1 Answer 1

2
$\begingroup$

the Slave Address is 0x1D (if my SAO=1, which I believe is referring to the I2C bus being on channel 1 on my raspberrypi v2)

SA0 is actually a pin on the chip (pin 7 by the datasheet). Changing it's value allows you to specify the address, helping to avoid address clashes. So it depends on how you've connected that pin in your circuit.

From the datasheet:

The MMA8452Q's standard slave address is a choice between the two sequential addresses 0011100 and 0011101. The selection is made by the high and low logic level of the SA0 (pin 7) input respectively

If you have SA0 already set to '1' then it's probably worth looking at the values from all the data registers: 0x01 to 0x06. If the device is outputting low values it's possible the MSBs will be 0.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.