Code Monkey home page Code Monkey logo

adafruit_circuitpython_lidarlite's Introduction

Introduction

Documentation Status Discord Build Status Code Style: Black

A CircuitPython & Python library for Garmin LIDAR Lite sensors over I2C

Does not work with Lidar Lite v4 at this time, no ETA when it may be added - PRs accepted!

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

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

sudo pip3 install adafruit-circuitpython-lidarlite

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

Usage Examples

V3 Example

import time
import board
import busio
import adafruit_lidarlite

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)

# Default configuration, with only i2c wires
sensor = adafruit_lidarlite.LIDARLite(i2c)

while True:
    try:
        # We print tuples so you can plot with Mu Plotter
        print((sensor.distance,))
    except RuntimeError as e:
        # If we get a reading error, just print it and keep truckin'
        print(e)
    time.sleep(0.01) # you can remove this for ultra-fast measurements!

V3 HP Example

import time
import busio
import board
import adafruit_lidarlite

i2c = busio.I2C(board.SCL, board.SDA)

sensor = adafruit_lidarlite.LIDARLite(i2c, sensor_type=adafruit_lidarlite.TYPE_V3HP)

while True:
    try:
        print(f"Sensor ID#: {sensor.unit_id}")
        print(f"Distance = {sensor.distance}")
        print(f"  Strength: {sensor.signal_strength}")
    except RuntimeError as e:
        print(e)
    try:
        print(f"Status: 0b{sensor.status:b}")
        print(f"  Busy: {bool(sensor.status & adafruit_lidarlite.STATUS_BUSY_V3HP)}")
        print(f"  Overflow: {bool(sensor.status & adafruit_lidarlite.STATUS_SIGNAL_OVERFLOW_V3HP)}")
        print(f"  Health: 0b{sensor.health_status:b}")
        print(f"  Power Control: 0b{sensor.power_control:b}")
        print(f"  I2C Config: 0b{sensor.i2c_config:b}")
        print(f"  Test Command: 0b{sensor.test_command:b}")
        print(f"  Correlation: 0b{sensor.correlation_data}")
    except RuntimeError as e:
        print(e)

    print()
    time.sleep(1)

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_lidarlite's People

Contributors

caternuson avatar dastels avatar evaherrada avatar foamyguy avatar johnrbnsn avatar kattni avatar ladyada avatar neradoc avatar siddacious avatar sommersoft avatar tannewt avatar tcfranks avatar tekktrik avatar

Stargazers

 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

adafruit_circuitpython_lidarlite's Issues

NameError: name 'I2C' is not defined (Raspberry Pi 4 Model B - Ubuntu 18.04 - adafruit_lidarlite)

I am getting an issue while trying to use the library "adafruit_circuitpython_lidarlite".

Below are the details of my environment:

1- Distributor ID: Ubuntu (ubuntu-18.04.5-preinstalled-server-arm64+raspi4.img.xz)

----> Description: Ubuntu 18.04.6 LTS

----> Release: 18.04

----> Codename: bionic

2- Raspberry Pi 4 Model B Rev 1.4

3- Germin Lidar Lite V3

4- SDA & SCL Ports

I am getting this issue on both versions (1.2.6 & 1.2.7).

Installed the lidarlite adafruite library with the below command:

sudo pip3 install adafruit-circuitpython-lidarlite

I enabled the I2C port from the raspi-config also, but I am still getting the same issue.

I am not sure, but I read that this might be something with the Raspberry Pi 4 Model B Revisions.

I checked this on Revision 1.1 & Revision 1.4 of Raspberry 4 Model B. But about 2 weeks ago the same worked on one of my Raspberry Pi 4 Model B without giving me any errors. But now that Pi is dead I don't know why.
I changed the Pi and this problem started appearing.

I tried the same on the NVidia Jetson and the problem is the same there too.

image

image

DisplayIO Example Wanted

Add a Basic DisplayIO Based Example

We would like to have a basic displayio example for this library. The example should be written for microcontrollers with a built-in display. At a minimum it should show a Label on the display and update it with live readings from the sensor.

The example should not be overly complex, it's intended to be a good starting point for displayio based projects that utilize this sensor library. Try to keep all visual content as near to the top left corner as possible in order to best fascilitate devices with small built-in display resolutions.

The new example should follow the naming convention examples/libraryname_displayio_simpletest.py with "libraryname" being replaced by the actual name of this library.

You can find an example of a Pull Request that adds this kind of example here: adafruit/Adafruit_CircuitPython_BME680#72

We have a guide that covers the process of contributing with git and github: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

If you're interested in contributing but need additional help, or just want to say hi, feel free to join the Discord server to ask questions: https://adafru.it/discord

python module error

Hi, the install works fine for me but when I try to run the example it is not able to import adafruit_lidarlite resulting in the error:
ModuleNotFoundError: No module named 'adafruit_lidarlite'

Is this related to the other issue of improper install setup? Thanks.

pip3 install failing

invalid py_module declaration in setup.py currently references 'adafruit_bmp280' rather than its own adafruit_lidarlite module. once "installed" the module doesnt exist in the dist-packages and cannot be imported/used.

Measurement Faliure

Hi, I'm new to working with Lidar Sensors. I have a Garmin Lidar Lite V4. I have connected the I2C wires SDA SCL to the Raspberry PI SDA SCL. I used the sample test code in this repository but it keeps saying measurement failed. Can you please help?

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_lidarlite.py:78
  • adafruit_lidarlite.py:125
  • adafruit_lidarlite.py:135
  • adafruit_lidarlite.py:165
  • adafruit_lidarlite.py:173

NameError: name 'WriteableBuffer' is not defined (Lidar Lite V3)

Hi,
I am getting an issue while trying to use the library "adafruit_circuitpython_lidarlite".

Below are the details of my environment:
1- Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic

2- Raspberry Pi 4 Model B
3- Germin Lidar Lite V3
4- SDA & SCL Ports

I am getting this issue on both versions (1.2.6 & 1.2.7).

Error:
Traceback (most recent call last):
File "lidarlite.py", line 4, in
import adafruit_lidarlite
File "/home/ubuntu/.local/lib/python3.6/site-packages/adafruit_lidarlite.py", line 30, in
from adafruit_bus_device.i2c_device import I2CDevice
File "/usr/local/lib/python3.6/dist-packages/adafruit_bus_device/i2c_device.py", line 26, in
class I2CDevice:
File "/usr/local/lib/python3.6/dist-packages/adafruit_bus_device/i2c_device.py", line 65, in I2CDevice
self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None
NameError: name 'WriteableBuffer' is not defined

image

Please update for LidarLiteV4

Can you please update this library to support the new LidarLiteV4?

I spent over an hour trying to set it up with this library, as the library does not specifically specify that it doesn't work with this model, and it is a module that is sold on the Adafruit store.

Thanks!

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.