Giter Club home page Giter Club logo

seeed_arduino_lis3dhtr's Introduction

Seeed_Arduino_LIS3DHTR Build Status

Introduction

An Arduino library for 3-Axis Digital Accelerometer ±2g to 16g (LIS3DHTR).Acceleration data can be obtained using IIC interface and SPI interface.

How to install Arduino Library

please refer here.

Usage

// This example use I2C.
#include "LIS3DHTR.h"
#include <Wire.h>
LIS3DHTR<TwoWire> LIS; //IIC
#define WIRE Wire

void setup()
{
  Serial.begin(115200);
  while (!Serial)
  {
  };
  LIS.begin(WIRE, LIS3DHTR_ADDRESS_UPDATED); //IIC init
  delay(100);
  LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);

}
void loop()
{
  if (!LIS)
  {
    Serial.println("LIS3DHTR didn't connect.");
    while (1)
      ;
    return;
  }
  //3 axis
   Serial.print("x:"); Serial.print(LIS.getAccelerationX()); Serial.print("  ");
   Serial.print("y:"); Serial.print(LIS.getAccelerationY()); Serial.print("  ");
   Serial.print("z:"); Serial.println(LIS.getAccelerationZ());

}

API Reference

  • begin(comm<TwoWire>, address<uint8_t>=0x18) : void
// Init device by IIC
LIS3DHTR<TwoWire> LIS; //IIC
LIS.begin(Wire, 0x19)
  • begin(comm<SPIClass>, sspin<uint8_t>=SS) : void
// Init device by SPI
LIS3DHTR<SPIClass> LIS; //SPI
LIS.begin(SPI, 10); //SPI SS/CS
  • setPoweMode(mode<power_type_t>) : void
// Set power mode
LIS.setPoweMode(POWER_MODE_NORMAL); // Normal mode
LIS.setPoweMode(POWER_MODE_LOW); // Low power mode
  • setFullScaleRange(range<scale_type_t>) : void
// Set Full scale
LIS.setFullScaleRange(LIS3DHTR_RANGE_2G); // 2G
LIS.setFullScaleRange(LIS3DHTR_RANGE_4G); // 4G
LIS.setFullScaleRange(LIS3DHTR_RANGE_8G); // 8G
LIS.setFullScaleRange(LIS3DHTR_RANGE_16G); // 16G
  • setOutputDataRate(odr<odr_type_t>) : void
// Set output data rate
LIS.setOutputDataRate(LIS3DHTR_DATARATE_POWERDOWN); // Power down
LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ); // 1HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ); // 10HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ); // 25HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ); // 50HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ); // 100HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ); // 200HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_400HZ); // 400HZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KH); // 1.6kHZ
LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ); // 5KHZ
  • available(void) : bool
// if new data
if(LIS.available){
  float x = LIS.getAccelerationX();
}
  • getAcceleration(x<float *>, y<float *>, z<float *>) : void
// get acceleration
float x, y, z;
LIS.getAcceleration(&x, &y, &z);
  • getAccelerationX(void) : float
// get acceleration x
float x = LIS.getAccelerationX();
  • getAccelerationY(void) : float
// get acceleration y
float y = LIS.getAccelerationY();
  • getAccelerationY(void) : float
// get acceleration z
float Z = LIS.getAccelerationZ();
  • getTemperature(void) : int16_t
// get temperature, you need to execute LIS.openTemp() before get temperature
int16_t temp = LIS.getTemperature();
  • openTemp(void) : void
// open temperature enable
LIS.openTemp();
  • closeTemp(void) : void
// close temperature enable
LIS.closeTemp();
  • readbitADC1(void) : uint16_t
// read ADC1
uint16_t adc1 = LIS.readbitADC1();
  • readbitADC2(void) : uint16_t
// read ADC2
uint16_t adc2 = LIS.readbitADC2();
  • readbitADC3(void) : uint16_t
// read ADC3
uint16_t adc3 = LIS.readbitADC3();
  • reset(void) : void
// reset device
LIS.reset();

License

This software is written by seeed studio
and is licensed under The MIT License. Check License.txt for more information.

Contributing to this software is warmly welcomed. You can do this basically by
forking, committing modifications and then pulling requests (follow the links above
for operating guide). Adding change log and your contact into file header is encouraged.
Thanks for your contribution.

Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
Benefiting from local manufacture power and convenient global logistic system,
we integrate resources to serve new era of innovation. Seeed also works with
global distributors and partners to push open hardware movement.

seeed_arduino_lis3dhtr's People

Contributors

aiwintermuteai avatar crazyhackelkorn avatar huadiweilaoqy avatar jiacheng-lu avatar lakshanthad avatar lynnl4 avatar matsujirushi avatar nathan-ma avatar pillar1989 avatar seeedwenzy avatar xie-joker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seeed_arduino_lis3dhtr's Issues

Allow high resolution mode for I2C communication

I noticed that when I connect to this device with the I2C communication protocol I get low-resolution (2 decimal) values. I would like to get more decimals. Looking at the code, I see the constructor with I2C passes the LIS3DHTR_REG_ACCEL_CTRL_REG4_HS_DISABLE flag. Can we make this configurable by the user to choose high-res for I2C?

Please release a new version of LIS3DHTR library to pick up latest fixes.

Describe the bug
See arduino-libraries/Arduino_SensorKit#32 (comment)

The latest released library released in Nov. 20 https://github.com/Seeed-Studio/Seeed_Arduino_LIS3DHTR/releases/tag/v1.2.3 does not yet pick up latest fixes like c56da9d

This causes the Arduino Sensor Kit (Seeed product) sensors to become incompatible with newer boards based on RP2040 microcontroller using the mbed_nano architecture - for example the Arduino Nano RP2040 connect.

See arduino-libraries/Arduino_SensorKit#32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.