Follow us:-
0

ESP32 with APDS-9960 Gesture Sensor

  • 02-07-2025

The APDS-9960 is an advanced, compact sensor from Broadcom (formerly Avago Technologies) that offers multiple sensing capabilities in one chip. It is widely used in gesture recognition, proximity sensing, ambient light detection, and color sensing, making it highly useful for smart devices and human-machine interfaces (HMIs).


πŸ” Key Features of APDS-9960

Feature Description
Gesture Detection Recognizes hand gestures (up, down, left, right, near, far).
Proximity Sensing Detects how close an object is to the sensor (up to ~10 cm).
Ambient Light Sensing Measures surrounding light intensity (lux value).
Color Sensing Detects Red, Green, Blue, and Clear light levels.
Digital I²C Interface Communicates via I²C protocol, making it easy to interface with microcontrollers.
Compact Size Tiny module suitable for portable and embedded applications.

πŸ“¦ Built-in Components

  • IR LED (Infrared emitter)

  • Photodiodes for R, G, B, Clear

  • Gesture engine

  • ALS (Ambient Light Sensor)

  • Proximity sensor


πŸ“ Technical Specifications

Parameter Value
Voltage Range 2.4V – 3.6V
I²C Address 0x39 (7-bit)
Gesture Detection Range ~10 to 20 cm
Proximity Detection Range ~1 to 10 cm
Ambient Light Range 0 – 10,000 lux
Operating Temperature -40°C to +85°C

πŸ”Œ Pin Configuration

Pin Description
VIN 3.3V power supply
GND Ground
SCL I²C clock (connect to SCL of MCU)
SDA I²C data (connect to SDA of MCU)
INT Interrupt output (optional)

πŸ€– Applications

  • Gesture-based control (swipe to change songs, etc.)

  • Smartphones (auto-brightness, face detection)

  • Laptops/tablets (gesture navigation)

  • Smart appliances (touchless control)

  • Interactive displays and kiosks


🧠 How Gesture Sensing Works

  1. The IR LED emits light.

  2. Four directional photodiodes (up, down, left, right) measure reflected IR light from a moving hand.

  3. The internal gesture engine compares the light intensity across these directions to detect:

    • UP / DOWN

    • LEFT / RIGHT

    • NEAR / FAR

    •  

      πŸ“‹ Tips for Better Performance

      • Use dark background behind the sensor to reduce IR reflection.

      • Ensure adequate lighting (not direct sunlight).

      • Place sensor in open space, not recessed.

      • Gesture speed should be moderate (not too fast or slow).


      πŸ“¦ Available Libraries

      • SparkFun APDS-9960 Library (recommended)

      • Adafruit_APDS9960

      • PlatformIO and Arduino IDE compatible

               HOW TO OPERATE

