The Adafruit ADXL343 is a small, thin, low-power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit two's complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. The ADXL343 is well-suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (3.9 mg/LSB) enables the measurement of inclination changes less than 1.0°.
Common applications of the ADXL343 include:
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Power supply (2.0V to 3.6V) |
3 | SCL | Serial Clock Line for I2C interface |
4 | SDA | Serial Data Line for I2C interface |
5 | CS | Chip Select for SPI interface (active low) |
6 | SDO | Serial Data Output for SPI interface (MISO) |
7 | SDA | Serial Data Input for SPI interface (MOSI) |
8 | SCL | Serial Clock for SPI interface |
To use the ADXL343 in a circuit:
Below is an example code snippet for interfacing the ADXL343 with an Arduino UNO using the I2C communication protocol. This code initializes the sensor and reads the acceleration data.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL343.h>
// Assign a unique ID to the sensor
Adafruit_ADXL343 accel = Adafruit_ADXL343(12345);
void setup() {
Serial.begin(9600);
if (!accel.begin()) {
Serial.println("Ooops, no ADXL343 detected ... Check your wiring!");
while (1);
}
}
void loop() {
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */
Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");
Serial.println("m/s^2 ");
// Delay before the next reading
delay(500);
}
Ensure that you have installed the necessary libraries (Adafruit_Sensor
and Adafruit_ADXL343
) before uploading this code to your Arduino UNO.
accel.begin()
function to check if the sensor is properly connected.Q: Can the ADXL343 be used with a 5V microcontroller? A: Yes, but ensure that the VCC is within the specified range and use level shifters for I2C or SPI lines if necessary.
Q: How can I change the range of the sensor?
A: Use the setRange()
function provided by the Adafruit ADXL343 library to set the desired range.
Q: What is the maximum sampling rate of the ADXL343? A: The ADXL343 can sample up to 3200 Hz, but the actual maximum rate depends on the communication protocol and microcontroller speed.
For further assistance, consult the datasheet of the ADXL343 and the Adafruit ADXL343 library documentation.