Git Product home page Git Product logo

micropython_lsm6dsox's Introduction

Introduction

Documentation Status

micropython

latest version on PyPI

Total PyPI downloads

Code Style: Black

MicroPython Library for the ST LSM6DSOX accelerometer/gyro Sensor

Installing with mip

To install using mpremote

mpremote mip install github:jposada202020/MicroPython_LSM6DSOX

To install directly using a WIFI capable board

mip.install("github:jposada202020/MicroPython_LSM6DSOX")

Installing Library Examples

If you want to install library examples:

mpremote mip install github:jposada202020/MicroPython_LSM6DSOX/examples.json

To install directly using a WIFI capable board

mip.install("github:jposada202020/MicroPython_LSM6DSOX/examples.json")

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 micropython-lsm6dsox

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

sudo pip3 install micropython-lsm6dsox

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install micropython-lsm6dsox

Usage Example

Take a look at the examples directory

Documentation

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

micropython_lsm6dsox's People

Contributors

jposada202020 avatar

Watchers

 avatar

Forkers

hybotics

micropython_lsm6dsox's Issues

OSError: [Errno 116] ETIMEDOUT

I am trying to get the IMU unit to work on my Nano RP2040.
I get these same results on multiple Arduino Nano RP2040s
I installed the python library into the rp2040 using the command ./mpremote.exe mip install github:jposada202020/MicroPython_LSM6DSOX and ran the following code:

import time
from machine import Pin, I2C
from lib.micropython_lsm6dsox.lsm6dsox import LSM6DSOX
# from lsm6dsox import LSM6DSOX
i2c = I2C(1, sda=Pin(2), scl=Pin(3))  # Correct I2C pins for RP2040
print(str(i2c))
devices = i2c.scan()
print(str(devices))
if devices:
    for d in devices:
        print(hex(d))
        time.sleep(1)
time.sleep(1)
lsm = LSM6DSOX(i2c)
while (True):
    print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.accel()))
    print('Gyroscope:     x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.gyro()))
    print("")
    time.sleep_ms(100)

and got:

MPY: soft reboot
I2C(1, freq=399361, scl=3, sda=2, timeout=50000)
[]
106 15 1 #this is coming from a debug line I wrote to print 'obj._address, self.register, self.lenght' in the 'RegisterStruct' class of i2c_helpers.py 
Traceback (most recent call last):
  File "<stdin>", line 14, in <module>
  File "lib/micropython_lsm6dsox/lsm6dsox.py", line 159, in __init__
  File "/lib/micropython_lsm6dsox/i2c_helpers.py", line 120, in __get__
OSError: [Errno 116] ETIMEDOUT

When I try the same thing using the following I2C config, I get:
i2c=I2C(0, scl=Pin(13), sda=Pin(12))

MPY: soft reboot
I2C(0, freq=399361, scl=13, sda=12, timeout=50000)
[106]
0x6a
106 15 1
Traceback (most recent call last):
  File "<stdin>", line 16, in <module>
AttributeError: 'LSM6DSOX' object has no attribute 'accel'

TypeError: 'int' object isn't subscriptable

Platform: MicroPython v1.22.1 on 2024-01-05; Arduino Nano RP2040 Connect with RP2040

Code:

import time
from micropython_lsm6dsox import LSM6DSOX
from machine import Pin, I2C

lsm = LSM6DSOX(I2C(0, scl=Pin(13), sda=Pin(12)))
while (True):
accx, accy, accz = lsm.acceleration
gyrox, gyroy, gyroz = lsm.gyro
print(f"Accelerometer: x:{accx:8.3f} y:{accy:8.3f} z:{accz:8.3f}")
print(f"Gyroscope: x:{gyrox:8.3f} y:{gyroy:8.3f} z:{gyroz:8.3f}")
print(f"Temperature: :{lsm.temperature}")
print("")
time.sleep_ms(1000)

When executed (using ampy) , generates the expected output lines for Accelerometer and Gyroscope, but then the error:
File "/lib/micropython_lsm6dsox/lsm6dsox.py", line 402, in temperature\r\nTypeError: 'int' object isn't subscriptable

It seems that in the line 402 there is an implicit conversion from int to float, which generates the error.

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.