{"id":13802550,"url":"https://github.com/rlangoy/uPy_APDS9960","last_synced_at":"2025-05-13T13:31:49.193Z","repository":{"id":142255945,"uuid":"229621167","full_name":"rlangoy/uPy_APDS9960","owner":"rlangoy","description":"Micropython proximitiy library for esp8266 using APDS9960","archived":false,"fork":false,"pushed_at":"2023-02-06T13:18:46.000Z","size":1080,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-22T12:36:34.188Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rlangoy.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-22T19:44:47.000Z","updated_at":"2024-04-13T11:08:43.000Z","dependencies_parsed_at":"2023-05-12T06:30:51.605Z","dependency_job_id":null,"html_url":"https://github.com/rlangoy/uPy_APDS9960","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlangoy%2FuPy_APDS9960","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlangoy%2FuPy_APDS9960/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlangoy%2FuPy_APDS9960/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlangoy%2FuPy_APDS9960/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rlangoy","download_url":"https://codeload.github.com/rlangoy/uPy_APDS9960/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253950136,"owners_count":21989311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:46.937Z","updated_at":"2025-05-13T13:31:49.185Z","avatar_url":"https://github.com/rlangoy.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"readme":"MicroPython APDS-9960 \u0026 APDS-9900 RAM optimized Library\n=======================================================\n\n.. image:: https://readthedocs.org/projects/upy-apds9960/badge/?version=latest\n    :target: https://upy-apds9960.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n|\n.. raw:: html \n    \n    \u003cimg src=\"https://github.com/rlangoy/uPy_APDS9960/raw/master/docs/images/breakoutboard.jpg\"\u003e\n\nAnother APDS9960 / GY-9960LLC / APDS9900 micro python library optimized for ESP8266 / ESP12-E for:\n    * Light Sensing  (Ambient Light and RGB Color Sensing)\n    * Proximity Sensing\n\nDocumentation \n=============\nComplete documentation is hosted on the \"Read the Docs\" page \n`upy-apds9960.readthedocs.io \u003chttps://upy-apds9960.readthedocs.io\u003e`_\n\n\nDependencies\n============\nThis driver depends on:\n\n* `MicroPython \u003chttp://micropython.org/\u003e`_\n\nTested on:\n      | Sensor:   `GY-9960LLC \u003chttps://www.aliexpress.com/item/32738206621.html\u003e`_\n      | Sensor:   `APDS-9900  \u003chttps://www.aliexpress.com/item/32738206621.html\u003e`_\n      | Devboard: Node MCU v1.0 \u0026 Raspberry PI Pico\n\nInstallation\n============\n* Flash the device with MicroPython\n* Copy the folder uPy_APDS9960 and content (apds9960LITE.py) to the root folder for APDS9960 circuits\n* Copy the folder uPy_APDS9900 and content (apds9900LITE.py) to the root folder for APDS9900 circuits\n\nThe steps above is descsribed in the `Thonny IDE tutorial`_.\n\n.. _Thonny IDE tutorial: https://upy-apds9960.readthedocs.io/en/latest/thonny_guide.html\n\nExamples\n========\nThe examples in theis respository uses the NodeMCU devboard the devboard to use rpi pico please change the I2C inferface as show in the code below\n\n.. code-block:: python\n\n  #Change I2C interface from: \n  #  i2c =  machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))\n  #to:\n  i2c =  machine.I2C(0,scl=machine.Pin(17), sda=machine.Pin(16))\n\nHere is the `NodeMCU Hookup`_.\n\n.. _NodeMCU Hookup: ./node_mcu_example.rst\n\nAPDS9960 Example\n================\n\n.. code-block:: python\n\n  import machine\n  from time import sleep_ms\n  from uPy_APDS9960.apds9960LITE import APDS9960LITE\n\n  #Init I2C Buss on RP2040\n  i2c =  machine.I2C(0,scl=machine.Pin(17), sda=machine.Pin(16))\n\n  apds9960=APDS9960LITE(i2c)      # Enable sensor\n  apds9960.prox.enableSensor()    # Enable Proximit sensing\n\n  while True:\n          sleep_ms(25) # wait for readout to be ready\n          print(apds9960.prox.proximityLevel)   #Print the proximity value\n\nAPDS9900 ESP32-C3 Example\n================\n\n.. code-block:: python\n\n    import machine\n    from time import sleep_ms\n    from uPy_APDS9900.apds9900LITE import APDS9900LITE\n    \n    #Init Left I2C Buss on ESP32-C3\n    i2c =  machine.SoftI2C(scl=machine.Pin(9), sda=machine.Pin(8))\n    \n    apds9900=APDS9900LITE(i2c)      # Enable sensor\n    apds9900.prox.enableSensor()    # Enable Proximit sensing\n    \n    while True:\n            sleep_ms(25) # wait for readout to be ready\n            print(apds9900.prox.proximityLevel)   #Print the proximity value\n\n\nAPDS9900 Raspberry Pico Example\n================\n\n.. code-block:: python\n\n    import machine\n    from time import sleep_ms\n    from uPy_APDS9900.apds9900LITE import APDS9900LITE\n\n    #Init I2C Buss on RP2040\n    i2c =  machine.I2C(0,scl=machine.Pin(17), sda=machine.Pin(16))\n\n    apds9900=APDS9900LITE(i2c)      # Enable sensor\n    apds9900.prox.enableSensor()    # Enable Proximit sensing\n\n    while True:\n            sleep_ms(25) # wait for readout to be ready\n            print(apds9900.prox.proximityLevel)   #Print the proximity value\n\n\n\nHardware Set-up\n---------------\n\nConnect Vin to 3.3 V or 5 V power source, GND to ground, SCL and SDA to the appropriate pins to the Raspberry PI Pico\n\n========== ====== ============ ======== ==============\nAPDS9960   Name   Remarks      RPI PICO  Function  \n========== ====== ============ ======== ==============\n1           VIN    +3.3V Power  36       3V3 \n2           GND    Ground       GND      GND           \n3           SCL    I2C clock    22       GP17 (SCL)   \n4           SDA    I2C Data     21       GP16 (SDA)   \n5           INT    Interrupt    26       GP20    \n========== ====== ============ ======== ==============\n\n.. raw:: html\n\n    \u003cimg src=\"https://github.com/rlangoy/uPy_APDS9960/raw/master/docs/images//PicoHookup.PNG\"\u003e\n\nBasics\n------\n\nOf course, you must import the device and library :)\n\n.. code:: python\n\n  import machine\n  from time import sleep_ms\n  from uPy_APDS9960.apds9960LITE import APDS9960LITE\n \n\nTo set-up the device to gather data, initialize the I2C-device using SCL and SDA pins. \nThen initialize the library.  \n\n.. code:: python\n  \n  i2c =  machine.I2C(0,scl=machine.Pin(17), sda=machine.Pin(16))\n  apds9960=APDS9960LITE(i2c)         # Poweron APDS9960\n  \n\nProximity\n~~~~~~~~~\nProximity funxtionalites is accessed torough the apds9960.prox member :class:`.PROX`\n\n.. code:: python\n\n  apds9960.prox.enableSensor()         # Enable Proximity sensing\n  sleep_ms(25)                         # wait for readout to be ready\n  print(apds9960.prox.proximityLevel)  # Print the proximity value\n\nLight Sensing\n~~~~~~~~~~~~~\nProximity funxtionalites is accessed torough the apds9960.als member :class:`.ALS`\n\n.. code:: python\n\n  apds9960.als.enableSensor()           # Enable Light sensor\n  sleep_ms(25)                          # Wait for readout to be ready\n  print(apds9960.als.ambientLightLevel) # Print the ambient light value\n\n\nDebug\n-----\nIf things does not work try to run the script below to verify that it i2c communication with the apds9960 is working as expected\n\n.. code:: python\n\n    import machine\n    i2c =  machine.I2C(0,scl=machine.Pin(17), sda=machine.Pin(16))\n\n    print('Scan i2c bus...')\n    devices = i2c.scan()\n\n    if len(devices) == 0:\n      print(\"No i2c device !\")\n    else:\n      print('i2c devices found:',len(devices))\n\n      for device in devices:\n        print(\"Decimal address: \",device,\" | Hexa address: \",hex(device))\n\n        if(device==0x39): # APDS9960 Address = 0x39\n            deviceID=i2c.readfrom_mem(devices[0],0x92, 1) #Get deviceID\n            deviceID=int.from_bytes(deviceID,'big')       #Conv byte to int\n            if(deviceID==0x29):\n               deviceID=9900\n            elif(deviceID==0x20):\n                deviceID=9901\n            else:\n                deviceID=9960\n\n            print(\"Found ADPS-\",deviceID)\n\nIf successful the output should be:\n\n.. code-block:: shell\n\n  Scan i2c bus...\n  i2c devices found: 1\n  Decimal address:  57  | Hexa address:  0x39  \n  Found ADPS- 9960\n\n\n.. note:: Be aware if the output shows: ::\n\n   \"many i2c devices was listed\"  check if the i2c pins are allocated correctly\n   \"No i2c device\"                check if the power is correctly connected\n  \nThe Device id can be 0xa8, 0xab 0x9c or 0x55.)\n\nSphinx documentation\n====================\n\n`Sphinx the Python Documentation Generator \u003chttp://www.sphinx-doc.org/\u003e`_ is used for this documentation, if you like to build a local copy of the documentation install Sphinx :\n\n.. code-block:: shell\n\n    python -m pip install sphinx\n\nCeate html doc by\n\n.. code-block:: shell\n\n    cd docs\n    make html\n\nThe html pages would be located at : docs/_build/html \n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n\u003chttps://github.com/adafruit/Adafruit_CircuitPython_APDS9960/blob/master/CODE_OF_CONDUCT.md\u003e`_\nbefore contributing to help this project stay welcoming.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlangoy%2FuPy_APDS9960","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frlangoy%2FuPy_APDS9960","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlangoy%2FuPy_APDS9960/lists"}