{"id":26539760,"url":"https://github.com/styropyr0/apds9960","last_synced_at":"2026-05-08T11:06:19.024Z","repository":{"id":282695770,"uuid":"949384624","full_name":"styropyr0/APDS9960","owner":"styropyr0","description":"A feature packed driver for the APDS9960 sensor, supporting ambient light, color, proximity, and gesture sensing.","archived":false,"fork":false,"pushed_at":"2025-03-16T10:46:43.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T11:30:25.678Z","etag":null,"topics":["apds","apds-9960","apds9960","arduino-ide","arduino-libraries","arduino-library","color-sensor","esp32","esp32-arduino","esp32-library","library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/styropyr0.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-16T10:42:10.000Z","updated_at":"2025-03-16T10:51:09.000Z","dependencies_parsed_at":"2025-03-16T11:30:32.594Z","dependency_job_id":"89de6290-49cc-4b7e-8651-170f52aed61d","html_url":"https://github.com/styropyr0/APDS9960","commit_stats":null,"previous_names":["styropyr0/apds9960"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FAPDS9960","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FAPDS9960/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FAPDS9960/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FAPDS9960/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styropyr0","download_url":"https://codeload.github.com/styropyr0/APDS9960/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244885785,"owners_count":20526309,"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":["apds","apds-9960","apds9960","arduino-ide","arduino-libraries","arduino-library","color-sensor","esp32","esp32-arduino","esp32-library","library"],"created_at":"2025-03-22T00:18:51.468Z","updated_at":"2026-05-08T11:06:19.006Z","avatar_url":"https://github.com/styropyr0.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APDS9960 Arduino Library\n\nThe **APDS9960 Arduino Library** is a feature packed driver for interfacing with the APDS9960 sensor, a versatile device capable of ambient light sensing, color detection (RGB), proximity sensing, and gesture recognition. This library provides an easy-to-use interface to configure the sensor and retrieve processed data, making it ideal for Arduino-based projects requiring environmental sensing or touchless interaction.\n\nThis library supports a wide range of functionalities, including enabling/disabling sensors, setting sensitivity levels, configuring interrupts, and interpreting gesture data.\n\n## Features\n- **Ambient Light Sensing**: Measure ambient light levels and set interrupt thresholds.\n- **Color Detection**: Read RGB and clear channel data for color analysis.\n- **Proximity Sensing**: Detect nearby objects with adjustable sensitivity and offsets.\n- **Gesture Recognition**: Interpret directional gestures (up, down, left, right) with customizable settings.\n- **Interrupt Support**: Enable interrupts for light, proximity, and gesture events.\n- **Flexible Configuration**: Adjust gain, sensitivity, LED drive, and timing parameters.\n\n## Requirements\n- **Hardware**: \n  - Arduino-compatible board (e.g., Uno, Mega, ESP32, etc.)\n  - APDS9960 sensor module\n- **Software**:\n  - Arduino IDE (1.8.x or later)\n  - [Wire library](https://www.arduino.cc/en/Reference/Wire) (included with Arduino IDE)\n  - `SensorHub.h` (dependency, ensure it’s included in your project)\n\n## Installation\n1. **Download the Library**:\n   - Clone this repository or download it as a ZIP file:\n     ```\n     git clone https://github.com/\u003cyour-username\u003e/APDS9960-Arduino-Library.git\n     ```\n   - Alternatively, download the ZIP from the releases page.\n\n2. **Install in Arduino IDE**:\n   - Open the Arduino IDE.\n   - Go to `Sketch \u003e Include Library \u003e Add .ZIP Library...`.\n   - Select the downloaded ZIP file or the folder containing `APDS9960.h` and `APDS9960DEFS.h`.\n\n3. **Verify Dependencies**:\n   - Ensure `SensorHub.h` is available in your project or library folder. If not provided, contact the author or check the repository for additional dependencies.\n\n## Usage\n### Basic Example\nThis example initializes the APDS9960 sensor and reads proximity data:\n\n```cpp\n#include \u003cAPDS9960.h\u003e\n\nAPDS9960 sensor;\n\nvoid setup() {\n  Serial.begin(9600);\n  if (sensor.begin()) {\n    Serial.println(\"APDS9960 initialized successfully!\");\n  } else {\n    Serial.println(\"Failed to initialize APDS9960. Check connections.\");\n  }\n  sensor.enableProximitySensing(true); // Enable proximity sensing\n}\n\nvoid loop() {\n  uint8_t proximity = sensor.readProximity();\n  Serial.print(\"Proximity: \");\n  Serial.println(proximity);\n  delay(500);\n}\n```\n\n### Gesture Detection Example\nThis example demonstrates gesture recognition:\n\n```cpp\n#include \u003cAPDS9960.h\u003e\n\nAPDS9960 sensor;\n\nvoid setup() {\n  Serial.begin(9600);\n  if (sensor.beginAll()) { // Initialize with all features enabled\n    Serial.println(\"APDS9960 ready with all features!\");\n  }\n  sensor.enableGestureSensing(true); // Enable gesture detection\n}\n\nvoid loop() {\n  Gesture gesture = sensor.readGesture();\n  String direction = sensor.resolveGesture(gesture, 50); // 50% threshold\n  if (direction != \"\") {\n    Serial.print(\"Gesture detected: \");\n    Serial.println(direction);\n  }\n  delay(100);\n}\n```\n\n### Color Sensing Example\nThis example reads RGB color data:\n\n```cpp\n#include \u003cAPDS9960.h\u003e\n\nAPDS9960 sensor;\n\nvoid setup() {\n  Serial.begin(9600);\n  sensor.begin();\n  sensor.enableLightSensing(true); // Enable light sensing\n}\n\nvoid loop() {\n  Color color = sensor.readColorData();\n  Serial.print(\"R: \"); Serial.print(color.red);\n  Serial.print(\" G: \"); Serial.print(color.green);\n  Serial.print(\" B: \"); Serial.print(color.blue);\n  Serial.print(\" Clear: \"); Serial.println(color.clear);\n  delay(1000);\n}\n```\n\n## API Overview\n### Initialization\n- `APDS9960()`: Constructor with default I2C address (0x39).\n- `bool begin()`: Initialize with default settings.\n- `bool beginAll()`: Initialize and enable all sensing and interrupt features.\n- `uint8_t getPID()`: Retrieve the product ID of the sensor.\n- `bool isConnected()`: Check if the sensor is connected and responding.\n\n### Sensor Control\n- `void enableAllSensors(bool state)`: Enable/disable all sensors (light, proximity, gesture).\n- `void enableLightSensing(bool state)`: Enable/disable ambient light sensing.\n- `void enableProximitySensing(bool state)`: Enable/disable proximity sensing.\n- `void enableGestureSensing(bool state)`: Enable/disable gesture sensing.\n- `void enableAllInterrupts(bool state)`: Enable/disable all interrupts (light, proximity).\n- `void enableLightInterrupt(bool state)`: Enable/disable ambient light interrupt.\n- `void enableProximityInterrupt(bool state)`: Enable/disable proximity interrupt.\n- `void enableGestureInterrupt(bool state)`: Enable/disable gesture sensing interrupt.\n- `void enableWaitTimer(bool state, uint8_t waitTime, bool WLONG)`: Enable/disable wait timer with specified wait time and long wait option.\n\n### Data Retrieval\n- `uint8_t readProximity()`: Get proximity value (0-255).\n- `Color readColorData()`: Get RGB and clear channel data.\n- `Gesture readGesture()`: Get raw gesture data from FIFO.\n- `String resolveGesture(Gesture gesture, uint8_t threshold)`: Interpret gesture direction with a percentage threshold.\n\n### Configuration\n- `void setLightSensitivity(uint8_t shutterSpeed)`: Adjust light sensor sensitivity (0-255).\n- `void correctProximity(int8_t upRight, int8_t downLeft)`: Correct proximity sensor offsets.\n- `void setLightSensingInterruptThreshold(uint16_t low, uint16_t high)`: Set light interrupt thresholds.\n- `void setProximitySensingInterruptThreshold(uint8_t low, uint8_t high)`: Set proximity interrupt thresholds.\n- `void setPersistence(uint8_t light, uint8_t proximity)`: Set persistence for light and proximity interrupts (0-15).\n- `void setProximitySensitivity(uint8_t sensitivity)`: Set proximity sensitivity (0-3).\n- `void setProximitySensorRange(uint8_t level)`: Set proximity LED drive current level (0-3).\n- `void setLightGain(uint8_t gainFactor)`: Set gain factor for light sensing (0-3).\n- `void setGestureGain(uint8_t gainFactor)`: Set gain factor for gesture sensing (0-3).\n- `void setGestureSensitivity(uint8_t pulseLength, uint8_t pulseCount)`: Set pulse length (0-3) and count (0-63) for gesture detection.\n- `void setGestureDetectorMode(uint8_t mode)`: Set gesture detector mode (0-3).\n\nFor detailed parameter ranges, refer to `APDS9960.h` and `APDS9960DEFS.h`.\n\n## Troubleshooting\n- **Sensor Not Detected**: Check I2C connections (SDA, SCL, VCC, GND) and ensure the address is correct (0x39).\n- **Invalid Readings**: Verify sensor configuration (gain, sensitivity) and check for obstructions.\n- **Errors**: Enable logging by modifying the private `printLogs` member to `true` for debug output.\n\n## Contributing\nContributions are welcome! Please:\n1. Fork the repository.\n2. Create a feature branch (`git checkout -b feature/YourFeature`).\n3. Commit changes (`git commit -m \"Add YourFeature\"`).\n4. Push to the branch (`git push origin feature/YourFeature`).\n5. Open a pull request.\n\n## License\nThis library is released under the [MIT License](LICENSE). Feel free to use, modify, and distribute it as needed.\n\n## Acknowledgments\n- Author: **Saurav Sajeev**\n- Built for the Arduino community ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fapds9960","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyropyr0%2Fapds9960","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fapds9960/lists"}