The SparkFun LIS3DH Breakout is a versatile and powerful accelerometer breakout board that features the LIS3DH sensor. This sensor is a three-axis accelerometer that provides high-resolution measurement at up to ±16g. It is designed for low-power consumption and operates on a supply voltage from 1.71V to 3.6V, making it ideal for battery-powered applications. The LIS3DH is commonly used in mobile devices, gaming controllers, motion detection systems, and various other applications where motion or inclination sensing is required.
Pin Number | Pin Name | Description |
---|---|---|
1 | GND | Ground connection for power and logic |
2 | VCC | Supply voltage (1.71V to 3.6V) |
3 | SCL/SPC | I2C Serial Clock / SPI Serial Clock |
4 | SDA/SDI | I2C Serial Data / SPI Serial Data In |
5 | SDO | SPI Serial Data Out / I2C Address Selection |
6 | CS | SPI Chip Select (active low) |
7 | INT1 | Interrupt 1 output (configurable) |
8 | INT2 | Interrupt 2 output (configurable) |
Powering the Device: Connect the VCC pin to a power supply within the range of 1.71V to 3.6V. Connect the GND pin to the ground of your power supply.
Selecting the Interface: Choose between I2C or SPI for communication. For I2C, use the SCL and SDA pins. For SPI, use the SPC, SDI, SDO, and CS pins.
Setting Up Interrupts (Optional): The INT1 and INT2 pins can be configured to output interrupts based on certain conditions detected by the accelerometer. Connect these to microcontroller interrupt pins if required.
Mounting: Ensure the breakout board is securely mounted to prevent noise and inaccuracies in the readings.
#include <Wire.h>
#include <SparkFunLIS3DH.h>
#include <SPI.h>
LIS3DH myIMU; // Default constructor is I2C, addr 0x19.
void setup() {
Serial.begin(9600);
Wire.begin();
if (myIMU.begin() != 0) {
Serial.println("Problem starting the sensor at 0x19.");
} else {
Serial.println("Sensor at 0x19 started.");
}
}
void loop() {
myIMU.readAccel(); // Read the accelerometer values and store them.
// Print out the values.
Serial.print("X: ");
Serial.print(myIMU.x);
Serial.print(" Y: ");
Serial.print(myIMU.y);
Serial.print(" Z: ");
Serial.println(myIMU.z);
delay(100); // Delay for readability.
}
Q: Can the LIS3DH operate in both I2C and SPI simultaneously? A: No, the LIS3DH can operate in either I2C or SPI mode, but not both at the same time.
Q: How do I change the I2C address of the LIS3DH? A: The I2C address can be changed by connecting the SDO pin to either VCC or GND.
Q: What is the purpose of the INT1 and INT2 pins? A: These pins can be configured to output interrupts for events like data ready, free fall detection, or threshold exceedance.
Q: How do I set the acceleration range? A: The acceleration range can be set through the sensor's registers, which can be accessed via I2C or SPI commands.
Q: Can this sensor detect orientation? A: Yes, by comparing the acceleration on different axes, you can determine the orientation of the sensor relative to the ground.