SparkFun RGB and Gesture Sensor - APDS-9960

This is the SparkFun RGB and Gesture Sensor, a small breakout board with a built in APDS-9960 sensor that offers ambient light and color measuring, proximity detection, and touchless gesture sensing. With this RGB and Gesture Sensor you will be able to control a computer, microcontroller, robot, and more with a simple swipe of your hand! This is, in fact, the same sensor that the Samsung Galaxy S5 uses and is probably one of the best gesture sensors on the market for the price.

The APDS-9960 is a serious little piece of hardware with built in UV and IR blocking filters, four separate diodes sensitive to different directions, and an I2C compatible interface. For your convenience we have broken out the following pins: VL (optional power to IR LED), GND (Ground), VCC (power to APDS-9960 sensor), SDA (I2C data), SCL (I2C clock), and INT (interrupt). Each APDS-9960 also has a detection range of 4 to 8 inches (10 to 20 cm).

  • Operational Voltage: 3.3V
  • Ambient Light & RGB Color Sensing
  • Proximity Sensing
  • Gesture Detection
  • Operating Range: 4-8in (10-20cm)
  • I2C Interface (I2C Address: 0x39)

SparkFun RGB and Gesture Sensor - APDS-9960 Product Help and Resources

Interactive Smart Mirror

February 8, 2016

Build a smart mirror that displays weather data using the Intel® Edison.

APDS-9960 RGB and Gesture Sensor Hookup Guide

November 6, 2014

Getting started guide for the Avago APDS-9960 color, proximity, and gesture sensor.

Customer-created Library for the Windows 10 IoT Core

One of our awesome customers has written some code for using this Gesture Sensor with the Windows 10 IoT Core here. There is no C# library so the customer converted it from the C++ library and added a helper to use it.


Detection Issues while Standing in Front of Sensor

If you are having trouble detecting gestures while standing in front of the sensor try this tip.

In the Arduino driver, the enableGestureSensor method set the IR LED to a 300% boost. Change it to 100%, and now you should be able to stand in front of it, and it will detect all the gestures when your hand is within 10-20 cm. Edit this line: (setLEDBoost(LED_BOOST_100)) in this repository


Custom Gestures Help

You are not able to have custom gestures using the sensor by itself. The sensor is able to recognize basic gestures as listed in the Supported gestures section of our Hookup Guide.

You could use an Arduino microcontroller for a more complex sequence of gestures. The best would be to use the reference language and the example code for gestures to write condition statements over a period time. The condition statements would check if you swipe right and up. Try using boolean values after the sensor recognizes the gestures and changing it to TRUE if the gesture is met within a certain amount of time. You can write a counter to keep the gestures within a certain time window. If the counter exceeds a certain value, you could reset the boolean values. Once the two gesture conditions are met in the if() statement, the result would be to make a pin turn HIGH using the digitalWrite() function.

If you require a certain sequence (for example: to swipe right and hover up), try using additional values to keep track of what gesture was used first. You would have to use some more condition statements (or add an additional condition) to determine if you are using the correct gesture sequence.


Core Skill: Soldering

This skill defines how difficult the soldering is on a particular product. It might be a couple simple solder joints, or require special reflow tools.

1 Soldering

Skill Level: Noob - Some basic soldering is required, but it is limited to a just a few pins, basic through-hole soldering, and couple (if any) polarized components. A basic soldering iron is all you should need.
See all skill levels


Core Skill: Programming

If a board needs code or communicates somehow, you're going to need to know how to program or interface with it. The programming skill is all about communication and code.

3 Programming

Skill Level: Competent - The toolchain for programming is a bit more complex and will examples may not be explicitly provided for you. You will be required to have a fundamental knowledge of programming and be required to provide your own code. You may need to modify existing libraries or code to work with your specific hardware. Sensor and hardware interfaces will be SPI or I2C.
See all skill levels


Core Skill: Electrical Prototyping

If it requires power, you need to know how much, what all the pins do, and how to hook it up. You may need to reference datasheets, schematics, and know the ins and outs of electronics.

2 Electrical Prototyping

Skill Level: Rookie - You may be required to know a bit more about the component, such as orientation, or how to hook it up, in addition to power requirements. You will need to understand polarized components.
See all skill levels


