ADXL345 Programming Notes

Active today
Viewed 20 times

I’m currently working on a rough VR system using the Raspberry Pi 3, and, of course, for that, I need a way to track the custom headset and controllers. I need the sensors to be compatible with Python 3, so that I can track them in 3D space.

Does anyone have any recommendations on any sensors like this?

 New contributor
  • I have been playing with ADXL345 and found it newbie friendly, comparing to MPU6050: (1) raspberrypi.stackexchange.com/questions/102041/…, (2) (2) raspberrypi.stackexchange.com/questions/105071/… (3) raspberrypi.stackexchange.com/questions/101095/… / to continue, … – tlfong01 5 hours ago
  • (4) raspberrypi.stackexchange.com/questions/74865/…. BTW. Rpi3B+ cannot change the flat I2C 100kHz rate. This is a problem because smBus cannot do Rpi3B+ cannot change the flat I2C 100kHz rate. This is a problem because smBus cannot do cycle stretching, and must lower I2C speed to 50k or even 10Bd. In other words, you might need to upgrade to Rpi4B to play with MPU6050/9260. That is the reason I follow MagPi 84 Page 45 recommendation on lowering the I2C speed. – tlfong01 5 hours ago
  • But then I found Bosch BNO055 even better, because there IMU staff is more open than Inversense. So my advice to newbie with a long plan, to try both MPU6050 and ADXL345 and make up your mind later. – tlfong01 5 hours ago
  • One more reason I prefer ADXL345 over MPU6050 is that ADXL345 is 3-DOF, while MPU6050 is 6-DOF. Actually both have a rather steep learning curve for newbies. I have a ADXL345 working testing program in python and happy to post it here for sharing, in case you are going into ADXL345. And another reason is that you can easily upgrade ADXL345 to industrial grade ADXL355, without changing software. – tlfong01 4 hours ago
  • More references here: (1) MPU6050 i2cdetect: imgur.com/gallery/6gNrOJe (2) MPU6050 forum posts (with schematic and tutorials): raspberrypi.org/forums/… (3) MPU6050 forum posts: raspberrypi.org/forums/… (4) MPU6050 forum posts:raspberrypi.org/forums/…. Happy sensing and cheers! 🙂 – tlfong01 4 hours ago
  • I have more mpu6050 (also MPU9250 which is not recommend to those faint of heart newbies) posts in other forums, including AAC (All About Circuits) projects (forum.allaboutcircuits.com/forums/the-projects-forum.6). I need to do some searching, in case you wish to have more references at the hardware circuit level. – tlfong01 4 hours ago
  • ADXL345 3-DOF Accelerometer is perhaps easier than 6-DOF MPU6050, the initial setup and testing is quite tedious. I have tested OK both the SPI and I2C and built up basic functions for future development. You may like to skim my programming record to get t feeling of the complexity. The penzu record actually includes basic API and I2C setup and testing record, useful for debugging. The ADXL345 related functions and output samples are HIGHLIGHTED IN BRIGHT RED, so you can just pay attention to those highlighted sections: penzu.com/p/926a24f6. Feel free to ask me any newbie questions. – tlfong01 53 secs ago   Edit

The MPU-6050 is a great choice.
enter image description here
To use it on Raspberry Pi 3, you need a python module. Follow instructions:

1. install the python-smbus package

sudo apt install python3-smbus

2. Install this package from PyPi repository

pip install mpu6050-raspberrypi  

If you find a problem, post an issue here.


Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

<span>%d</span> bloggers like this: