Reference
ADXL345
3-axis accelerometer (found on the GY-85 9-DoF board).
- Connects over
- I²C
- Address
- 0x53 (or 0x1D)
- Made by
- Analog Devices
- Datasheet
- analog.com
Use it
hardware {
device adxl345: ADXL345
}
every 1s {
let value: float = adxl345.x()
log("adxl345", "x={value}")
}
On its own, the declaration puts the ADXL345 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x53. To choose the pins or the address, declare the bus and attach the device: device adxl345: ADXL345 on i2c0 at 0x1D with i2c i2c0(sda: 21, scl: 22).
Methods
-
adxl345.x() -> float
X acceleration in g
-
adxl345.y() -> float
Y acceleration in g
-
adxl345.z() -> float
Z acceleration in g
-
adxl345.magnitude() -> float
Vector magnitude in g (1.0 at rest)
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V or 5V on GY-85 |
GND | Ground |
SDA | GPIO21 on ESP32 |
SCL | GPIO22 on ESP32 |
Specifications
- Voltage
- 3.3V (GY-85 has an onboard regulator, 3.3-5V ok)
- Range
- ±2g (full resolution, 3.9 mg/LSB)
- Sample rate
- 100 Hz
Tips
- On the GY-85 this shares the bus with ITG3205 (0x68) and HMC5883L (0x1E) — declare all three on the same bus.
- Address 0x1D if SDO is pulled high (bare chip); GY-85 fixes it at 0x53.
Alternatives worth knowing:
- MPU6050: Accel + gyro in one chip.