A few months ago I was looking for a sensor that was able to detect light color. I stumbled into this page and thought well, that seems good to me, so I bought it. When I got it, I was going to throw it away. It just wouldn’t work. I hooked it up to my Arduino Uno with a level shifter, and it didn’t work. I hooked it up to an ATmega8 microcontroller on a breadboard, powered it with my USB serial adaptor using the 3.3V output, and it would still tell me that white light was red, and so was blue light. I checked better and found out I didn’t have an APDS-9960, but an APDS-9930.
I decided to keep it, and write a new library for it 😉
I didn’t actually write it from scratch: it’s based off the library for the APDS-9960 written by SparkFun. In fact, the usage is very similar. Few things have changed, other than removing the unneeded code (for color detection and gestures) and adding some device specific code (this specific device has two photodiodes: one that detects the visible spectrum + the infrared, called channel 0, and one that detects only infrared, channel 1). I added a method that uses the channel 1 value to filter infrared noise from the channel 0 value and turn it to Lux, but I don’t guarantee it returns the correct value.
Interrupts use channel 0 anyways, so use that value if not sure 🙂
My examples are self-explanatory, so make sure you check them if you don’t know where to start.
I took a picture to help you hook it up to an Arduino Uno, in case you were having issues. You already knew you needed a logic level shifter (like the one I’m using
Here’s the picture:
The picture isn’t really clear. Basically the interrupt (INT) pin from the sensor goes to an interrupt pin on the board through the shifter (digital pins 2 and 3 correspond to interrupts 0 and 1 on Arduino Uno, read more here) and can be safely left disconnected if not needed. SCL and SDA are the I2C data bus pins, and are always needed. SDA goes to analog pin 4 and SCL goes to analog pin 5. Some level shifters (like the one I use) are hard-wired to shift from 3V to 5V, while the one from SparkFun
Let me know if you have any issues! Either comment below or use the contact form!
P.S.: If you’re also looking for an APDS-9960 with RGB and gesture detection support, you can buy one from eBay