(Reference) Accelerometer ADXL345
Accelerometer ADXL345

Wiring
| Sensor | Photon 2 | Function |
|---|---|---|
| GND | GND | Ground |
| VCC | 3V3 | Power (requires 3.3v) |
| CS | 3V3 | Power (requires 3.3v) |
| SDO | GND | Ground |
| SDA | SDA | I2C data (no resistors needed) |
| SCL | SCL | I2C clock (no resistors needed) |
| INT1 | Any GPIO Pin | Optional (if using interrupts) |
| INT2 | Any GPIO Pin | Optional (if using interrupts) |
Wiring Diagram

Operation
ADXL345_Sparkfun_Particle Library
- Initialize accelerometer object
ADXL345 adxl; //accelerometer object
void setup() {
accel.powerOn(); // Power on the ADXL345
- There are other additional settings to configure tap, etc.
- These can be found in the example files in the library
Library Operations
-
Recommended library for Photon 2
ADXL345_Sparkfun_Particle
-
Check for vibrations
accel.readTap()greater than 0 is a vibration
-
Measure acceleration
accel.cxint value for force of gravity in the X direction-
accel.cyint value for force of gravity in the Y direction accel.czint value for force of gravity in the Z direction
Credit
- Sparkfun
- Sensor Datasheet
- Accelerometers, Gyros, IMUs
- Diagrams created with Frizting