GithubHelp home page GithubHelp logo

python-apds9960's Introduction

Python (and MicroPython) APDS-9960 Library

Python library for the APDS-9960 gesture sensor developed while I was looking to get the APDS-9960 to work with a Raspberry Pi to build a user interface feeling like in Minority Report.

This library is a port of the APDS-9960 Raspberry Pi Library of Justin Woodman. Sadly his library is coded in C++ and seems not to be maintained any more.

This library has been tested with SparkFun RGB and Gesture Sensor - APDS-9960 but should work with any other APDS-9960 based I²C device, too.

Installation

This library is available from PyPi. You may want to setup a virtualenv before installing the library using:

pip install apds9960

Features of the APDS-9960

  • operational voltage: 3.3V
  • ambient light & RGB color sensing
  • proximity sensing
  • gesture detection
  • operating range: 10 - 20cm
  • I²C interface (hard wired I²C address: 0x39)

Documentation & Examples

python-apds9960's People

Contributors

liske avatar pcgeek86 avatar raceking37 avatar ristomatti avatar thomaswaldmann avatar

Stargazers

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

python-apds9960's Issues

Problems in readGesture()

Here is what I get when i try to use your sample code for RPi.

Traceback (most recent call last):
  File "test.py", line 39, in <module>
    motion = apds.readGesture()
  File "/home/pi/.local/lib/python2.7/site-packages/apds9960/device.py", line 192, in readGesture
    self.gesture_data_.u_data[self.gesture_data_.index] = fifo_data[i + 0]
IndexError: list assignment index out of range

Here is what I get when I try to print the list and the index (last 2 loop):

[137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 0]
31
[137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137]
32

looks like self.gesture_data_.u_data has 32 item and self.gesture_data_.index doing +1 in each loop.

not working esp32

exec(open('test_ambient.py').read(),globals())
Traceback (most recent call last):
File "", line 1, in
File "", line 10, in
File "apds9960/device.py", line 41, in init
File "apds9960/exceptions.py", line 3, in init
AttributeError: type object 'Exception' has no attribute 'init'

ESP32 Issue

I installed this library via Thonny packages and after running the example it throws me this error:
Warning: I2C(-1, ...) is deprecated, use SoftI2C(...) instead
Traceback (most recent call last):
File "", line 10, in
File "/lib/apds9960/device.py", line 41, in init
File "/lib/apds9960/exceptions.py", line 3, in init
AttributeError: type object 'Exception' has no attribute 'init'

Can you please help me?

APDS9960InvalidDevID

I am using Raspberry Pi 4B, python3.7
I've got this error message:

pi@rpi4g:~/apds9960 $ i2cget -y 1 0x39 0x92
0x39
pi@rpi4g:~/apds9960 $ vim test_ambient.py
pi@rpi4g:~/apds9960 $ python3 test_ambient.py
Traceback (most recent call last):
  File "test_ambient.py", line 11, in <module>
    apds = APDS9960(bus)
  File "/home/pi/.local/lib/python3.7/site-packages/apds9960/device.py", line 41, in __init__
    raise ADPS9960InvalidDevId(self.dev_id, valid_id)
apds9960.exceptions.ADPS9960InvalidDevId: Device id 0x39 is not a valied one (valid: 0xab, 0x9c, 0xa8)!

when i using i2cget -y 1 0x39 0x92, i got 0x39 but is not include in

# APDS9960 device IDs
APDS9960_DEV_ID = [0xab, 0x9c, 0xa8, -0x55]

How to solve this problem Please?

Enabling both proximity and gesture

Trying to enable proximity and gesture sensors ends in a weird behavior for the proximity sensor that returns weird values

BTW, thank you so much for this library!

Gesture issue on rpi

Hi, I'm trying your library on a rpi3 b+
The proximity example works as expected but I've some issue with the gesture one.

If I use your script as is, I get INTERRUPT printed indefinitely and gesture are not recognized.
If I remove the interrupt part of the code the script start and wait but gesture are still not recognized

I've setup the sensor as per your instruction in the Readme.

Any hint?
Thank you

Gestures are not working on ESP32

When I try to run example gesture code I get:

Gesture Test
============
Traceback (most recent call last):
  File "<stdin>", line 31, in <module>
  File "apds9960/device.py", line 185, in readGesture
  File "apds9960/device.py", line 1103, in _read_i2c_block_data
OSError: I2C bus error (6)

Any ideas what is wrong?

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.