Comments

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Member #1525649 / about 4 years ago * / 1

    I am designing a PCB that requires both a gesture sensor and ambient light sensor. The purpose of the ambient light sensor is to control the brightness of my LED. Can I just use the APDS9960 for both or will I have to get a separate ambient light sensor like the TEMT6000?

  • Member #1457730 / about 5 years ago / 1

    I am looking for ways to connect upto 12 sensors into a single teensy. is there any way to do that with I2C addresses or any suggestions on a work around?

  • Member #1440783 / about 6 years ago / 1

    Forgive me if this was asked before but other than a few extra inches of range, what does the ZX Distance and Gesture Sensor have over this?

    • The ZX Sensor gives you a reading in 2 dimensions of the detected object: how far above the sensor and how far side-to-side from the center. The APDS-9960 does not really give you distance information in any dimension but is better at detecting gestures (swipe left, swipe up, etc.), and it comes in a smaller package.

  • balam / about 6 years ago / 1

    for Teensy . here is the solutions https://forum.pjrc.com/threads/32286-APDS-9960-with-teensy

  • nsa / about 7 years ago / 1

    I'm trying to work with the gesture example and the arduino 101... does not work.. anyone with any solution?

  • Member #645021 / about 7 years ago / 1

    I'm new to the hobby. Is there a port of this to python and use with raspberry pi? It'd be great to see a tutorial on how to get these components up and running on that platform.

  • Member #923091 / about 7 years ago / 1

    Hi, does it work in the dark? Thanks

    • The proximity and gesture sensing should, yes. The sensor emits infrared light and looks for reflection. The RGB sensor detects wavelengths of light, so I would not expect color sensing to work in the dark.

  • MrGiskard / about 7 years ago / 1

    Hi, I'd like to clear something up with regards to the published specs for the sensor.

    The range of the sensor here is given as 10cm to 20cm (I use metric as I'm from a European country) but on other sites that also sell boards containing this chip the range is given as 0-100mm (i.e 10cm).

    Can you please clarify this confusing set of figures? I'm planning to use the sensor to pick up hand swipes near an installation and I need to know what is the minimum and maximum distance that people need to keep their hand at for this to work

    • 10-20 cm is what I found to work for picking up gestures when the LED current was set to maximum (100mA) and gesture GAIN set to 4x, which are the defaults in the Arduino library. 20cm is likely the maximum you're going to get out of the sensor, but you can play with the LED drive current and GAIN settings to get a lower minimum (which will also likely lower the maximum). Hope that helps!

      • MrGiskard / about 7 years ago / 1

        So if I understand it correctly, if the distance is less than 10cm the swipes won't register?

        • Not necessarily. If you reduce the LED strength and GAIN, you might be able to detect gestures less than 10cm. However, it means that the maximum will be reduced as well.

          • MrGiskard / about 7 years ago / 1

            Yeah, I meant with the max LED strength and GAIN.

            So to summarise, in general the sensor will need at least a few cm lead space before it can register movement yes?

  • Member #898019 / about 7 years ago / 1

    Hello, Great product! I am able to make all the examples work except the gesture sensor. It is not picking up any gestures. I had a doubt in the source CPP file on Github on line 544. ProcessGestureData is only true for near and far dir state. So my question is why does is it only try to detect near and far gestures?

    • Hi! sorry to hear you are having issues. The sensor should be able to detect left, right, up, down swipes in addition to "near" and "far," as you see in the video. I recommend contacting Tech Support to help you with setting up and testing the sensor.

      • Member #898019 / about 7 years ago / 1

        Thanks for the reply! I was able to solve it by changing the LED BOOST current to 100 mA. I am not sure why I had to do it, but I read it on esp8266 forums.

  • Can I use the Gesture, Proximity, and Color sensing simultaneously???

    • In theory, yes. However, I've run into some issues where trying to compute gestures would cause prox and color sensing to hang. This is likely due to my 328p running out of resources, so I recommend a beefier processor (e.g. SAMD21) if you want to sense all 3 at once.

  • Member #854583 / about 7 years ago / 1

    In my Case I ordered two sensors, one was wired while it was plugged in to the machine and load the Gesture Test example without any problem it worked. but after a 10 min of time suddenly it stopped showing directions. only showing This, SparkFun APDS-9960 - GestureTest APDS-9960 initialization complete Gesture sensor is now running So i connected the second sensor. But same problem. So i tested for Other examples as well, proximity sensor,color sensor they were all working fine. Only Gesture Test is not showing directions. anyone can help me to troubleshoot.

  • Member #615079 / about 8 years ago / 1

    Has anyone encountered the issue that the sensor was reporting gestures even if there are none? I had everything working well until I stopped getting gestures events... connecting a logic analyzer I found out that the FIFO overflow flag is being set without anything moving. The interrupt signal goes low shortly after initialization and never goes back high again. The FIFO never gets empty regardless of how long I read out data.

    Thanks!

    • I ran into this problem a while back when I was writing the library, but I can't remember what caused it. I think it had something to do with setting certain bits in the config registers. Is this happening with the GestureTest example in the library?

  • Member #834588 / about 8 years ago / 1

    This sensor is now supported by B4R (a free alternative development tool for Arduino): https://www.b4x.com/android/forum/threads/rapds9960-gesture-sensor.70781/

  • Member #803590 / about 8 years ago / 1

    ShawnHymel,

    I was able to use another wire library that added the timeout needed for when the device is not plugged in properly or there is something laying over it on boot up.

    Message #11 on this thread (for a teensy at least): https://forum.pjrc.com/threads/24487-wire-endTransmission()-hangs-if-it-can-t-connect-with-I2C-slave-device?highlight=wire+timeout

    My question to you is how do we add new gestures? It’s implied that we can and the Seeedstudio Grove product allows for clockwise and counter-clockwise gestures that I would like to add.

    • Sadly, I can't quite tell what sensor the Gesture R boards are using. It looks very similar to the APDS-9960 but not quite the same.

      To add your own gestures, you will need to modify the library. I recommend forking the GitHub repo and taking a look at SparkFun_APDS9960.cpp.

      In the processGestureData() method, you'll find how gestures are being calculated. Keep in mind that this code was based on sample code provided by Avago.

  • Member #804923 / about 8 years ago / 1

    Any one know if I can somehow increase the range for detecting gesture? My rough estimate is that the device can detect gesture at around 10cm away. Or maybe there is a different product that has longer range?

    • The gesture settings by default in the library are set to almost maximum. You could get a tiny amount of range by changing the GGAIN setting from 4x to 8x. I also recommend checking out the ZX Sensor, as it gets more range, but only detects gestures across 2 axes.

  • Member #803590 / about 8 years ago * / 1

    I'm having an issue NOT initializing my apds-9960. Yes, I wrote that correctly :) I would like to have an option of using a rotary device or the apds-9960 in my sketch. If the apds-9960 is disconnected then my app hangs on the apds.init() command... how do I get this routine to time out after a certain amount of time so my sketch can proceed? Additionally I am getting occasional freezing when you wave your hand too fast. I am using 1.4.2 on an arduino. Please help, this is going on a car and I wont have a way to reboot it, I need it stable.

    • From what I can tell, the Arduino command Wire.endTransmission() actually causes the hang, and the APDS-9960 library is based on the Arduino Wire library. You could re-write the I2C portions of the APDS-9960 library to use a different I2C library, if you wanted to add a timeout.

      Why do you need to disconnect the APDS-9960 from the circuit? The rotary encoder and APDS-9960 should be able to be connected at the same time.

      EDIT: Alternatively, you could not call apds.init() unless you are sure the APDS-9960 is present.

      • Member #803590 / about 8 years ago / 1

        I'm trying to keep the options of input open from either this device or a rotary encoder for my interface, not both. I'll have to come up with a way around this I guess. I didnt expect apds.init() to cause the application to hang if the device wasn't present. Was hoping for an exit code of some sort.

  • Member #803023 / about 8 years ago / 1

    I'd like to use this with my Netduino Plus 2. I am coding in Visual Studio 2015 in C#. Are there any References available for this? If not, then what is the best way of making this device easily accessible in C# using the Micro Framework?

    • You can take a look at the GitHub repository for the library to see how it was done in C++. Additionally, elijahparker in the comments has ported it to work for the Raspberry Pi, if that helps.

  • Member #796039 / about 8 years ago / 1

    Do you have any datum about the low power consumption of apds9960 ?

    • Nothing that I have measured personally, but the datasheet shows that the LED can sink 12-100mA (depending on the settings), which is likely to be the biggest current draw.

  • Member #760649 / about 8 years ago / 1

    I'd like to wire this up to my raspberry pi, do you have any suggestions ? I was using the suggestions on https://justinwoodman.wordpress.com/2014/11/15/using-the-apds-9960-rgb-proximity-and-gesture-sensor-with-the-raspberry-pi-2/ but the int line goes low and stays there. occasionally it will report something but 99% of the time nothing. The device shows up on the i2c bus at 39.

    • elijahparker / about 8 years ago / 2

      I just ported Shawn's Arduino library over to standard Linux today (I haven't updated the readme's and stuff yet) and it's working great! I'm using it on a custom A13 (ARM) board running Debian Jessie. Thanks Shawn for the great code! Very well documented and quite exhaustive -- that little chip's got a lot of registers! Here's the fork for Linux: https://github.com/elijahparker/SparkFun_APDS-9960_Sensor_Arduino_Library/tree/master/src

      • That's awesome! Thanks for doing that. I was working on a Linux port as well, but I found that the whole thing would crash randomly when the gesture and light sensors were running concurrently. I've not had a chance to fix it, so I was wondering if you ran into something similar.

    • You need to read the entire gesture FIFO on the APDS-9960 to get the interrupt to clear (go high). If you're having trouble with that code, I also recommend checking out the port to UPM of the APDS-9960 code I made: https://github.com/ShawnHymel/upm/tree/apds9960. It's really buggy (and I haven't tried it on the RPi yet), but it might be worth a shot.

  • Member #257312 / about 8 years ago / 1

    So I'm trying to use this sensor to turn on and off an LED strip for a kitchen lighting project, I only had a Due to give 3.3V but will wire up a level shifter when I get a chance and use a boarduino. I used pins 20 for SDA and 21 for SCL and used 3 for the INT pin. This didn't give a reading even though it initialised OK until I did this to the code, the digitalPinToInterrupt() is a recommendation of the Arduino site although I've never used it before. attachInterrupt(digitalPinToInterrupt(APDS9960_INT), interruptRoutine, FALLING); I changed this in both places of the gesture code and changed the line #define APDS9960_INT 3 // Needs to be an interrupt pin to get it away from the serial0 pins. It's working well but might need tuning. Hope this helps someone. Cheers Mike

    • Thanks for the heads up! I've added a note to the GitHub library to update attachInterrupt() to include the new digitalPinToInterrupt() function.

  • Member #753372 / about 8 years ago / 1

    Hi all, Just got this gem and used it successfully with my Photon Particle to detect gesture. It works like a charm. When I want to use the RGB sensor with the example provided it does not seems to give good results. Do I need to make some calculation to get the real R, G and B? I mean do I need to mix the ambiant light value with the R value to get the real R value?

    Thanks

    • I have not seen a good way to extract the exact R, G, and B light values (e.g. lux), unfortunately. You would probably need to mix the ambient light value, but the datasheet offers little help here. The best I found was "RGBC results can be used to calculate ambient light levels (i.e. Lux) and color temperature (i.e. Kelvin)" according to the datasheet.

      • Member #753372 / about 8 years ago / 1

        Thanks Shawn. I actually gave up trying to read RGB from the sensor. Will probably use another sensor for that purpose.

  • Member #371268 / about 8 years ago / 1

    Hi all, my question is if someone managed to operate the sensor behind glass or plastic . I 've tried various combinations ( even placing it behind the proximity sensors windows of a smartphone glass) and i have not success. I have studied the data sheet and I saw that the technical requirements are strict. Regards

    • In theory, it should work considering it uses IR light. The Samsung S5 (and I believe S6) have this exact sensor behind a plate of smartphone glass, and it definitely works. I'm hoping to test this with some clear and IR-transparent plastic in the near future, but if someone else has tried it, I would also like to know how they got it to work behind glass or plastic.

      • Member #753372 / about 8 years ago / 1

        Guys, I am struggling to hide the sensor. I tried to build a small case around it using a 3D printer but gesture detection don't work. It seems that it needs to have nothing in its near surroundings. I tried several cases with no success. I then thought of putting a glass on top of it. I tried with transparent plastic with no success neither. Has someone managed to cover in some way this sensor? Regards

        • My phone has an APDS-9960, which is covered by the front screen. That leads me to believe that it is possible to have the sensor covered, but it likely needs to be special IR-transparent plastic/glass.

          Edit: This is what I get for not reading my previous comment, so I just rehashed it :-/ The point I was trying to make was that special IR-transparent sheet is probably necessary.

  • Member #736781 / about 8 years ago / 1

    Hi, I've tried using the sensor and it works perfectly and detects gestures well. However, if left idle for a while (powered) and then used, there is a delay when detecting the first few gestures and sometimes it even freezes up. After a while it goes back to working properly. Would appreciate any helping understanding why this happens and what I can do to fix it.

    • How long do you need to keep it idle before the problem appears? If you reset the microcontroller without removing power, does it clear the issue (i.e. is it a problem with the APDS-9960 or the library)?

  • Member #684898 / about 8 years ago / 1

    Hi. Is there a way to make this sensor function in both reading proximity and gestures modes at the same time?

    • It should be possible. Keep in mind that there is only one interrupt pin, so that will go low if there is either a proximity or gesture event. You'll need to have some code differentiate between them.

      • Member #684898 / about 8 years ago / 1

        Thank you for quick respond. As I understand that is if I start both engines with interrupts flag. Probably there should also be possible to run, for instance, gesture handling interrupt-driven and manually check for proximity in the main loop. I'll try to make it work these ways.

        • Member #771817 / about 8 years ago / 1

          Hi Member 684898, I have the same question! I tried a lot, but I can't figure out how this should be done. If you know by now, I'd highly appreciate if you'd share you code ;-) Thanks in advance, Susan

  • Member #162165 / about 9 years ago * / 2

    Update: Got this working. I needed to bitshift left the address. Nice device so far. Tons of registers, this is a lot of work to set up but seems like it has a lot of uses after you get it dialed in.

    • nanogear / about 9 years ago / 1

      Are you coding on other platform than arduino?

      • Member #162165 / about 9 years ago / 1

        Propeller. Typically we do not bitshift the address when using 7 bit address scheme, only add 1 or 0 to change from write to read. In this case, the address needed to be shifted to work. But I have it working fine now.

  • nanogear / about 9 years ago / 2

    I hope it won’t takes too long to have a re-stock of this sensor...

  • Member #713985 / about 9 years ago / 1

    Hi, can we calculate lux and cct values using apds9960.

    • From the datasheet: "RGBC results can be used to calculate ambient light levels (i.e. Lux) and color temperature (i.e. Kelvin)."

  • Member #693417 / about 9 years ago * / 1

    Hi. I get two APDS 9960 RGB AND I TRY THE EXAMPLE IN THE HOOKUP GUIDE WITH AN ARDUINO MEGA 256 CONNECTING THE 3.3V PIN TO MY APDS. THIS IS PART OF MY CODE: // Initialize APDS-9960 (configure I2C and initial values)

    if ( apds.init() ) {

    Serial.println(F("APDS-9960 initialization complete"));
    

    } else {

    Serial.println(F("Something went wrong during APDS-9960 init!"));
    

    }

    I GET THE "Something went wrong during APDS-9960 init" MESSAGE ALLWAYS.

    I TRY BOTH SENSSORS AND I GET THE SAME MESSAGE.

    IF I DISCONNECT THE PWM 2 PIN I GET THE "NONE" CYCLE 6 TO 10 TIMES.

    CAN YOU HELP ME PLEASE ?

  • SynapseRapture / about 9 years ago / 1

    Is there any reason this would have issues on a Pro Mini @ 8MHz? I was thinking about using this as a primary input device in a wearables project, but I'm having issues getting reliable repeatability. Too often, the gestures aren't registered within a reasonable timeframe. Trying the sample sketch, sometimes I get a response ~5-10 seconds after a gesture, but more often it's not registered at all. Thoughts?

    • The sensor should work just fine on the Pro Mini at 8 MHz (I did the Hookup Guide with a Pro @ 8 MHz, which is just about the same thing as a Pro Mini). Reading gestures should have less than a second delay, so it sounds like there is an error with the sensor or Pro Mini itself. I recommend contacting our Tech Support team, who should be able to assist you.

      • Member #157709 / about 9 years ago / 1

        I had a 3.3V pro mini with a 3.3V regulator between the arduino and this board as well as another I2C sensor on the line (holdovers from an old setup). I found that all of the sketches worked (distance/color/ect) but the gestures didn't. It initialized fine but then didn't do anything. When I removed the other sensor and bypassed the 3.3V regulator it worked. Not sure why that would cause problems for only this sketch but may be worth looking at if your having issues with this sketch only...

        • The APDS-9960 can draw a good bit of amperage (over 100 mA) when it is in gesture mode. This can easily cause a power supply to dip in voltage and reset the APDS-9960 or the Arduino. If you have an oscilloscope, you can check this. To fix it, you can use a more powerful power supply, add a larger decoupling capacitor (> 100uF) near the APDS-9960, or lower the Gesture LED Power in the library.

  • I used this with a 5v Mega 2560 and a logic level converter. I followed the hook up guide and all the example code worked EXCEPT the "GestureTest" code. In other words, I could not get it to sense gestures even though it could sense color, proximity, and light level. I will keep trying.

    UPDATE: I re-positioned the sensor in different lighting conditions and gesture sensing works fine. Very accurate feed back from the example code.

  • Member #355011 / about 9 years ago / 1

    Does anyone know how one can map the ADC values to a lux value?

  • Member #688570 / about 9 years ago * / 1

    I'm trying to port the Arduino lib to a C lib for an AVR ATtiny85 which runs @ 1Mhz. Initialisation works ok and it catches the gesture and interrupt but always hangs for a while or gives me a "NONE" gesture, so readGesture() or further down does not work. Can the 1Mhz in stead of 16Mhz have something to do with this or what else?

    Another question is of how I know the sensor init is correct, with correct values etc.? Is this when both init_apds() and enableGestureSensor(1) return true? (seems there might be some small differences between commands sent by my ATtiny85 and Arduino)

  • Member #664576 / about 9 years ago / 1

    Hi - I'd like to use the gesture sensor with uView as a standalone package (with a 9v battery). The github demo code warns that the board needs 3.3v yet the uView provides only 5v. How could I replicate the demo setup without the FTDI breakout box? I'm using the uView programmer. I would like to avoid a level shifter as that requires separate power supplies for 3.3v and 5v.

    • If you take a look at the Simple Sketch, I have the battery boost converter board set to 3.3V, which runs both the MicroView and the APDS-9960. However, the MicroView uses a 16MHz, which isn't really supposed to be run at 3.3V. It works, but it's not super recommended :)

      • Member #664576 / about 9 years ago / 1

        Thanks - I assume you are relating to this sketch https://github.com/sparkfun/simple_sketches/blob/master/apds9960/apds9960.ino If I were to use the Microview USB programmer (for power supply) with Microview and APDS-9660 or just the Microview+APDS-9660 combination with 9V battery, is there a way to set power to 3.3V?

        • Correct. That Sketch is the one used in this video: https://www.youtube.com/watch?v=OS36IdgpEIo

          The problem with using the MicroView USB programmer or just the MicroView is that 3.3V is not broken out to one of the pins. You will either need to find where there is a 3.3V line on the MicroView or USB programmer and solder a wire to it to feed to your APDS-9960 or use a separate power regulator (e.g. buck converter) to get the 9V down to 3.3V.

  • Member #670247 / about 9 years ago / 1

    I've been playing around with this Gesture Sensor, but I seem to be running into an issue. There are certain cases when I've attached the sensor for FALLING edge, and the sensor reads a gesture , the INT pin remains at LOW 0V, which prevents it from reading anymore gestures. I've tried unattaching and reattaching the pin after each interrupt, but this does seem to work either. Anyone one have an idea of why the INT pin stays stuck at low?

    • Does the interrupt work for other functions? Does the ProximityInterrupt example work for you?

      • Member #670247 / about 9 years ago / 1

        I've tried the sample gesture code on github, and that worked without issues. But when I tried to slightly modify the code, I had issues with the INT pin getting stuck at low. Right now I have a simple code to continuously loop and increment a counter. Using the same interrupt code in the github file, the interrupt gesture button decrements the counter when when it catches a falling edge. I can paste in the code if it'll help with troubleshooting.

        • Yes, please paste in your code. That will help us troubleshoot the problem.

          • Member #670247 / about 9 years ago * / 1

            .

            • Because the system doesn't handle code so well, I recommend pasting the code into something like a gist to make it easier to read: https://gist.github.com/ShawnHymel/65cd4c1c1bbb097ab62e

              A few things I noticed:

              • You are waiting 5 seconds every time you receive an interrupt. The INT pin, I believe, will stay low until you call apds.readGesture(), which means that the INT pin will be low for 5 seconds before you actually read anything from the sensor. Can I ask why you need that delay?

              • Your "break;" line is inside of the if statement, which means that you are actually executing both case 'R' and case 'X' unless you see an interrupt.

              • Member #670247 / about 9 years ago / 1

                I was banging my head trying to figure out why the code wasnt working, and I realized that the handlegesture() function has to be called when interrupted otherwise the INT pin wont be brought back to 3.3V. I made a simple counter code to test this out. https://gist.github.com/jkredz/4a28caddb533796a4410. Detaching and reattaching the interrupt pin doesn't bring the INT pin back.

                This is probably not the intent of the gesturesensor, since you probably want to call the function when an interrupt is called, but I was testing a code where I had an event which I didn't want to register the gesture readings or interrupts. Using a combination of noInterrupts()/Interrupts() or detach/attach during this period didnt work either, as it still registers an interrupt and keeps the INT pin low until readGesture is called again. https://gist.github.com/jkredz/133c888924b2425e4a16

                • This is correct and works as intended. The APDS-9960 sensor brings the INT pin low until its FIFO is read (e.g. using the readGesture() method).

                  *EDIT: Can you explain what you are trying to do? You could, for example, call handleGesture() and just ignore the results if all you want to do is increment a counter.

                  • Member #670247 / about 9 years ago / 1

                    At the moment the interrupt increments a counter for the handle gesture function. The handle gesture function then determines the gesture, increments another counter, and vibrates a motor. I can take out the vibrate motor code, but is there a way to re-enable the pin without calling the gesture function?

                    Thanks Shawn!

                    • Not without modifying the library. You have to read the FIFO from the IC for it to clear it's interrupt pin. Right now, the handle gesture function is the only thing that does that.

                      • Member #670247 / about 9 years ago / 1

                        Ah I see. Any way to adjust the sensitivity of the gesture range as well (reducing the the range to register gestures < 5 inches etc...) or would I have to modify the library as well?

                        • That would require modifying the library, but it's not too bad. In SparkFun_APDS9960.h, there is a list of constants (/* Default values */) where you can play with the LED strength and gain during gesture sensing. Specifically, look at DEFAULT_GGAIN and DEFAULT_GLDRIVE. By adjusting those values, you can reduce the range and sensitivity.

        • Member #670247 / about 9 years ago / 1

          I've also tried to detach and reattach the interrupt button to see if it would get the INT Pin back to 3.3V, but that didnt work either.

  • nanogear / about 9 years ago / 1

    I am translating the libraries of the APDS-9960 sensor from Arduino to a PIC from MICROCHIP. If someone is interested and want to use the code please just let me know.

    • Member #657496 / about 9 years ago / 1

      I use flowcode5 on a microchip ic . I am interested in your librarie . Can I use it.

      • nanogear / about 9 years ago / 1

        For sure... please allow me to finish it, ok? I will let you know!

        • Member #688570 / about 9 years ago / 1

          readGesture Did you already ported the libs to pic yet? I'm interrested in that code! :)

  • Member #637726 / about 9 years ago / 1

    I need to use color sensor using apds9960. However i think am not getting true color values, what kind of illumination light is needed and to what number of bits each color is represented and how to map them to 8-bit range. Thanks

  • Member #637726 / about 9 years ago / 1

    I need to use color sensor using apds9960. However i think am not getting true color values, what kind of illumination light is needed and to what number of bits each color is represented and how to map them to 8-bit range. Thanks

    • nanogear / about 9 years ago / 1

      If you are using a "white" LED, then the color values are not correct. Try using a small lamp that have phosphorus inside the glass

  • mrbbp / about 9 years ago / 1

    can't have a gesture detection! All message said it's good but no detection. I've try the proximity sketch and i've good feedback values. i use a mini pro in 3.3V. I've try to change interrupt on pin 3 (with attachInterrupt(1,inerruptRoutine, FALLING);) but same pb...

    • JPB / about 9 years ago / 1

      Hello, were you able to make the gesture sensor APDS9960 work with the Arduino Pro Mini 3.3V? I have the same issue that you had 4 months ago. I think it is something related to the interrupt pin 2.

    • mrbbp / about 9 years ago / 1

      I've tried with an other pro mini. and nothing better

      • It sounds like it could be an issue with the chip itself. Contact tech support and they will be able to help you. If it is the chip, they will be able to get you a replacement.

  • Ruphobia / about 9 years ago / 1

    Can this be used to gather range; i.e. a distance sensor? if so, what are the usable distance measurement ranges?

    • Yes, this will work as a simple distance sensor. I've been able to sense up to about 8 inches and down to about 1-2 inches away from the sensor.

      • How accurate is the distance measurement? Can I edit the library to increase the range?

        • It's really not very accurate (I recommend the IR distance sensors or the ToF range finder for much better accuracy). You can adjust some of the parameters like LED intensity and Gain in the library to get more range.

      • Ruphobia / about 9 years ago / 1

        Excellent; thanks.

  • Member #641502 / about 9 years ago / 1

    Hi Guys,

    This is awesome sensor. But i noticed that. With the sparkfun code i cant detect range from 0-100mm. I think its starting from 10mm. Any way to get the range from 0-100mm?

    • Not that I am aware of. You need a little bit of distance from the IR transmitter to the reflector (e.g. your hand) so that the sensors can process the direction of the reflector. If you manage to get it working with 0 distance, definitely let us know!

  • awin206 / about 9 years ago / 1

    Whats the best light set up to accurately read the colors. If some of you could give me some suggestions on how to build around the sensor that'd be greatly appreciated. For example, lets say I'm trying to read the color of a skittle. If I put it too close, it won't work. Do I need a light to be shining on the object? Any help would be greatly appreciated.

    Cheers.

    • nanogear / about 9 years ago / 1

      Hello, yes, you need a source of light that reflect the sample you want to sense. White led light is not the best you can use.

  • ltc / about 9 years ago * / 1

    I'm trying to use the Example Code but everything the serialmonitor displays is "none". Anyone can help me with that issue?

    Thanks!

  • Member #559398 / about 9 years ago / 1

    I have used bi directional level shifter with arduino uno and apds 9960. But I see that the Gesture test example gets stuck in the infinite while 1 loop inside readGesture() library call. Has someone faced this?

  • I'm intrigued, the IR wavelength listed on the datasheet is 950nm which can theoretically pass through plastic. Is there any chance you could experiment and see if it's possible to detect gestures through a thin 3D printed PLA sheet?

  • Member #40223 / about 9 years ago / 1

    Can I get the code for the MicroView Demo somewhere?

  • Madbodger / about 9 years ago / 1

    If you end up revising the board, would it make sense to put a cut pad across the connection between the LED drive output and the LED cathode so people could cut it if they wanted access to both LED pins?

  • bunnyHat / about 9 years ago / 1

    I want to use Arduino Uno with ADPS9960, however, I only have BOB11978 old school level converter. It has two bidirectional channel. and another two high to low channels. However, I think SDA, SCL and INT all need to be converted from LOW to HIGH. In the end, I connect SCL directly to A5 without converting and SDA&INT go through the two bidirectional channels. And it is working now ! :). Will this harm ADPS sooner or later, if so, which one out of the three SDA, SCL, INT could I work around by connecting directly from Arduino UNO. Thanks! Impatient student with shallow pocket

    • PointyOintment / about 9 years ago / 1

      The datasheet says INT is an open drain output, so it'll drive the line low, but not high. Therefore, it needs a pull-up resistor—the datasheet suggests 10 kΩ. Connect that to the 3.3 V supply. That should be high enough for the Arduino to see a high signal without needing the level converter. (The ATmega datasheet (Fig. 35-25 on page 600) says that the threshold voltage is ~2.65 V when running at 5 V.) If you connect the pull-up resistor to 5 V, you could damage the sensor—the datasheet says the max voltage allowed to be applied to INT is 3.8 V (page 3, second table, Vout).

      I'm not sure why it's working with the configuration you've got. I would connect INT directly, with a pull-up, as I said above, and SDA and SCL through the level converter's bidirectional channels (or just SDA through a bidirectional channel and SCL through a high→low channel, because SCL is a unidirectional line).

    • animan / about 9 years ago / 1

      Power the ADPS9960 using 3.3V power from Uno. Connect two 1K resistors in series when you connect the SCL and SDA lines. No resistors should be needed on the INT line since it is an output from the ADPS9960.

    • timknecht / about 9 years ago / 1

      Convert SDA and SCL. INT should work unconverted as 3.3V would be high enough for a 5V logic high or if it pulls to GND its also a 5V LOW.

  • Member #617773 / about 9 years ago / 1

    Can it be used with ambient light?

  • gumush / about 9 years ago / 1

    Can it be used for just proximity to detect reaction times fast as miliseconds ? How can i find rise and fall times for detecting proximity like photodiodes ?

    • I don't quite understand what you are looking to do, so my apologies if this does not help.

      You can get a proximity response from the sensor that is on the order of about a millisecond, but I would not recommend it for precise timing. You could also change some of the parameters regarding the pulse lengths for proximity and gesture to better measure the response time. I recommend looking at the datasheet to see what registers you need to adjust.

  • Anyone get a reading on how fast you can swipe and it will register under normal light conditions?

    • I would say it's a medium to slow swipe. If you swipe quickly, the sensor will miss it. Additionally, there is a bug in the Arduino software right now that causes the program to freeze if you try to swipe your hand over the sensor very quickly, back and forth. I'm hoping to take a look at it this weekend.

      • nanogear / about 9 years ago / 1

        Please let us know when the bug is corrected. This sensor is awesome!

        • Done! I forgot to disable interrupts in the demo code, which would cause the program to not interpret gestures. It should no longer crash with fast swipes now.

          • mike41325 / about 9 years ago / 2

            Maybe you have already fixed this and I just don't know where the most recent code is, but I downloaded the library for this a few days ago and couldn't get the gesture sensing to work. I started comparing the interrupt code to some of the other examples and noticed that pinMode(APDS9960_INT, INPUT); was missing from the setup function in the gesturetest example. Adding that in fixed my problem.

          • nanogear / about 9 years ago / 1

            ShawnHymel you're the best!

  • rstaph / about 9 years ago * / 1

    Can you make the next version with the capability to put the capacitor on back? (or the sensor?) For example, have a set of pads on the back so someone could move the capacitor to the back side so the sensor can be a little more flush to whatever it is being mounted to?

    • Not a bad idea. We generally try to keep all components to one side for ease of assembling, but having optional pads on the back is a good idea.

      • rstaph / about 9 years ago / 1

        I guess I could just unsolder the cap anyway and put one in behind the board, with the leads insulated and reaching around...

    • nanogear / about 9 years ago / 1

      Or maybe a smaller capacitor

      • I tried :(

        I started out with a 10uF cap and began working my way up. The problem is that whenever the sensor enters into "gesture mode" (i.e. there's an object above the sensor, and the sensor starts recording the object's motion), the LED blasts IR light (think 100+mA). That initial rush of current causes the voltage to sag just enough to mess up sensing unless the sensor is either A) right next to the power supply (not 6 inches away connected by wires) or B) has a rather large capacitor next to it to supply instantaneous current. I tested several capacitors and discovered that I could not really go below 100uF. That massive tantalum capacitor was the smallest package available for 100uF.

        • EvPlasmaMan / about 9 years ago / 3

          One thing I sometimes do when faced with this problem is use several smaller caps in parallel. The nice thing about this is you get a better ESR. The down side of course is you do use more board area but you might be able to get a better height profile.

        • nanogear / about 9 years ago * / 1

          Woow, now I understand why. Then, the optional pads on the back just behind the sensor can be a good rstaph idea after all!!

          Thank you for explain this to us ShawnHymel

  • dominicv / about 9 years ago / 1

    To : Shawn, In viewing the recent presentation of the gesture sensor, I came up with a great use for it, HOME AUTOMATION, a couple of question are in order. The main use I have in mind is, room entering and exiting, in order to determine position, the questions, first in order to save on GPIO, is it possible to only use the IN and OUT direction, secondly, could this chip be used in a digital mode ( Like a switch ) as opposed to analog mode. I apologize as I am neither a programmer or an electronic person, so any layman term would be greatly appreciated.

    Regards

    Dom

    • Dom, the chip requires 3 pins from the microcontroller: SDA, SCL, and an interrupt. SDA and SCL are used for I2C, which is how the chip communicates (it's not one GPIO per gesture or anything like that). All of the gestures are handled in a microcontroller, so you would have to disable the other directions in code.

      In addition to gestures, you can also use the chip to detect proximity. When something gets close enough to the chip, it tells the microcontroller that something tripped its proximity sensor.

      Hope that helps!

      • AgustinGS / about 9 years ago / 1

        So you can't really daisy chain different of these with one uC for say a more "complex" direction sensing? since it uses SDA, SCL for I2C and uC usually just have 1 I2C interface what would you recommend to achieve this?

        Thanks

        • Ruphobia / about 9 years ago / 1

          I need 8 of these running on 1-I2C bus; I'm going to try this: http://www.digikey.com/product-detail/en/PCA9547BS,118/568-3379-1-ND/1125734.

          Should be able to getup all 8 working on 1 bus :)

        • You can daisy chain them, as I2C is a bus (i.e. you can connect multiple devices to a single I2C bus). However, you will run into a couple of problems:

          • Right now, the I2C address is hardcoded into the sensor, so you can only have 1 sensor per I2C bus
          • If you have sensors too close to each other, you will likely run into IR bleeding, where the infrared light from one sensor messes up the reading of another sensor

          • AgustinGS / about 9 years ago / 1

            ah, so the distance between sensors would also opaque each other's field of vision as a matter of speaking...

            its a shame, so many uses! so many possibilities ruined :(

            Thanks Shawn

            • Correct. You might be able to build an array of sensors if you can put some opaque material between the sensors to block IR bleeding. Don't give up yet! :)

  • Member #108924 / about 9 years ago / 1

    I couldn't tell from the datasheet what the range of processing time was for gestures. If very short (perhaps <100ms, which physiologically feels nearly "instant"), it seems like you could use one or more of these for an interesting musical instrument. Has anyone tested how short and consistent the processing time is? Thanks! Excited to see how people use this.

    • Member #353335 / about 9 years ago / 1

      +1 That is an excellent idea. Gesture to MIDI !!

      I guess you could also arrange these in a matrix (3x3) and get more complex gestures --like the way you can unlock some smartphones.. very exciting.

      • Member #353335 / about 9 years ago / 1

        Okay, I just saw Shaw's response. If there is the need for more complex gestures, it seems much simpler to have a matrix of individual IR LED, each one paired with an IR Receiver diode, and do the gesture recognition yourself --kind of the way you would programmatically determine the winner in a tic-tac-toe game.

    • As it turns out, much of the processing is done in the microcontroller (not the sensor). The sensor gives you reflected values from the IR levels, and it's up to the microcontroller to figure out how to interpret them into a "gesture."

      The bad news is that means it's a lot of work in software to sense a gesture. The good news is that it is possible to optimize the algorithm and put it on a faster microcontroller (like the mbed, Teensy, etc.) or even an FPGA to achieve the effects you want.

  • bunnyHat / about 9 years ago / 1

    Can I use Arduino Uno for this sensor since Uno has a 3.3V power?

  • nanogear / about 9 years ago / 1

    Dear Sparkfun.. Do you know if the Gesture control feature and the Ambience light sensor feature can be used simultaneously?

    • Yes, the gesture and color/ambient light sensor can be used at the same time. I noticed some slow down in the software when doing this, as the gesture sensing part requires a good amount of processing.

  • 172pilot / about 9 years ago / 1

    The "New Products" page that links to this says that it is the sensor used in the kohler no touch toilets.. Is that really true? If so, how is it sensing, with the sensor hidden inside the tank? I thought this was a VISUAL sensor, but if it can sense through some other means, maybe this could be an alternate input for my garage door opener, in case I forget my RFID chip??? (But, it would have to work from inside a box or behind the siding)

  • nsa / about 9 years ago / 1

    does it work with arduino?

    • Yes it does. The sensor uses the I2C protocol, which will work many microcontrollers, including Arduino. The library only supports Arduino right now.

  • nanogear / about 9 years ago / 1

    This is exactly what I was looking for...

  • Ogre / about 9 years ago / 1

    This. Is. AWESOME!

  • Member #448635 / about 9 years ago / 1

    I would love to see one of your new Simple Sketch videos showing this sensor in action.

    • In the works :)

      • Member #403458 / about 9 years ago / 1

        The video is great at showing the gestures in action, but is there anything planned to show color detection? I have a project in mind for this, but I'm not sure how well the color sense will work. Thanks.

        • We don't have anything planned to show color detection. I can definitely hold up various colored pieces of paper to the sensor and watch the output change, but I really can't say how accurate it is versus other color sensors.

    • nanogear / about 9 years ago / 1

      https://www.youtube.com/watch?v=OS36IdgpEIo

  • BradLevy / about 9 years ago / 1

    I'm curious - a quick search shows the APDS-9960 chip for sale thru Asia-Pacific and UK region distributors, but not US distributors. Anybody know the reason behind that? Patent issues?

    • bentwookiee / about 9 years ago / 1

      AVNET lists it, but isn't stocking yet, showing a 6 week lead time. I may ask our rep next time they come around, but I'm going to lead more towards a delay in distribution as opposed to any legal issues.

