[New part] Trying out APDS-9960 - Gesture, proximity, ambient light and RGB sensor


One of the aspects of any tinkerer's (and mine) activities that goes largely overlooked is learning about, sourcing and trying out new electronic parts. The industry continuously churns out sensors and microcontrollers that can do more than the previous generations. It's up to you to get acquanted with as much of the fresh stuff as possible, if you want to stay on the bleeding edge.

So, this post will (hopefully) establish a new series of posts under "New part" tag, where I'll show off the new part that I obtained from online or offline stores (or maybe even some other sources), what it can do and the minimal set-up to get it working.

Proximity sensing as I knew it

Having been involved in robotics in my university years, I've always looked out for new solutions to the hottest hardware problems in this field. One of such challenges was accurate proximity sensing - the ability to accurately sense distance to other objects was often what separated winning robots from the rest in robotics contests.

The type of sensor we (and the majority) used back then was a common ultrasonic one, mostly due to its low cost and ubiquity. You know, something like this:
HC-SR04. 10USD can buy you a bag of those.

This sensor continuosly sends click train in ultrasound, senses the reflections of those clicks. By measuring the time it took for the click to bounce back, we can tell the distance to the nearest object.

It was simple to use them,but there were two downsides that became apparent with time:
  • Detection range of 2cm to 400 cm (1" - 13 feet) seems huge, and it is. What's inconvenient is that when something approaches closer that 2cm, sensor starts spouting erratic distances.
  • Doesn't work well with acoustic absorbers (e.g. cloth, foam).

Gesture and color sensing as I knew it

To be fair, I never stumbled upon popular and inexpensive sensors for these purposes, so frankly I knew precisely squat.

APDS-9960 - Gesture, proximity, ambient light and RGB sensor

When I learned about this sensor, it sounded too good to be real. Gesture sensing (up, down, left, right, up, down, in and out), proximity sensing, color and ambient light sensing, floor sweeping and coffee making - looks like another indispensable part in maker's cabinet!

No doubt it can do all these things, but can it do them WELL? My expectation was that it would be good at close range and with acoustic absorbers too, being used as a complement to ultrasonic sensor to form a universal proximity sensing solution, thus eliminating the shortcomings of  both sensor types. According to the specs, though,  the proximity sensing capabilities on this one turned out to be almost useless. 10 to 20cm (4" - 8")? Pfft...

Still, APDS-9960 looked promising, so I got myself a breakout board. Sparkfun makes them, and as usual, the cheap knock-offs are in place as well.  Ten times as cheap, to be precise.

Sparkfun sensor, 15USD No name sensor, a little under 2USD.
See any difference in layout? Me neither.

So I quickly drew up a simple testing set-up with one (1) helping hand, one (1) APDS-9960 and one (1) Arduino Uno modified for 3.3V operation. Now, the last thing is not something everyone has in their drawer, so any 3.3V powered microcontroller will suffice. In case you DO have a spare Arduino Uno and want to have one that's 3.3.V compliant handy, you can follow these instructions on adafruit's blog.

As for the code, I'm just uploading Sparkfun's stock examples for this sensor. Those can be downloaded here or via Arduino library manager.

Here's me trying the sensor out and showing a simple contraption you can use to improve color sensing:

And here are some more detailed pics of the black box:

White LED and APDS-9960 visible through the slit.

LED's beam is shielded (I want to say focused but that's not what's happering here) from the sensor and its surrounding by a piece of heat shrink tubing.


This part can definitely be included in any maker's storage cabinet solely because of its versatility.

  • Gesture sensing: 6 gestures- up, down, left, right, near and far. Making fancy handwave-activated desk lamps and smart mirrors just got easier.

  • Proximity sensing: the useful range of APDS-9960 is even a bit wider than specifications allow for - about 7 to 25 cm (3 to 10 inches), but that's still less than any downbeat ultrasound sensor can put out.
    Additionally, the sensor's proximity units are highly dependent on ambient light levels. Hence you can't use it in applications where you want your measurements to be reproducible across multiple conditions (that is, virtually any application).
    To make my point, I measured the distance to a cardboard box in two different settings:
    1. Brightly lit scene:

    2. Dim scene:

  • See? Slightly different lighting produced drastically different results for the same distance (20cm.)

  • Ambient light sensing: this sensor's light sensing pleasantly surprised me with high resolution: starting with 0 for pitch black surroundings, it tops out at around 25-30k units with light shining close to the sensor. That means that even tiniest variations in light levels can be measured with this thing.

  • Color sensing: it just works and that's about as much I as I can demand from an RGB sensor with this price tag. Black box with internal lighting separates ambient colors from the object we want to determine color of. This simple trick drastically improves color sensing at little to no additional cost. Because of this, APDS-9960 just became a jellybean part for color sensing in my book.