Hello,
I recently ordered the APDS-9960 gesture sensor, SKU SEN-12787. It appears that it is not working properly.
I modified the GestureTest.ino sketch provided by sparkfun as an example to troubleshoot, and the apds.readGesture() command seems to cause a very long delay or is non responsive. Sometimes so long that it fails to read the gesture. In the video posted on the product page, the response from the sensor was close to immediate. Delay with my sensor ranges between 30 seconds and 2 minutes. I provided a sample of the serial output below.
Tried both the 3.3V Pro Micro I purchased on the same order, and also with an Arduino Uno with the same results. Tried different breadboards and soldered onto an adafruit perma proto board to rule out any connection issues. Tried removing serial comms as well.
The other sample sketches I tried (such as proximity detection) seem to work fine. Only gesture detection seemed to be an issue.
followed the hookup guide here:
https://learn.sparkfun.com/tutorials/ap … okup-guide
Any idea what could be causing this? Is the sensor defective?
I also bought a ZX Distance and Gesture Sensor for comparison, and that one works great!
sample serial output w/ comments. notice the time between readGesture and the response in capital letters:
13:17:27.539 ->
13:17:27.539 -> --------------------------------
13:17:27.573 -> SparkFun APDS-9960 - GestureTest
13:17:27.607 -> --------------------------------
13:17:27.641 -> APDS-9960 initialization complete
13:17:27.674 -> Gesture sensor is now running
13:17:27.707 -> isGestureAvailable (no gesture performed, but there's still caused a delay during bootup)
13:17:27.741 -> readGesture
13:17:38.462 -> NONE
13:17:38.496 -> readGesture... done
13:17:38.496 -> isGestureAvailable... done
13:17:38.530 -> isGestureAvailable
13:17:38.564 -> isGestureAvailable... done
13:17:46.823 -> isGestureAvailable (swipe left, no delay in interrupt or isGestureAvailable, but reading the gesture took 1 min 45 sec)
13:17:46.823 -> readGesture
13:19:31.260 -> NONE
13:19:31.260 -> readGesture... done
13:19:31.294 -> isGestureAvailable... done
13:19:31.328 -> isGestureAvailable
13:19:31.328 -> isGestureAvailable... done
13:19:50.490 -> isGestureAvailable (swipe left)
13:19:50.523 -> readGesture
13:20:20.286 -> NONE
13:20:20.319 -> readGesture... done
13:20:20.319 -> isGestureAvailable... done
13:20:20.353 -> isGestureAvailable
13:20:20.386 -> isGestureAvailable... done
13:20:29.354 -> isGestureAvailable (swipe left)
13:20:29.354 -> readGesture
13:21:06.629 -> LEFT
13:21:06.629 -> readGesture... done
13:21:06.663 -> isGestureAvailable... done
13:21:06.697 -> isGestureAvailable
13:21:06.697 -> isGestureAvailable... done
code used for the above, from the sample sketch:
/****************************************************************
GestureTest.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
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
away.
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
Resources:
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.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - GestureTest"));
Serial.println(F("--------------------------------"));
// 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 ) {
detachInterrupt(0);
handleGesture();
isr_flag = 0;
attachInterrupt(0, interruptRoutine, FALLING);
}
}
void interruptRoutine() {
isr_flag = 1;
}
void handleGesture() {
Serial.println("isGestureAvailable");
if ( apds.isGestureAvailable() ) {
Serial.println("readGesture");
switch ( apds.readGesture() ) {
case DIR_UP:
Serial.println("UP");
break;
case DIR_DOWN:
Serial.println("DOWN");
break;
case DIR_LEFT:
Serial.println("LEFT");
break;
case DIR_RIGHT:
Serial.println("RIGHT");
break;
case DIR_NEAR:
Serial.println("NEAR");
break;
case DIR_FAR:
Serial.println("FAR");
break;
default:
Serial.println("NONE");
}
Serial.println("readGesture... done");
}
Serial.println("isGestureAvailable... done");
}