Customer Reviews

4 out of 5

Based on 8 ratings:

Currently viewing all customer reviews.

1 of 1 found this helpful:

Sensor works well, but someone wasn't thinking very hard.

Yes, and here's why. The sensor is 0.05" tall. If you want to flush mount it to a panel, the big cap is 0.12" high. The small R's and C's are about 0.025" tall. This makes it difficult to mount cleanly. The sensor should have been on the back where one could drill a small hole in the project box for it, and then epoxy/hot glue it in place.

OTHER than that, it works well, and the library is pretty good (except for not working on a Teensy, since the attachInterrupt() and detachInterrupt() calls are hard-coded to 0 instead of using digitalPinToInterrupt()).

1 of 1 found this helpful:

Protecting the APDS9960

Great product. I made an nice project with it. But my project is for outside use and I need to protect it. I read the datasheet for the APDS 9660 (page 18) and they suggest to cover it with a rubber with 2 holes. I must say that it really improve the detection of the gestures especially the NEAR and the FAR. They also suggest to cover it with a 1mm with a specific Makrolon or Lexan window. I cannot find any of these products on Internet. Anybody has any suggestion? Sparkfun rocks

0 of 9 found this helpful:

Could do without the interrogation

Did not like being interrogated what I was going to use this for 'and respond in a full sentence' before I could purchase this. Apparently it is NOT export restricted and I was asked due to a 'glitch in the system', I was told when I followed up on what that was about. Anyway. Not impressed. Can't help wondering why I was really asked.

