Giter Site home page Giter Site logo

adafruit_circuitpython_lsm9ds1's Introduction

Introduction

Documentation Status

Discord

Build Status

Code Style: Black

CircuitPython module for the LSM9DS1 accelerometer, magnetometer, gyroscope.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-lsm9ds1

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-lsm9ds1

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-lsm9ds1

Usage Example

See examples/lsm9ds1_simpletest.py for a demo of the usage.

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_lsm9ds1's People

Contributors

2bndy5 avatar aarondewindt avatar brennen avatar caternuson avatar davidskeck avatar dhalbert avatar evaherrada avatar foamyguy avatar jepler avatar jerryneedell avatar jposada202020 avatar kattni avatar keiththeee avatar ladyada avatar siddacious avatar sommersoft avatar tannewt avatar tcfranks avatar tdicola avatar tekktrik avatar thekitty avatar

Stargazers

 avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_lsm9ds1's Issues

Sample rate for accelerometer?

Hi,

Is it possible to set the sample rate for the accelerometer? In the Arduino library there is a setting that can be altered, but I don't see the same in this library.

Thanks!

Missing Type Annotations

There are missing type annotations for some functions in this library.

The typing module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

try:
    from typing import List, Tuple
except ImportError:
    pass

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

def wrap_text_to_pixels(
    string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:

If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs and Check your code with pre-commit contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev channel.

The following locations are reported by mypy to be missing type annotations:

  • adafruit_lsm9ds1.py:126
  • adafruit_lsm9ds1.py:183
  • adafruit_lsm9ds1.py:212
  • adafruit_lsm9ds1.py:240
  • adafruit_lsm9ds1.py:332
  • adafruit_lsm9ds1.py:339
  • adafruit_lsm9ds1.py:346
  • adafruit_lsm9ds1.py:398
  • adafruit_lsm9ds1.py:415
  • adafruit_lsm9ds1.py:427
  • adafruit_lsm9ds1.py:436
  • adafruit_lsm9ds1.py:489
  • adafruit_lsm9ds1.py:498
  • adafruit_lsm9ds1.py:509
  • adafruit_lsm9ds1.py:520

Looking for burst data from LSM9DS1

I have an application where I would like to get burst data from the LSM9DS1 when it is connected to a Raspberry Pi. As an example I would like to collect 10 seconds of ~900Hz data from the accelerometers and gyros. I think the chip is capable of it. I have not found the capability in the CircuitPython package yet.

Is the capability in the package but I have not found it?
Are there any plans to add the capability?
Is it even possible to do it with Circuit Python?

XG requires reboot to function properly

Hello, I am using the LSM9DS1 connected to an ESP32-PICO-D4 over SPI on a custom board. I found that it would fail when checking if self._read_u8(_XGTYPE, _LSM9DS1_REGISTER_WHO_AM_I_XG) != _LSM9DS1_XG_ID, raising the RuntimeError('Could not find LSM9DS1')

I fixed it by changing the line above,
from: self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG8, 0x05)
to:
self._write_u8(_XGTYPE, _LSM9DS1_REGISTER_CTRL_REG8, int('0b10000101', 2))
This changes the BOOT flag on the register CTRL_REG8 from 0 to 1, telling the XG to reboot memory content. I noticed that in your line to reboot the mag sensor you did set the REBOOT flag, this was the clue to also BOOT the XG.

I am not sure if this is specific to the ESP32-PICO-D4 but wanted to share my solution

Temperature starting point estimation is off

The board gives consistently lower temperature readouts (by 3~4°C). I do not have laboratory equipment to test this out but it appears the zero raw value is at about 31.0 instead of 27.5. I believe more testing and update to the library is warranted.

SPI class is using I2C Device

class LSM9DS1_SPI(LSM9DS1):
    """Driver for the LSM9DS1 connect over SPI."""
    # pylint: disable=no-member
    def __init__(self, spi, xgcs, mcs):
        self._mag_device = spi_device.I2CDevice(spi, mcs)
        self._xg_device = spi_device.I2CDevice(spi, xgcs)
        super().__init__()

Setting accel_range and gyro_scale

Dear all,
I just got two short questions regarding accel_range and gyro_scale.
a) Is it correct to set the values like that initially, or do I need to reset the sensor afterwards in some fashion?

import board
import busio
import adafruit_lsm9ds1
lsm9ds1 = adafruit_lsm9ds1.LSM9DS1_I2C(i2c)
lsm9ds1.accel_range = adafruit_lsm9ds1.ACCELRANGE_16G
lsm9ds1.gyro_scale = adafruit_lsm9ds1.GYROSCALE_2000DPS

b) Can I, at any time, set the range/scale to a new value like this, or do I need to reset/give another command to the sensor?

lsm9ds1.accel_range = adafruit_lsm9ds1.ACCELRANGE_2G
lsm9ds1.gyro_scale = adafruit_lsm9ds1.GYROSCALE_245DPS

Thanks a lot for your help!

CTRL_REG1_G handling

According to the datasheet, CTRL_REG1_G consists of:

ODR_G2 ODR_G1 ODR_G0 FS_G1 FS_G0 0 BW_G1 BW_G0 and the scale is encoded on FS_G1 and FS_G0.

In the source code this bit mask is used: 0b00110000 (0x30), and it seems that ODR_G0 and FS_G1 are written. Shouldn't you use 0b00011000 (0x18) instead?

Using SPI gives same measurement for all magnetometer axes

When I use the code for the SPI example, I noticed that all three values were the same when calling sensor.magnetic. Initially, I believed it to be a very strong magnetic interference, but it behaved as expected after switching to the I2C connection. Haven't yet nailed down what the issue is. I am using it with a raspberry pi zero w. Has this issue been encounter before?

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.