APDS 9960 problems with gesture sensor example sketch

Thread Starter

Big Sammy

Joined Jan 28, 2012
Hi...I had posted this, but with an incorrect title....I'm trying to use a APDS 9960 sensor. I have it connected to both an Arduino Uno and Nano. I have two different sensors...a sparkfun one and another one...not sure of brand name, but it is purple.
When connecting the purple one, everything works...all the example sketches work flawlessly, except the gesture sensor example. The sensor initializes correctly, begins to work, but will not recognize any gestures.
The Sparkfun sensor reports an initialization error.
Anybody have similar experience with these sensors? Any suggestions to getting the gesture sensor example sketch to work?


Joined Apr 11, 2010
Hi! I have a couple of questions.

The APDS 9960 is a 3.3V module. The Uno and Nano are 5V boards. Are you powering the sensor with the correct voltage? Are you level shifting the IO?

What libraries are you using for the two sensors and where did you get them? For example, the Sparkfun sensor has A download link for their library. Please note that the Sparkfun sensor requires the Sparkfun library.

Secondly, are you using sample sketches for both sensors? Can you post the two example sketches for me to examine?

Thread Starter

Big Sammy

Joined Jan 28, 2012
Hi...on both boards the sensor is connected to the 3.3v pin. I'm using the Sparkfun library from Github. I'm using the same sketches for both sensors....
This is the gesture test example sketch from the Sparkfun library that I'm using for both sensors....
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014

Tests the gesture sensing abilities of the APDS-9960. Configures
APDS-9960 over I2C and waits for gesture events. Calculates the
direction of the swipe (up, down, left, right) and displays it
on a serial console.

To perform a NEAR gesture, hold your hand
far above the sensor and move it close to the sensor (within 2
inches). Hold your hand there for at least 1 second and move it

To perform a FAR gesture, hold your hand within 2 inches of the
sensor for at least 1 second and then move it above (out of
range) of the sensor.

Hardware Connections:

IMPORTANT: The APDS-9960 can only accept 3.3V!

Arduino Pin  APDS-9960 Board  Function

3.3V  VCC  Power
GND  GND  Ground
A4  SDA  I2C Data
A5  SCL  I2C Clock
2  INT  Interrupt

Include Wire.h and SparkFun_APDS-9960.h

Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V

This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!

Distributed as-is; no warranty is given.

#include <Wire.h>
#include <SparkFun_APDS9960.h>

// Pins
#define APDS9960_INT  2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

void setup() {

  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);

  // Initialize Serial port
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // 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!"));
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
  Serial.println(F("Gesture sensor is now running"));
  } else {
  Serial.println(F("Something went wrong during gesture sensor init!"));

void loop() {
  if( isr_flag == 1 ) {
  isr_flag = 0;
  attachInterrupt(0, interruptRoutine, FALLING);

void interruptRoutine() {
  isr_flag = 1;

void handleGesture() {
  if ( apds.isGestureAvailable() ) {
  switch ( apds.readGesture() ) {
  case DIR_UP:
  case DIR_DOWN:
  case DIR_LEFT:
  case DIR_RIGHT:
  case DIR_NEAR:
  case DIR_FAR:
Moderators note : used code tags


Joined Apr 11, 2010
But what about your I2C pins? Since you are using the Uno and Nano, they will produce a 5V signal. The sensor is a 3.3V module, so I would expect that 5V I2C signals may not work.

Even the example sketch on the Sparkfun site says
IMPORTANT: The APDS-9960 can only accept 3.3V!
Note that the example sketch uses a 3.3V Arduino Pro Mini, which is a 3.3V board.