I am sorry you had this issue while ordering from us. This problem has been corrected and won't happen again. Thank you for the feedback!

Worked Perfectly !

This sensor worked exactly as described to detect gestures. I was able to use the provided software library as a reference to help write a similar library in LabVIEW and use the sensor with a myRIO.

A joy to work with

The breakout board takes care of some wiring busywork. The APDS-9960 itself is marvelously documented (datasheet is clear, complete and one of the best I've ever seen). Documented features do what they say they'll do. And Sparkfun's existing Arduino library code is exquisitely well-commented and exhaustive—made a great launchpad to write my own (JS/Johnny-Five) support for the gesture sensor. One of the best complex multi-sensors I've ever worked with.

0 of 1 found this helpful:

BE Careful!

First I would like to say that these sensors are awesome, they can do soo much and they are very easy to use. But just as a warning, be very careful with them. if you are prototyping and have things wired up with a header and jumpers, if you are waving your hands around the sensor and you manage to knock the ground wire off of the sensor, it will never sense again :(

While working on a final Project for my embedded systems class this past semester, my partner and I found this out it a very hard way, the weekend before our project was due. luckily SparkFun and their Awesome!!! order fulfillment team were able to get an order for two more of them placed on Saturday ready for a 10am local pickup on Monday (the same Monday the project was due). you guys rock! these Sensors are AWESOME!!!

Easy device

Good documentation, easy device to be integrated in robot projects.

Nice sensor!

works very well with a raspberry pi. Sometimes the far and near gestures are a bit hard to achieve.