Hi,
I am trying to build a wheeled robot which will stop when it bumps into something. I thought the Adafruit ADXL345 QT would do the trick and I have installed it on both a pi zero and pi 5.
In both cases, I cannot get the tap detection to work. The device appears to be wired correctly. I get no error messages when running the code below, and motion is detected correctly, but no matter what settings I use for the tap detection, I very rarely get a 'true' detected message.
Here is the code I use, with the recommended settings. I have tried all kinds of numbers for the threshold and duration, to no avail.
Can anyone recommend some settings, please?
Thanks,
CJ
I am trying to build a wheeled robot which will stop when it bumps into something. I thought the Adafruit ADXL345 QT would do the trick and I have installed it on both a pi zero and pi 5.
In both cases, I cannot get the tap detection to work. The device appears to be wired correctly. I get no error messages when running the code below, and motion is detected correctly, but no matter what settings I use for the tap detection, I very rarely get a 'true' detected message.
Here is the code I use, with the recommended settings. I have tried all kinds of numbers for the threshold and duration, to no avail.
Can anyone recommend some settings, please?
Thanks,
CJ
Code:
import timeimport boardimport busioimport adafruit_adxl34xi2c = busio.I2C(board.SCL, board.SDA)accelerometer = adafruit_adxl34x.ADXL345(i2c)accelerometer.enable_freefall_detection(threshold=10, time=25)accelerometer.enable_motion_detection(threshold=18)accelerometer.enable_tap_detection(tap_count=1, threshold=20, duration=50, latency=20, window=255)while True: print("%f %f %f"%accelerometer.acceleration) print("Dropped: %s"%accelerometer.events["freefall"]) print("Tapped: %s"%accelerometer.events['tap']) print("Motion detected: %s"%accelerometer.events['motion']) time.sleep(0.5)
Statistics: Posted by Candyjet — Wed Jan 24, 2024 3:18 pm