Der APDS-9960 ist ein Sensor der über den I2C Bus mit einem Mikrocontroller wie dem ESP8266 verbunden werden kann.
Mithilfe des Sensors ist es möglich einfache Gesten zu erkennen, die Helligkeit, den Abstand eines Objekts zum Sensor und die Farbe des auf den Sensor treffenden Lichts zu messen.
Die Integration in ESPEasy ist dank des passenden Plugins recht einfach.
Die notwendigen Schritte zur Integration des APDS-9960 in Eure ESPEasy-Instanz sind im folgenden Artikel beschrieben.
Safety instructions
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/
Affiliate links/advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Requirements
Helpful articles:
Additional tips on ESPEasy can be found in the following articles.
- ESPEasy - Execute commands and actions via HTTP, MQTT, UDP and directly
- ESPEasy - Compile firmware, flash and configure WLAN access data
- ESPEasy / Wemos D1 Mini - Adapt ADC to other maximum voltages
Required tool:
Required material:
Den APDS-9960 an den ESP8266 anschließen
Der APDS-9960 wird über den I2C Bus mit dem ESP8266 bzw. Wemos D1 Mini verbunden.
Konfiguration des APDS-9960 in ESPEasy
Damit der APDS-9960 in ESPEasy konfiguriert werden kann sollte die ESPEasy Firmware schon auf den ESP8266 bzw. ESP32 aufgespielt und erreichbar sein. Informationen dazu findet Ihr auch im Artikel ESPEasy - Compile firmware, flash and configure WLAN access data.

First open the configuration website of your ESP8266 programmed with ESPEasy by entering its IP address into your web browser. Information on how to find out the IP address can also be found in the article Display/find out the IP address of the devices in the network summarized.
Sobald Ihr die Konfigurationswebseite geöffnet habt, müsst Ihr auf den “Devices”-Tab wechseln. Klickt dazu auf den “Devices”-Button.

You will then be automatically redirected to the featured view and...

...can select here which device you want to create.
Selects here the entry
- Gesture – APDS9960 [DEVELOPMENT]
off.
If the entry you are looking for is not visible, the plugin is not included in your ESPEasy installation. A precompiled binary which also contains this plugin can be found at the following link.

This will redirect you back to an overview page.
Hier könnt Ihr Alle Einstellungen bezüglich des APDS-9960 vornehmen.
If you have used the circuit diagram shown above, you can use the settings shown.
Wichtig ist, dass Ihr den Haken bei “Force Slow I2C Speed” setzt.
Außerdem müsst Ihr im Abschnitt “Plugin Mode” einstellen ob der Sensor die Gesten, Annäherung und Helligkeitswerte oder die RGB-Farbwerte des auftreffenden Lichts messen soll.

Zur Messung der Gesten- Näherungs- und Helligkeitswerte muss der APDS-9960 dagegen wie hier dargestellt konfiguriert werden.

Ansicht der weiteren Einstellungen im Modus zur Messung der Gesten- Näherungs- und Helligkeitswerte.
Klickt zum übernehmen der Einstellungen auf “Submit”.

Ansicht der weiteren Einstellungen im Modus zur Messung der RGB-Farbmessung
Klickt zum übernehmen der Einstellungen auf “Submit”.
Messwerte des APDS-9960 anzeigen lassen
Nachdem Ihr den APDS-9960 konfiguriert habt könnt Ihr Ihn direkt testen.

In der Übersicht der konfigurierten Devices sind in der Zeile des APDS-9960 auf der rechten Seite die Messwerte zu sehen.
Diese aktualisieren sich spätestens alle 60 Sekunden. Dieses Intervall lässt sich in der Konfiguration des APDS-9960 im Abschnitt “Interval” einstellen.

Falls Ihr den APDS-9960 zuvor auf die Messung der RGB-Farbwerte konfiguriert habt, sieht die Ansicht wie links dargestellt aus.
Helligkeitswert des APDS-9960 mithilfe von Rules nutzen
Wenn Ihr den APDS-9960 im Modus zur Messung der Gesten- Näherungs- und Helligkeitswerte nutzt könnt Ihr den gemessenen Helligkeitswert auch nutzen um zum Beispiel die Helligkeit einer Lampe automatisch an die Umgebungshelligkeit anzupassen. Auch zur Anpassung von Displayhelligkeiten ist dies praktisch, da das Display bei dunkler Umgebungshelligkeit nicht zu hell und bei heller Umgebungshelligkeit nicht zu dunkel dargestellt wird.
Ein Beispiel zur automatischen Nutzung des vom APDS-9960 gemessenen Helligkeitswert findet Ihr in den folgenden Rules. Das dargestellte Beispiel führt dazu, dass die Helligkeit der LEDs welche vom pxlBlck-Plugin angesteuert werden automatisch an die Umgebungshelligkeit angepasst wird.
On gesture#Light do pbbr,0,[gesture#Light],1,1,15, endon
Sensordaten per MQTT versenden
Die gesammelten Sensordaten könnt Ihr nun auch per MQTT an Euer SmartHome senden und dort ggf. weiter verarbeiten. Was Ihr dazu konfigurieren müsst ist im folgenden Artikel beschrieben.
Additional sensors for connection to the ESP8266 / ESP32
An overview of other articles for connecting sensors and actuators to ESPEasy can be found in the following category.
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