3

I've two identical GY-291 / ADXL345 sensors. To read the data I use the python-module (https://pypi.org/project/adxl345/). i2cdetect detects the sensors at address x53 correctly.

Unfortunately, data for all axis are way off. z stays always constant at 20 m/s^2 and x and y are measuring pitch and roll correspondingly but are way off. For example, if I place the sensor horizontally on the table the x = -5, y = -11, and z = -20 for one sensor and x = -10, y = -11, and z = -20 for the other one.

I've tried the libraries from Pimoroni and Adafruit but to no avail.

I've checked the code on the chips and it reads 345B **** **** PHIL. So, I guess it should be an Analog Devices ADXL345.

Q Any ideas to get the sensors on track?

Edit

Say for sensor A:

  1. z-axis aligned vertically, static

    • x-axis = -5 m/s^2 (offset by 5 m/s^2)
    • y-axis = -11 m/s^2 (offset by 11 m/s^2)
    • z-axis = -20 m/s^2
  2. x-axis vertically, static

    • x-axis = -15 m/s^2
    • y-axis = -11 m/s^2
    • z-axis = -20 m/s^2
  3. y-axis aligned vertically, static

    • x-axis = -5 m/s^2
    • y-axis = -20 m/s^2
    • z-axis = -20 m/s^2

Even when accelerating or decelerating, the sensor's z-axis reads constantly 20 m/s^2.

Edit 1

  • black is connected to rPi's ground
  • red is connected to rPi's 3V3 pin
  • SCL and SDA are connected to the rPi accordingly
  • the chip reads 345B #029 4218 PHIL

adxl345

Edit 2

Results for http://abyz.me.uk/rpi/pigpio/code/i2c_ADXL345_py.zip

           x    y    z
z-up:    -127 -282 1299
z-down:  -110 -264  762
y-up:    -125   43 1017
y-down:  -128 -594 1043
x-up:     201 -277 1029
x-down:  -448 -278 1034
14
  • You have provided no evidence that anything is wrong. As a minimum you will have to provide readings for different orthogonal orientations so we can determine the units.
    – joan
    Commented May 3, 2019 at 8:02
  • @joan I've added readings for 3 different orientations and the units. Commented May 3, 2019 at 8:23
  • I would try different software and also confirm you only have one wired to the I2C bus at any one time. I think the time has come for clear photos of the connections.
    – joan
    Commented May 3, 2019 at 10:05
  • @joan I'm using only one sensor at address x53 at the time and both of the sensors show the weird behavior at the time. Also, employing alternative libs e.g. Pimoroni's and Adafruit's lib for ADXL345 show similar results. There is only a difference in scaling. Commented May 3, 2019 at 10:15
  • Need clear photos.
    – joan
    Commented May 3, 2019 at 10:28

1 Answer 1

3

I would connect SDO to ground. This ensures the ADXL345's I2C address is 0x53. If you connect SDO to 3V3 the address will be 0x54. It may float between the two if not explicitly set to ground or 3V3.

I would connect CS to 3V3. This ensures the ADXL345 is in I2C mode. If it is ever low the ADXL345 will enter SPI mode.

Other than that I am out of ideas apart from try my Python ADXL345 script. All the script does is initialise the ADXL345 and then return the raw X, Y, Z readings.

Needs sudo pigpiod to start the pigpio daemon before you run it.

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.