How can I start with getting accelerometer readings from LIS2DH sensor. Can I program it using python or C ?


You start by reading and understanding its datasheet.

If you examine the datasheet you will notice you can communicate with the device by I2C or SPI. If you buy the LIS2DH as part of a module the module itself may only support I2C or SPI.

I think I2C is usually slightly easier to use if you have a choice. SPI will generally allow for higher communication speeds though.

The Raspberry Pi supports both SPI and I2C.

Both SPI and I2C are usable from Python and C.

  • Thanks @joan . I'm struggling to start with it , is there are any guide on how to read data using SPI or I2c ? – musta Oct 4 '16 at 12:46
  • Google will find SPI/I2C tutorials. Or look through issues of the Magpi. Google the sensor and Raspberry Pi or the sensor and Arduino. – joan Oct 4 '16 at 12:49

you can check i2c sample codes. its really easy to use. here you can find the code for LIS3DHTR I2C code in python,java,c and much more.

LIS2DH and LIS3DHTR work in the same way and X,Y,Z register address are same for LIS2DH and LIS3DHTR, so its possible LIS3DHTR code will work for LIS2DH with minor changes. Still, its a good idea to check with the datasheet and make sure you are sending the correct data to read the sensors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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