/***************************************************************************
  This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor

  This sketch puts the sensor in gesture mode and decodes gestures.
  To use this, first put your hand close to the sensor to enable gesture mode.
  Then move your hand about 6" from the sensor in the up -> down, down -> up,
  left -> right, or right -> left direction.

  Designed specifically to work with the Adafruit APDS9960 breakout
  ----> http://www.adafruit.com/products/3595

  These sensors use I2C to communicate. The device's I2C address is 0x39

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Dean Miller for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

#include "Adafruit_APDS9960.h"
Adafruit_APDS9960 apds;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
 
  if(!apds.begin()){
    Serial.println("failed to initialize device! Please check your wiring.");
  }
  else Serial.println("Device initialized!");

  //gesture mode will be entered once proximity mode senses something close
  apds.enableProximity(true);
  apds.enableGesture(true);
}

// the loop function runs over and over again forever
void loop() {
  //read a gesture from the device
    uint8_t gesture = apds.readGesture();
    if(gesture == APDS9960_DOWN) Serial.println("v");
    if(gesture == APDS9960_UP) Serial.println("^");
    if(gesture == APDS9960_LEFT) Serial.println("<");
    if(gesture == APDS9960_RIGHT) Serial.println(">");
}

                   HOW TO OPERATE WITH SSD1306(OLED DISPLAY)

// UP → Green

// DOWN → Red

// RIGHT → Blue

// LEFT → Yellow

#include <Adafruit_GFX.h>              // Core graphics library for OLED
#include <Adafruit_SSD1306.h>          // OLED display library
#include <Wire.h>                      // I2C communication
#include "Adafruit_APDS9960.h"         // Gesture sensor library
#include <Adafruit_NeoPixel.h>         // NeoPixel (RGB LED strip) library

// Define NeoPixel settings
#define PIN_NEO_PIXEL 15               // GPIO pin connected to NeoPixel
#define NUM_PIXELS 10                  // Number of NeoPixels

// Define OLED screen settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1                 // Reset pin not used with this OLED

// Create objects for OLED, gesture sensor, and NeoPixel
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_APDS9960 apds;
Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(115200);               // Initialize serial monitor for debugging
  NeoPixel.begin();                   // Initialize NeoPixel strip

  // Initialize the APDS9960 gesture sensor
  if (!apds.begin()) {
    Serial.println("Failed to initialize device! Please check your wiring.");
  } else {
    Serial.println("Device initialized!");
  }

  apds.enableProximity(true);         // Enable proximity detection
  apds.enableGesture(true);           // Enable gesture detection

  // Initialize the OLED display
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // I2C address is usually 0x3C
  display.clearDisplay();             // Clear display buffer
  display.display();                  // Push the cleared screen to the display
  delay(1000);                        // Wait 1 second for display to stabilize
}

void loop() {
  // Read any gesture detected
  uint8_t gesture = apds.readGesture();

  // Handle UP gesture
  if (gesture == APDS9960_UP) {
    Serial.println("^");             // Print gesture to serial monitor
    display.clearDisplay();          // Clear previous content on OLED
    drawUpArrow();                   // Draw UP arrow on OLED
    display.display();               // Display the arrow

    // Light NeoPixels green one by one
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {          
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 255, 0)); // Green
      NeoPixel.show();
      delay(500);                    // Delay between lighting each LED
    }

    // Clear all LEDs after animation
    NeoPixel.clear();
    NeoPixel.show();
  }

  // Handle DOWN gesture
  if (gesture == APDS9960_DOWN) {
    Serial.println("v");
    display.clearDisplay();
    drawDownArrow();
    display.display();

    // Light NeoPixels red one by one
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(255, 0, 0)); // Red
      NeoPixel.show();
      delay(500);
    }

    NeoPixel.clear();
    NeoPixel.show();
  }

  // Handle RIGHT gesture
  if (gesture == APDS9960_RIGHT) {
    Serial.println(">");
    display.clearDisplay();
    drawRightArrow();
    display.display();

    // Light NeoPixels blue one by one
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 0, 255)); // Blue
      NeoPixel.show();
      delay(500);
    }

    NeoPixel.clear();
    NeoPixel.show();
  }

  // Handle LEFT gesture
  if (gesture == APDS9960_LEFT) {
    Serial.println("<");
    display.clearDisplay();
    drawLeftArrow();
    display.display();

    // Light NeoPixels yellow one by one (red + green)
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(255, 255, 0)); // Yellow
      NeoPixel.show();
      delay(500);
    }

    NeoPixel.clear();
    NeoPixel.show();
  }
}

// Function to draw an UP arrow on OLED
void drawUpArrow() {
  display.fillTriangle(64, 10, 44, 40, 84, 40, SSD1306_WHITE); // Triangle pointing up
}

// Function to draw a DOWN arrow on OLED
void drawDownArrow() {
  display.fillTriangle(64, 54, 44, 24, 84, 24, SSD1306_WHITE); // Triangle pointing down
}

// Function to draw a RIGHT arrow on OLED
void drawRightArrow() {
  display.fillTriangle(100, 32, 70, 12, 70, 52, SSD1306_WHITE); // Triangle pointing right
}

// Function to draw a LEFT arrow on OLED
void drawLeftArrow() {
  display.fillTriangle(28, 32, 58, 12, 58, 52, SSD1306_WHITE); // Triangle pointing left
}

 

ESP32 with APDS-9960 Gesture Sensor

Related Post

How do I run a script at Pico on boot?

How do I run a script at Pico on boot?

As per official documentation Step by step process for pico program run after power on:Save your pyt...

ESP32 Setup in Arduino IDE

ESP32 Setup in Arduino IDE

ESP32 Board are so popular? Mainly because of the following featuresLow-costBluetoothWiFiLow PowerDu...

Node MCU ESP8266 Setup in Arduino IDE

Node MCU ESP8266 Setup in Arduino IDE

Node MCU ESP8266 Board are so popular? Mainly because of the following features.Its true Arduino Kil...

ESP32 with L298N DC Motor Driver

ESP32 with L298N DC Motor Driver

πŸ”§ Basic IntroductionL298N is a dual H-Bridge motor driver IC that allows controlling the direction...

MotorBot with Esp32

MotorBot with Esp32

πŸ”§ Components Needed:ComponentQuantityESP32 Dev Board1L298N Motor Driver Module1DC Gear Motors (TT o...

ESP32 with ADXL335 Accelerometer

ESP32 with ADXL335 Accelerometer

The ADXL335 is a small, thin, low-power 3-axis analog accelerometer manufactured by Analog Devices....

ESP32 with Ultrasonic Sensor (HC-SR04)

ESP32 with Ultrasonic Sensor (HC-SR04)

🧠 What is an Ultrasonic Sensor?An ultrasonic sensor is a device that uses sound waves to detect how...

ESP32 with DHT11 Temperature & Humidity Sensor

ESP32 with DHT11 Temperature & Humidity Sensor

πŸ“Œ What is the DHT11 Sensor?The DHT11 is a basic, low-cost digital temperature and humidity sensor....

ESP32-Based Autonomous Fire Extinguisher Bot

ESP32-Based Autonomous Fire Extinguisher Bot

πŸ”₯ FIRE BOT – Bluetooth Controlled Fire Extinguisher RobotWelcome to the FIRE BOT project! This robo...

ESP32 with BMP180 Pressure & Temperature Sensor

ESP32 with BMP180 Pressure & Temperature Sensor

BMP180 Sensor: Digital Barometric Pressure SensorThe BMP180 is a digital barometric pressure sensor...

ESP32 with 1.8" TFT LCD Display (ST7735S)

ESP32 with 1.8" TFT LCD Display (ST7735S)

πŸ”§ 1. Hardware Overview: 1.8" TFT DisplayMost 1.8" TFT modules are based on the ST7735 driver and co...

Smart Display Interface Using SSD1306 OLED & ESP32

Smart Display Interface Using SSD1306 OLED & ESP32

The SSD1306 is a popular controller used in OLED (Organic Light Emitting Diode) displays, most commo...

ESP32 with Servo Motor

ESP32 with Servo Motor

A servo motor is a type of motor designed for precise control of angular position, making it ideal f...

ESP32 with Gravity Voice Recognition Module

ESP32 with Gravity Voice Recognition Module

The Gravity Voice Recognition Module is a user-friendly module developed by DFRobot that allows micr...

Smart Control: Stepper Motor with ESP32

Smart Control: Stepper Motor with ESP32

πŸ” What is the 28BYJ-48 Stepper Motor?The 28BYJ-48 is a 5V unipolar stepper motor with a built-in re...

Smart Farming : ESP32 with Soil Moisture Sensor

Smart Farming : ESP32 with Soil Moisture Sensor

How Soil Moisture Sensor Works and Interface it with Esp32Β When you hear the term β€œsmart garden,” on...

Control in Your Hands: ESP32 with 2-Axis Joystick

Control in Your Hands: ESP32 with 2-Axis Joystick

πŸ”§ What is an Analog Joystick?An analog joystick typically has:2 potentiometers (one for X-axis, one...

ESP32 with NEO-8M GPS Module

ESP32 with NEO-8M GPS Module

πŸ“‘ What is the NEO-8M GPS Module?The NEO-8M is a high-precision GNSS GPS receiver by u-blox, capable...

ESP32 with WS2812 NeoPixel LED

ESP32 with WS2812 NeoPixel LED

πŸ”§ What is a NeoPixel?NeoPixel is Adafruit’s name for individually addressable RGB LEDs using the WS...

Motion Detected: ESP32 with PIR Sensor (HC-SR501)

Motion Detected: ESP32 with PIR Sensor (HC-SR501)

🧠 What is a PIR Sensor?PIR = Passive Infrared SensorA PIR sensor detects motion by measuring change...

ESP32 with AI Thinker GP-02 GPS Module

ESP32 with AI Thinker GP-02 GPS Module

βœ… What is AI Thinker GP-02?The AI Thinker GP-02 is a GNSS (GPS) module, designed to work with satel...

ESP32 with SIM900A GSM Module

ESP32 with SIM900A GSM Module

πŸ“‘ What is SIM900?The SIM900 is a GSM/GPRS module from SIMCom. It allows microcontrollers like ESP32...

Button with ESP32

Button with ESP32

🧠 What is a Push Button?A push button is a simple mechanical switch that connects two points in a c...

Tilt Sensor Module SW520D

Tilt Sensor Module SW520D

πŸ€” What is a Tilt Sensor?A tilt sensor (also called a ball switch or mercury switch) is a digital sw...

ESP32 with TCS34725 RGB Sensor

ESP32 with TCS34725 RGB Sensor

🎨 What is the TCS34725?The TCS34725 is a color sensor made by AMS (now part of Renesas).It detects...

ESP32 + I2C LCD for Real-Time Feedback

ESP32 + I2C LCD for Real-Time Feedback

πŸ“˜ What is an I2C LCD?An I2C LCD is a Liquid Crystal Display that uses the I2C communication protoco...

MPU6050 Accelerometer and Gyroscope Sensor

MPU6050 Accelerometer and Gyroscope Sensor

🧠 What is MPU6050?The MPU6050 is a 6-axis motion tracking device made by InvenSense. It combines:βœ…...

Digital Temperature Monitoring: ESP32 + DS18B20 Sensor System

Digital Temperature Monitoring: ESP32 + DS18B20 Sensor System

🌑️ What is DS18B20?The DS18B20 is a digital temperature sensor from Maxim Integrated (now Analog Dev...

ESP32 with DS1307 RTC Module

ESP32 with DS1307 RTC Module

⏰ What is DS1307 RTC?The DS1307 is a real-time clock IC by Maxim Integrated that keeps track of:Sec...

DFPlayer Mini with Esp32

DFPlayer Mini with Esp32

🎡 What is DFPlayer Mini?The DFPlayer Mini is a tiny, standalone MP3 audio player module. It can pla...

IR Receiver VS1838B with ESP32

IR Receiver VS1838B with ESP32

πŸ“‘ What is an IR Receiver?An IR (Infrared) Receiver module receives signals from an IR remote contro...

Rotary Encoder with Esp32

Rotary Encoder with Esp32

πŸ“Œ What is a Rotary Encoder?A rotary encoder is an electro-mechanical sensor that converts the angul...

ESP32 with Dot Matrix Display (MAX7219)

ESP32 with Dot Matrix Display (MAX7219)

πŸ“Œ What is the Dot Matrix Display with MAX7219?A Dot Matrix Display is an arrangement of LEDs in a g...

ESP-NOW with ESP32

ESP-NOW with ESP32

πŸ“Œ What is ESP-NOW?ESP-NOW is a wireless communication protocol developed by Espressif, allowing ESP...

ESP32 Joystick Controlled Robot Using ESP-NOW Protocol & L298N Motor Driver

ESP32 Joystick Controlled Robot Using ESP-NOW Protocol & L298N Motor Driver

πŸ€– ESP32 Joystick Controlled Robot Using ESP-NOW Protocol & L298N Motor DriverWireless bot control w...

ESP32 with MAX30100 HEART SENSOR

ESP32 with MAX30100 HEART SENSOR

❀️ Heart Rate & SpOβ‚‚ Sensor (MAX30100/MAX30102)πŸ”¬ Pulse Sensor | SpOβ‚‚ Monitor | Wearable Health Tech...