Datasheet
or LIS3DH_RANGE_16_G
When reading the range back from the sensor, 0 is ±2g, 1 is ±4g, 2 is ±8g and 3 is ±16g range
Raw data readings
You can get these raw readings by calling lis.read() which will take a snapshot at that moment in time. You can then
grab the x, y and z data by reading the signed 16-bit values from lis.x , lis.y and lis.z . When you are done with that
data, call read() again to get another snapshot.
Normalized readings
If you dont want to noodle around with range readings and scalings, you can use Adafruit_Sensor to do the
normalization for you. Its a nice way to have consistant readings betwixt multiple types of accelerometers.
Adafruit_Sensor uses event ( sensors_event_t ) objects to 'snapshot' the data:
Once you've getEvent 'd the data, read it out from the event object with event.acceleration.x , event.acceleration.y &
event.acceleration.z
The key point is that those values are floating point, and are going to be in m/s No matter the range!
It's up to you whether you want the raw numbers or normalized data - there's times you want to keep it simple and
avoid floating point numbers, and other times you may want to avoid doing the math for force conversion.
Tap & Double tap detection
One of the neat extras in the LIS3DH is tap & double-tap detection. By tapping the accelerometer or the PCB or
something the PCB is attached to you can create a type of interface.
Open up the tapdemo demo to run it! It defaults to I2C so change to SPI if you're using that interface.
/* Get a new sensor event */
sensors_event_t event;
lis.getEvent(&event);
2
© Adafruit Industries https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout Page 17 of 22










