Library to interface H3LIS331DL accelerometer.

Dependents:   H3LIS331DL_Demo H3LIS331DL_AdjVal

3-axis Digital Accelerometer H3LIS331DL library

This library interfaces this grove sensor and was tested so far in a LPC1768, but it should work with all mbed platforms supporting I2C API.

The main difference from the original library is that the constructor takes two pins for SDA and SCL.

Basic example

#include "mbed.h"
#include "H3LIS331DL.h"

H3LIS331DL h3lis(p28, p27);
Serial pc(USBTX, USBRX); // tx, rx
C12832 lcd(p5, p7, p6, p8, p11);

int main() {
    h3lis.init();

    while(1) {
        double accel[3] = {0.0, 0.0, 0.0};
        
        h3lis.getAcceleration(accel);
        pc.printf("X %1.3f    Y %1.3f    Z %1.3f\n", accel[0], accel[1], accel[2]);
        wait_ms(100);
    }
}

Example applications

Find the two applications from Seeed Studio ported into mbed:

License

The MIT License (MIT)

Copyright (c) 2013 Seeed Technology Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

/media/uploads/spastor/grove_3axis_accelerometer400g.jpg

Revision graph

The revision graph only works with JavaScript-enabled browsers.