{"id":169899,"date":"2025-06-25T15:12:00","date_gmt":"2025-06-25T15:12:00","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=169899"},"modified":"2025-06-25T15:12:03","modified_gmt":"2025-06-25T15:12:03","slug":"esp8266-nodemcu-apds9960-sensor-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/","title":{"rendered":"ESP8266 NodeMCU with APDS9960 Proximity, Light, RGB, and Gesture Sensor (Arduino IDE)"},"content":{"rendered":"\n<p>Learn how to use the APDS9960 sensor with the ESP8266 board using Arduino IDE. This sensor combines gesture detection, proximity sensing, and ambient RGB light measurement over I2C. In this guide, we&#8217;ll show you how to wire the sensor to the ESP8266 and the code to use each of its features.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 with APDS9960 Proximity, Light, RGB, and Gesture Sensor\" class=\"wp-image-169903\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<p>In this guide, we&#8217;ll cover the following topics:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#apds9960-intro\" title=\"\">Introducing the APDS9960 Sensor<\/a><\/li>\n\n\n\n<li><a href=\"#APDS9960-esp8266-wiring\" title=\"\">Wiring the APDS9960 Module to the ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"#installing-apds9960-libraries\" target=\"_blank\" rel=\"noopener\" title=\"\">Installing Libraries for the APDS9960 Sensor<\/a><\/li>\n\n\n\n<li><a href=\"#apds9960-i2c-address-chip-id\" title=\"\">Getting the Sensor I2C Address and Chip ID<\/a><\/li>\n\n\n\n<li>Examples:\n<ul class=\"wp-block-list\">\n<li><a href=\"#esp8266-apds9960-detect-gestures\" title=\"\">1) ESP8266 with APDS9960 &#8211; Detecting Gestures<\/a><\/li>\n\n\n\n<li><a href=\"#esp8266-apds9960-detect-gestures-oled-display\" title=\"\">2) ESP8266 with APDS9960 &#8211; Detecting Gestures and Display on OLED<\/a><\/li>\n\n\n\n<li><a href=\"#esp8266-apds9960-detect-proximity\" title=\"\">3) ESP8266 with APDS9960 &#8211; Detecting Proximity<\/a><\/li>\n\n\n\n<li><a href=\"#esp8266-apds9960-detect-rgb-light\" title=\"\">4) ESP8266 with APDS9960 &#8211; Detecting RGB Light<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>This tutorial focuses on programming the ESP8266 using the Arduino core. Before proceeding, you should have the ESP8266 Arduino core installed in your Arduino IDE. Follow the next tutorial to install the ESP8266 boards in the Arduino IDE, if you haven\u2019t already.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp8266-nodemcu-arduino-ide-2-0\/\" title=\"\">Installing ESP8266 NodeMCU Board in Arduino IDE 2 (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"apds9960-intro\">Introducing the APDS9960 Sensor<\/h2>\n\n\n\n<p>The APDS9960 is a 4-in-one sensor that combines gesture detection, proximity sensing, ambient light, and RGB color sensing in one small module. It comes in a compact package with a built-in IR LED and a factory-calibrated LED driver. This sensor is used on the Samsung Galaxy S5 Smartphone.<\/p>\n\n\n\n<p>For our ESP8266 projects, it&#8217;s useful to get a breakout board with the sensor. I&#8217;ve got the breakout board shown in the picture below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Proximity-Light-RGB-Gesture-Sensor.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 Proximity, Light, RGB, Gesture Sensor\" class=\"wp-image-169809\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Proximity-Light-RGB-Gesture-Sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Proximity-Light-RGB-Gesture-Sensor.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You can get different modules with the same sensor, but from different providers. They may look different, but they will work the same.<\/p>\n\n\n\n<p>The module uses the I2C communication protocol, which makes it quite simple to incorporate into your <a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\" title=\"\">ESP32<\/a>, <a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\" title=\"\">ESP8266<\/a>, <a href=\"https:\/\/randomnerdtutorials.com\/projects-arduino\/\" title=\"\">Arduino<\/a>, or <a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\" title=\"\">Raspberry Pi Pico<\/a> projects.<\/p>\n\n\n\n<p>For more detailed information about how the sensor works, we recommend taking a look at the <a href=\"https:\/\/cdn.sparkfun.com\/assets\/learn_tutorials\/3\/2\/1\/Avago-APDS-9960-datasheet.pdf\" target=\"_blank\" rel=\"noopener\" title=\"\">APDS9960 datasheet<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key Features of the APDS9960<\/h3>\n\n\n\n<p>Here&#8217;s a summary of the key features of the APDS9960 sensor:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Gesture Detection<\/strong>: detects up, down, left, right, and other gestures using IR-based proximity.<\/li>\n\n\n\n<li><strong>Proximity Sensin<\/strong>g: measures distance to objects typically up to 20 cm &gt; analog output: 0\u2013255 range.<\/li>\n\n\n\n<li><strong>Ambient Light Sensing<\/strong>: measures ambient light intensity, useful to control the brightness of displays.<\/li>\n\n\n\n<li><strong>RGB Color Sensing<\/strong>: detects red, green, blue, and clear light levels.<\/li>\n\n\n\n<li><strong>I2C Interface<\/strong>: easy integration with microcontrollers like Arduino, ESP32, ESP8266, etc.<\/li>\n\n\n\n<li><strong>Operating Voltage<\/strong>: 2.4V to 3.6V.<\/li>\n<\/ul>\n\n\n\n<p><strong>Where to Buy?<\/strong><\/p>\n\n\n\n<p>You can check our Maker Advisor Tools page to compare the APDS9960  module price in different stores:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/apds9960-sensor\/\" target=\"_blank\" rel=\"noopener\" title=\"\"><strong>APDS9960 Proximity, Light, RGB, Gesture Sensor<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">APDS9960 Sensor Module Pinout and Wiring<\/h3>\n\n\n\n<p>Let&#8217;s take a quick look at the APDS9960 sensor module pinout. If you have a different module, the pinout should be similar.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Pin<\/strong><\/td><td><strong>Function<\/strong><\/td><td><strong>Wiring to the ESP8266<\/strong><\/td><\/tr><tr><td><strong>VCC<\/strong><\/td><td>Power supply (2.4V to 3.6V)<\/td><td>3.3V<\/td><\/tr><tr><td><strong>GND<\/strong><\/td><td>Ground<\/td><td>GND<\/td><\/tr><tr><td><strong>SDA<\/strong><\/td><td>I2C data line<\/td><td>GPIO 4 (D2)<\/td><\/tr><tr><td><strong>SCL<\/strong><\/td><td>I2C clock Line<\/td><td>GPIO 5 ( D1)<\/td><\/tr><tr><td><strong>INT<\/strong><\/td><td>Interrupt Output for the proximity sensor (active LOW)<\/td><td>Any digital pin<\/td><\/tr><tr><td><strong>VL<\/strong><\/td><td>Additional power supply for the IR LED<\/td><td>Usually, you don&#8217;t need to connect<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">APDS9960 Jumpers:<\/h3>\n\n\n\n<p>The APDS9960 sensor module comes with two jumpers, which you&#8217;ll usually want to leave as they are:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Jumpers.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 Jumpers\" class=\"wp-image-169838\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Jumpers.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Jumpers.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PS Jumper<\/strong>: the PS jumper connects the power for the sensor and its IR LED. By default, it\u2019s closed (solder blob present), which means, the IR LED will get its power from the VCC pin. The VL pin can be left unconnected.<\/li>\n\n\n\n<li><strong>I2C PU Jumper<\/strong>: connects 10K pull-up resistors to SDA\/SCL (you don&#8217;t need to add resistors for the SDA and SCL lines to your circuit). <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"APDS9960-esp8266-wiring\">Wiring the APDS9960 Module to the ESP8266<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 with APDS9960 Sensor - Wiring\" class=\"wp-image-169909\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Here&#8217;s a list of the parts required for this tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noopener\" title=\"\">ESP8266 Board<\/a> &#8211; read <a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Best ESP8266 Development Boards<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/apds9960-sensor\/\" target=\"_blank\" rel=\"noopener\" title=\"\">APDS9960 Sensor<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\" rel=\"noopener\" title=\"\">LED<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\" rel=\"noopener\" title=\"\">220 Ohm resistor<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/oled-display-128x64-0-96-inch\/\" target=\"_blank\" rel=\"noopener\" title=\"\">SSD1306 OLED Display<\/a> (optional)<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noreferrer noopener\">Breadboard<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<p>Wire the APDS9960 sensor to the ESP8266 as shown in the following table\/diagram.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"807\" height=\"537\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring-Diagram-Fritzing_bb.png?resize=807%2C537&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 APDS9960 Sensor Wiring Diagram\" class=\"wp-image-169913\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring-Diagram-Fritzing_bb.png?w=807&amp;quality=100&amp;strip=all&amp;ssl=1 807w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring-Diagram-Fritzing_bb.png?resize=300%2C200&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Wiring-Diagram-Fritzing_bb.png?resize=768%2C511&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><\/figure><\/div>\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Pin<\/strong><\/td><td><strong>Wiring to the ESP<\/strong>8266<\/td><\/tr><tr><td><strong>VCC<\/strong><\/td><td>3.3V<\/td><\/tr><tr><td><strong>GND<\/strong><\/td><td>GND<\/td><\/tr><tr><td><strong>SDA<\/strong><\/td><td>GPIO 4 (D2)<\/td><\/tr><tr><td><strong>SCL<\/strong><\/td><td>GPIO 5 (D1)<\/td><\/tr><tr><td><strong>INT<\/strong><\/td><td>GPIO 14 (D5) (or any digital pin)<\/td><\/tr><tr><td><strong>VL<\/strong><\/td><td>don&#8217;t connect * (check your jumpers)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"rntbox rntclgreen\">Recommended reading: <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-pinout-reference-gpios\/\" title=\"\">ESP8266 Pinout Reference: Which GPIO pins should you use?<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-apds9960-libraries\">Installing Libraries for the APDS9960 Sensor<\/h2>\n\n\n\n<p>There are several libraries that make it easy to interface with the APDS9960 sensor. We&#8217;ll use the <a href=\"https:\/\/github.com\/adafruit\/Adafruit_APDS9960\" target=\"_blank\" rel=\"noopener\" title=\"\">APDS9960 library by Adafruit<\/a>. Install it on your Arduino IDE.<\/p>\n\n\n\n<p>Go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Manage Libraries<\/strong>. Search for APDS9960 Adafruit and install the corresponding library and any additional required dependencies<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"803\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP32-Install-APDS9960-Sensor.png?resize=803%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install APDS9960 Library Arduino IDE ESP32\" class=\"wp-image-169858\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP32-Install-APDS9960-Sensor.png?w=803&amp;quality=100&amp;strip=all&amp;ssl=1 803w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP32-Install-APDS9960-Sensor.png?resize=300%2C219&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP32-Install-APDS9960-Sensor.png?resize=768%2C560&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 803px) 100vw, 803px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"apds9960-i2c-address-chip-id\">Getting the Sensor I2C Address and Chip ID<\/h2>\n\n\n\n<p>The APDS9960 sensor typically uses the I2C address<span class=\"rnthl rntliteral\"> 0x39<\/span> and has a chip ID of <span class=\"rnthl rntliteral\">0xAB<\/span>. <\/p>\n\n\n\n<p>However, some clone or counterfeit modules may use a different I2C address or return a different chip ID. To avoid issues, it&#8217;s a good idea to run the code below to confirm the actual address and ID of your sensor.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  \n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*\/\n#include &lt;Wire.h&gt;\n\n\/\/ Define APDS9960 chip ID register\n#define APDS9960_ID_REG 0x92 \/\/ Chip ID register address\n\n\/\/ Function to read chip ID from a given I2C address\nuint8_t readChipID(uint8_t i2cAddress) {\n  Wire.beginTransmission(i2cAddress);\n  Wire.write(APDS9960_ID_REG); \/\/ Request chip ID register\n  Wire.endTransmission(false); \n  Wire.requestFrom(i2cAddress, (uint8_t)1);\n  if (Wire.available()) {\n    return Wire.read(); \/\/ Read chip ID\n  }\n  return 0; \/\/ Return 0 if no data (invalid or no response)\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  delay(1000);\n  Serial.println(&quot;Starting I2C Scanner and Chip ID Reader&quot;);\n\n  \/\/ Initialize I2C\n  Wire.begin();\n  Wire.setClock(100000); \n\n  \/\/ Scan I2C bus for devices\n  Serial.println(&quot;\\nScanning I2C bus...&quot;);\n  bool deviceFound = false;\n\n  for (uint8_t address = 0x08; address &lt;= 0x7F; address++) {\n    Wire.beginTransmission(address);\n    uint8_t error = Wire.endTransmission();\n\n    if (error == 0) {\n      deviceFound = true;\n      Serial.print(&quot;I2C device found at address 0x&quot;);\n      if (address &lt; 16) Serial.print(&quot;0&quot;);\n      Serial.print(address, HEX);\n\n      \/\/ Read and print chip ID\n      uint8_t chipID = readChipID(address);\n      Serial.print(&quot; - Chip ID: 0x&quot;);\n      if (chipID &lt; 16) Serial.print(&quot;0&quot;);\n      Serial.println(chipID, HEX);\n    }\n  }\n\n  if (!deviceFound) {\n    Serial.println(&quot;No I2C devices found. Check wiring or try again.&quot;);\n  } else {\n    Serial.println(&quot;\\nScan complete.&quot;);\n  }\n}\n\nvoid loop() {\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/APDS9960\/ESP8266_APDS9960_Scan_Address_Chip_ID.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>After uploading the code, open the Serial Monitor at a baud rate of 115200. You should get your sensor I2C address and chip ID.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"372\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Find-I2c-Address-Chip-ID-Serial-Monitor.jpg?resize=666%2C372&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 Get I2c Address and Chip ID\" class=\"wp-image-169912\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Find-I2c-Address-Chip-ID-Serial-Monitor.jpg?w=666&amp;quality=100&amp;strip=all&amp;ssl=1 666w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Find-I2c-Address-Chip-ID-Serial-Monitor.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure><\/div>\n\n\n<p>In my case, the I2C address is <span class=\"rnthl rntliteral\">0x39<\/span>, which is the expected address, and the chip ID is <span class=\"rnthl rntliteral\">0xA8<\/span>, which is <strong>not what is expected<\/strong> (<span class=\"rnthl rntliteral\">0xAB<\/span> would be expected). This means I have a counterfeit module.<\/p>\n\n\n\n<p>If you also have a counterfeit module, don&#8217;t worry. You can still use it and follow the tutorial. You just need to make a small change in one of the library files.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">APDS9960 &#8211; Not Expected Chip ID<\/h4>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">Adafruit_APDS9960<\/span> library has the chip ID hardcoded, and it checks the sensor ID when initializing the module. If you have a counterfeit one, it won&#8217;t initialize properly.<\/p>\n\n\n\n<p>To fix this, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the <strong>Arduino IDE installation folder<\/strong> and navigate to the <span class=\"rnthl rntliteral\">libraries<\/span> directory.<\/li>\n\n\n\n<li>Locate the <span class=\"rnthl rntliteral\">Adafruit_APDS9960_Library<\/span> folder.<\/li>\n\n\n\n<li>Inside it, open the <span class=\"rnthl rntliteral\">Adafruit_APDS9960.cpp<\/span> file.<\/li>\n\n\n\n<li>Comment the following lines so that it ignores that you have a different chip ID (lines 100 to 104). Or replace with your chip ID.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>  \/* Make sure we're actually connected *\/\n  \/*uint8_t x = read8(APDS9960_ID);\n  if (x != 0xAB) {\n    return false;\n  }*\/<\/code><\/pre>\n\n\n\n<p>Save the <span class=\"rnthl rntliteral\">Adafruit_APDS9960.cpp<\/span> file.<\/p>\n\n\n\n<p>Now that you have the sensor address, chip ID, and all the required libraries installed, let&#8217;s test some examples to understand how the sensor works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-apds9960-detect-gestures\">1) ESP8266 with APDS9960 &#8211; Detecting Gestures<\/h2>\n\n\n\n<p>The APDS9960 can detect basic gestures like up, down, right, and left when you swipe your hand in front of the sensor. With the right code, you can also detect more complex gestures.<\/p>\n\n\n\n<p>The following picture shows the orientation of the sensor for gesture recognition.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Gesture-Detection-Orientation.jpg?resize=300%2C300&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 Gesture Detection Sensor Orientation\" class=\"wp-image-169813\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Gesture-Detection-Orientation.jpg?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Gesture-Detection-Orientation.jpg?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/APDS9960-Gesture-Detection-Orientation.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n<p>The following code shows you the basic commands to detect the four different gestures. This is based on the <a href=\"https:\/\/github.com\/adafruit\/Adafruit_APDS9960\/blob\/master\/examples\/gesture_sensor\/gesture_sensor.ino\" target=\"_blank\" rel=\"noopener\" title=\"\">example<\/a> provided by the library.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/* This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor\r\n   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&quot; from the sensor in the up -&gt; down, down -&gt; up,  left -&gt; right, or right -&gt; left direction.\r\n   Designed specifically to work with the Adafruit APDS9960 breakout ----&gt; http:\/\/www.adafruit.com\/products\/3595 These sensors use I2C to communicate. The device's I2C address is 0x39\r\n   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 *\/\r\n\r\n\/\/ Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/\r\n\r\n#include &quot;Adafruit_APDS9960.h&quot;\r\nAdafruit_APDS9960 apds;\r\n\r\n\/\/ the setup function runs once when you press reset or power the board\r\nvoid setup() {\r\n  Serial.begin(115200);\r\n  \r\n  if(!apds.begin()){\r\n    Serial.println(&quot;failed to initialize device! Please check your wiring.&quot;);\r\n  }\r\n  else Serial.println(&quot;Device initialized!&quot;);\r\n\r\n  \/\/gesture mode will be entered once proximity mode senses something close\r\n  apds.enableProximity(true);\r\n  apds.enableGesture(true);\r\n}\r\n\r\n\/\/ the loop function runs over and over again forever\r\nvoid loop() {\r\n  uint8_t gesture = apds.readGesture();\r\n  if (gesture == APDS9960_DOWN) { \r\n    Serial.println(&quot;v Moving DOWN&quot;); \r\n  }\r\n  if (gesture == APDS9960_UP) {\r\n     Serial.println(&quot;^ Moving UP&quot;);\r\n  }\r\n  if (gesture == APDS9960_LEFT) { \r\n    Serial.println(&quot;&lt; Moving LEFT&quot;); \r\n  }\r\n  if (gesture == APDS9960_RIGHT) {\r\n    Serial.println(&quot;&gt; Moving RIGHT&quot;); \r\n  }\r\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/APDS9960\/ESP8266_APDS9960_Gesture_Sensor.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Does the Code Work<\/h3>\n\n\n\n<p>Continue reading to learn how the code works, or skip to the demonstration section.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Importing the Library<\/h4>\n\n\n\n<p>First, import the <span class=\"rnthl rntliteral\">Adafruit_APDS9960<\/span> library as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include \"Adafruit_APDS9960.h\"<\/code><\/pre>\n\n\n\n<p>Create an object called <span class=\"rnthl rntliteral\">apds<\/span> to interact with the sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Adafruit_APDS9960 apds;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Then, initialize the sensor using the <span class=\"rnthl rntliteral\">begin()<\/span> method as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if(!apds.begin()){\n  Serial.println(\"failed to initialize device! Please check your wiring.\");\n}\nelse Serial.println(\"Device initialized!\");<\/code><\/pre>\n\n\n\n<p>The following lines enable proximity sensing and gesture sensing. The gesture detection only works when the sensor detects proximity.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>apds.enableProximity(true);\napds.enableGesture(true);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, check if a gesture is detected using the <span class=\"rnthl rntliteral\">readGesture()<\/span> function. If it detects a gesture, save it in the <span class=\"rnthl rntliteral\">gesture<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>uint8_t gesture = apds.readGesture();<\/code><\/pre>\n\n\n\n<p>Then, check the gesture detected and print it in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (gesture == APDS9960_DOWN) { \n  Serial.println(\"v Moving DOWN\"); \n}\nif (gesture == APDS9960_UP) {\n   Serial.println(\"^ Moving UP\");\n}\nif (gesture == APDS9960_LEFT) { \n  Serial.println(\"&lt; Moving LEFT\"); \n}\nif (gesture == APDS9960_RIGHT) {\n  Serial.println(\"&gt; Moving RIGHT\"); \n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Testing Gesture Detection<\/h3>\n\n\n\n<p>After uploading the code, open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n\n<p>Swipe your hand close to the sensor: up, down, left, and right.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Gestures.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 with APDS9960 - Testing Gesture Detection\" class=\"wp-image-169914\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Gestures.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Gestures.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The corresponding gesture will be printed in the Serial Monitor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"250\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Gestures.jpg.png?resize=675%2C250&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 with APDS9960 Gesture Detection Arduino IDE - Serial Monitor Demonstration\" class=\"wp-image-169919\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Gestures.jpg.png?w=675&amp;quality=100&amp;strip=all&amp;ssl=1 675w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Gestures.jpg.png?resize=300%2C111&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 675px) 100vw, 675px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-apds9960-detect-gestures-oled-display\">2) ESP8266 with APDS9960 &#8211; Detecting Gestures and Display on OLED<\/h2>\n\n\n\n<p>You can take this previous example to the next level and add an OLED display to your circuit to detect the gestures. This example can be easily modified to display whatever screen you like, depending on the gesture.<\/p>\n\n\n\n<p>For this project, follow these next steps:<\/p>\n\n\n\n<p><strong>1)<\/strong> Add an OLED display to your previous circuit:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>OLED<\/strong><\/td><td><strong>Wiring to the ESP8266<\/strong><\/td><\/tr><tr><td><strong>VCC<\/strong><\/td><td>3.3V<\/td><\/tr><tr><td><strong>GND<\/strong><\/td><td>GND<\/td><\/tr><tr><td><strong>SDA<\/strong><\/td><td>GPIO 4 (D2)<\/td><\/tr><tr><td><strong>SCL<\/strong><\/td><td>GPIO 5 (D1)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>2) <\/strong>Install the <span class=\"rnthl rntliteral\">Adafruit_SSD1306<\/span> Library and corresponding dependencies on your Arduino IDE.<\/p>\n\n\n\n<p><strong>3)<\/strong> Upload the following code to your board.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  \n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*\/\n#include &quot;Adafruit_APDS9960.h&quot;\n#include &lt;Adafruit_SSD1306.h&gt;\n#include &lt;Wire.h&gt;\n\n\/\/ OLED display settings\n#define SCREEN_WIDTH 128\n#define SCREEN_HEIGHT 64\n#define OLED_RESET    -1 \/\/ Reset pin # (or -1 if sharing Arduino reset pin)\nAdafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);\n\n\/\/ APDS9960 sensor\nAdafruit_APDS9960 apds;\n\n\/\/ Function to center text horizontally\nvoid centerText(const char* text, int y) {\n  int charCount = strlen(text);\n  int textWidth = charCount * 6;\n  int x = (SCREEN_WIDTH - textWidth) \/ 2;\n  display.setCursor(x, y);\n  display.println(text);\n}\n\n\/\/ Function to display UP gesture\nvoid displayScreenUp() {\n  display.clearDisplay();\n  centerText(&quot;^&quot;, 10);\n  centerText(&quot;Moving UP&quot;, 30);\n  display.display();\n  Serial.println(&quot;^ Moving UP&quot;);\n}\n\n\/\/ Function to display DOWN gesture\nvoid displayScreenDown() {\n  display.clearDisplay();\n  centerText(&quot;v&quot;, 10);\n  centerText(&quot;Moving DOWN&quot;, 30);\n  display.display();\n  Serial.println(&quot;v Moving DOWN&quot;);\n}\n\n\/\/ Function to display LEFT gesture\nvoid displayScreenLeft() {\n  display.clearDisplay();\n  centerText(&quot;&lt;&quot;, 10);\n  centerText(&quot;Moving LEFT&quot;, 30);\n  display.display();\n  Serial.println(&quot;&lt; Moving LEFT&quot;);\n}\n\n\/\/ Function to display RIGHT gesture\nvoid displayScreenRight() {\n  display.clearDisplay();\n  centerText(&quot;&gt;&quot;, 10);\n  centerText(&quot;Moving RIGHT&quot;, 30);\n  display.display();\n  Serial.println(&quot;&gt; Moving RIGHT&quot;);\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  \n  \/\/ Initialize OLED display\n  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { \/\/ Address 0x3C for 128x64\n    Serial.println(F(&quot;SSD1306 allocation failed&quot;));\n    for(;;); \/\/ Don't proceed, loop forever\n  }\n  \/\/ Clear the display\n  display.clearDisplay();\n  display.display();\n  delay(500);\n\n  display.setTextSize(1);      \n  display.setTextColor(WHITE);\n  display.setCursor(0,0); \n  display.println(F(&quot;Gesture Sensor&quot;));\n  display.display();\n  delay(100);\n  \n  \/\/ Initialize APDS9960\n  if(!apds.begin()){\n    Serial.println(&quot;Failed to initialize APDS9960! Check wiring.&quot;);\n    display.clearDisplay();\n    display.setCursor(0,0);\n    display.println(F(&quot;APDS9960 Failed&quot;));\n    display.display();\n  } else {\n    Serial.println(&quot;APDS9960 initialized!&quot;);\n    apds.enableProximity(true);\n    apds.enableGesture(true);\n  }\n}\n\nvoid loop() {\n  uint8_t gesture = apds.readGesture();\n  if (gesture == APDS9960_DOWN) {\n    displayScreenDown();\n  }\n  if (gesture == APDS9960_UP) {\n    displayScreenUp();\n  }\n  if (gesture == APDS9960_LEFT) {\n    displayScreenLeft();\n  }\n  if (gesture == APDS9960_RIGHT) {\n    displayScreenRight();\n  }\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/APDS9960\/ESP8266_APDS9960_Gesture_Sensor_OLED_Display.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>We won&#8217;t explain how this code works. To learn how to interface an OLED SSD1306 with the ESP8266 read the following guide: <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-0-96-inch-oled-display-with-arduino-ide\/\" title=\"\">ESP8266 0.96 inch OLED Display with Arduino IDE<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Demonstration<\/h3>\n\n\n\n<p>Swipe your hand in different directions in front of the sensor. The gesture will be displayed on the OLED screen.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Up-Gesture-OLED-Display.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 with ESP8266 - Moving Up Gesture Detection\" class=\"wp-image-169915\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Up-Gesture-OLED-Display.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Up-Gesture-OLED-Display.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\">Detecting the Moving UP Gesture<\/figcaption><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Left-Gesture-OLED-Display.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 with ESP8266 - Moving LeftGesture Detection\" class=\"wp-image-169916\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Left-Gesture-OLED-Display.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Detect-Left-Gesture-OLED-Display.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\">Detecting the Moving LEFT Gesture<\/figcaption><\/figure><\/div>\n\n<div style=\"text-align:center\"><iframe src=\"https:\/\/player.vimeo.com\/video\/1096285648?color=ff9933&title=1&byline=0&portrait=0\" width=\"720\" height=\"405\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen><\/iframe><\/div><\/br>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-apds9960-detect-proximity\">3) ESP8266 with APDS9960 &#8211; Detecting Proximity<\/h2>\n\n\n\n<p>The APDS9960 sensor can detect proximity within a range of approximately 10 to 20 cm. When an object comes close to the sensor, it activates the <strong>INT<\/strong> (interrupt) pin. This is an <strong>active LOW<\/strong> interrupt, meaning the pin&#8217;s state changes from HIGH to LOW when proximity is detected.<\/p>\n\n\n\n<p>The APDS9960 sensor allows you to set a proximity threshold, which defines how close an object must be before it&#8217;s considered &#8220;detected.&#8221; <\/p>\n\n\n\n<p>For this example, follow the next steps:<\/p>\n\n\n\n<p><strong>1)<\/strong> Wire an LED to your circuit. We&#8217;re connecting it to GPIO 12 (D6), but you can use any other digital output.<\/p>\n\n\n\n<p><strong>2)<\/strong> Upload the following code to your board. This code is based on the <a href=\"https:\/\/github.com\/adafruit\/Adafruit_APDS9960\/blob\/master\/examples\/proximity_sensor\/proximity_sensor.ino\" target=\"_blank\" rel=\"noopener\" title=\"\">example<\/a> provided by the Adafruit library.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/* This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor\n   This sketch puts the sensor in proximity mode and enables the interrupt to fire when proximity goes over a set value\n   Designed specifically to work with the Adafruit APDS9960 breakout ----&gt; http:\/\/www.adafruit.com\/products\/3595 These sensors use I2C to communicate. The device's I2C address is 0x39\n   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 *\/\n\n\/\/ Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/\n\n#include &quot;Adafruit_APDS9960.h&quot;\n\n\/\/the pin that the interrupt is attached to\n#define INT_PIN 14\n\n\/\/ LED for visual output\n#define LED_PIN 12\n\n\/\/create the APDS9960 object\nAdafruit_APDS9960 apds;\n\nvoid setup() {\n  Serial.begin(115200);\n  pinMode(INT_PIN, INPUT_PULLUP);\n  pinMode(LED_PIN, OUTPUT);\n\n  if(!apds.begin()){\n    Serial.println(&quot;failed to initialize device! Please check your wiring.&quot;);\n  }\n  else Serial.println(&quot;Device initialized!&quot;);\n\n  \/\/enable proximity mode\n  apds.enableProximity(true);\n\n  \/\/set the interrupt threshold to fire when proximity reading goes above 175\n  apds.setProximityInterruptThreshold(0, 175);\n\n  \/\/enable the proximity interrupt\n  apds.enableProximityInterrupt();\n}\n\nvoid loop() {\n  \/\/print the proximity reading when the interrupt pin goes low\n  if(!digitalRead(INT_PIN)){\n    Serial.println(apds.readProximity());\n    digitalWrite(LED_PIN, HIGH);\n\n    \/\/clear the interrupt\n    apds.clearInterrupt();\n  }\n  digitalWrite(LED_PIN, LOW);\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/APDS9960\/ESP8266_APDS9960_Proximity_Sensor.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Does the Code Work<\/h3>\n\n\n\n<p>Continue reading to learn how the code works.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Importing the Library<\/h4>\n\n\n\n<p>First, import the <span class=\"rnthl rntliteral\">Adafruit_APDS9960<\/span> library as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include \"Adafruit_APDS9960.h\"<\/code><\/pre>\n\n\n\n<p>Create an object called <span class=\"rnthl rntliteral\">apds<\/span> to interact with the sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Adafruit_APDS9960 apds;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Defining Pins<\/h4>\n\n\n\n<p>Define the pin that the INT pin is connected to. In our case, it is connected to GPIO 14 (D5).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/the pin that the interrupt is attached to\n#define INT_PIN 14<\/code><\/pre>\n\n\n\n<p>Then, define the pin that the LED is connected to.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ LED for visual output\n#define LED_PIN 12<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Set the interrupt pin as an input with an internal pull-up resistor, and the LED as an output.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(INT_PIN, INPUT_PULLUP);\npinMode(LED_PIN, OUTPUT);<\/code><\/pre>\n\n\n\n<p>Then, initialize the sensor using the <span class=\"rnthl rntliteral\">begin()<\/span> method as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if(!apds.begin()){\n  Serial.println(\"failed to initialize device! Please check your wiring.\");\n}\nelse Serial.println(\"Device initialized!\");<\/code><\/pre>\n\n\n\n<p>Enable the proximity detection using the <span class=\"rnthl rntliteral\">enableProximity()<\/span> function on the <span class=\"rnthl rntliteral\">apds<\/span> object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>apds.enableProximity(true);<\/code><\/pre>\n\n\n\n<p>Now, set the proximity interrupt threshold range using the <span class=\"rnthl rntliteral\">setProximityInterruptThreshold()<\/span> function. The sensor will only trigger an interrupt if it detects something close enough to produce a reading over 175 (the maximum reading is 255\u2014the closer the object, the higher the value).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>apds.setProximityInterruptThreshold(0, 175);<\/code><\/pre>\n\n\n\n<p>Then, activate the interrupt on proximity.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>apds.enableProximityInterrupt();<\/code><\/pre>\n\n\n\n<p>After this, when the threshold is crossed, the sensor will pull the INT pin to LOW.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/set the interrupt threshold to fire when proximity reading goes above 175\napds.setProximityInterruptThreshold(0, 175);<\/code><\/pre>\n\n\n\n<p>You can use this interrupt to trigger an alert or perform a task only when something is near the sensor.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, check the state of the INT pin. If it is LOW, it means we have an object close to the sensor. In that case, we read the proximity value with <span class=\"rnthl rntliteral\">apds.readProximity()<\/span> and light up the LED.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/print the proximity reading when the interrupt pin goes low\nif(!digitalRead(INT_PIN)){\n  Serial.println(apds.readProximity());\n  digitalWrite(LED_PIN, HIGH);\n\n  \/\/clear the interrupt\n  apds.clearInterrupt();\n}<\/code><\/pre>\n\n\n\n<p>After that, we call the <span class=\"rnthl rntliteral\">clearInterrupt()<\/span> function. It resets the interrupt flag on the APDS9960 sensor. When the sensor detects a proximity event above the threshold, it pulls the INT pin LOW to signal the event. <\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/clear the interrupt\n apds.clearInterrupt();<\/code><\/pre>\n\n\n\n<p>This LOW state will remain until the interrupt is cleared by calling the <span class=\"rnthl rntliteral\">clearInterrupt()<\/span> function. After this, the INT pin will go back to its original state, HIGH.<\/p>\n\n\n\n<p>When the pin is not triggered, turn the LED off.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>digitalWrite(LED_PIN, LOW);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Demonstration<\/h3>\n\n\n\n<p>Upload the previous code to your board.<\/p>\n\n\n\n<p>Put something closer to the sensor. You&#8217;ll see that when it reaches a certain proximity threshold, the LED turns on.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Proximity-Sensor.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 ESP8266 Testing Proximity Sensor\" class=\"wp-image-169918\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Proximity-Sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Proximity-Sensor.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>At the same time, the proximity values are printed in the Serial Monitor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"375\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Proximity-Sensor.png?resize=667%2C375&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 APDS9960 Testing Proximity Sensor - Serial Monitor\" class=\"wp-image-169920\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Proximity-Sensor.png?w=667&amp;quality=100&amp;strip=all&amp;ssl=1 667w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Proximity-Sensor.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-apds9960-detect-rgb-light\">4) ESP8266 with APDS9960 &#8211; Detecting RGB Light<\/h2>\n\n\n\n<p>The APDS9960 sensor can measure red, green, blue, and clear light. The clear channel measures overall brightness, while the red, green, and blue channels tell you how much of each color is present.<\/p>\n\n\n\n<p>The values you get from the sensor are relative values. Higher values represent more light of that specific color. You can compare the values to try to estimate the dominant color of an object or environment.<\/p>\n\n\n\n<p>The following code reads the red, green, blue, and clear light, and displays the results in the Serial Monitor. This code is based on <a href=\"https:\/\/github.com\/adafruit\/Adafruit_APDS9960\/blob\/master\/examples\/color_sensor\/color_sensor.ino\" target=\"_blank\" rel=\"noopener\" title=\"\">this example<\/a> provided by the library.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/* This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor\n   This sketch puts the sensor in color mode and reads the RGB and clear values.\n   Designed specifically to work with the Adafruit APDS9960 breakout ----&gt; http:\/\/www.adafruit.com\/products\/3595 These sensors use I2C to communicate. The device's I2C address is 0x39\n   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 *\/\n\n\/\/ Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/\n\n#include &quot;Adafruit_APDS9960.h&quot;\nAdafruit_APDS9960 apds;\n\nvoid setup() {\n  Serial.begin(115200);\n\n  if(!apds.begin()){\n    Serial.println(&quot;failed to initialize device! Please check your wiring.&quot;);\n  }\n  else Serial.println(&quot;Device initialized!&quot;);\n\n  \/\/enable color sensing mode\n  apds.enableColor(true);\n\n  \/\/ Set ADC gain to high (16x) for better color sensitivity\n  apds.setADCGain(APDS9960_AGAIN_16X);\n}\n\nvoid loop() {\n  \/\/create some variables to store the color data in\n  uint16_t r, g, b, c;\n  \n  \/\/wait for color data to be ready\n  while(!apds.colorDataReady()){\n    delay(5);\n  }\n\n  \/\/get the data and print the different channels\n  apds.getColorData(&amp;r, &amp;g, &amp;b, &amp;c);\n  Serial.print(&quot;Red Light: &quot;);\n  Serial.print(r);\n  \n  Serial.print(&quot; || Green Light: &quot;);\n  Serial.print(g);\n  \n  Serial.print(&quot; || Blue Light: &quot;);\n  Serial.print(b);\n  \n  Serial.print(&quot; || Ambient Light: &quot;);\n  Serial.println(c);\n  Serial.println();\n  \n  delay(500);\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/APDS9960\/ESP8266_APDS9960_Light_Sensor.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Does the Code Work?<\/h3>\n\n\n\n<p>Enable the color sensing mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/enable color sensing mode\napds.enableColor(true);<\/code><\/pre>\n\n\n\n<p>Then, we&#8217;re setting a 16x gain for better sensitivity. This line is optional.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Set ADC gain to high (16x) for better color sensitivity\napds.setADCGain(APDS9960_AGAIN_16X);<\/code><\/pre>\n\n\n\n<p>Here&#8217;s all gain options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">APDS9960_AGAIN_1X<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">APDS9960_AGAIN_4X<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">APDS9960_AGAIN_16X<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">APDS9960_AGAIN_64X<\/span><\/li>\n<\/ul>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, create four variables to save the color data.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">r<\/span> = red<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">g<\/span> = green<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">b<\/span> = blue<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">c<\/span> = clear (ambient light)<\/li>\n<\/ul>\n\n\n\n<p>Wait until new color data is available from the sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>while(!apds.colorDataReady()){\n  delay(5);\n}<\/code><\/pre>\n\n\n\n<p>Once the data is ready, get the different values into our variables as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>apds.getColorData(&amp;r, &amp;g, &amp;b, &amp;c);<\/code><\/pre>\n\n\n\n<p>Then, print the results in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(\"Red Light: \");\nSerial.print(r);\n  \nSerial.print(\" || Green Light: \");\nSerial.print(g);\n  \nSerial.print(\" || Blue Light: \");\nSerial.print(b);\n  \nSerial.print(\" || Ambient Light: \");\nSerial.println(c);\nSerial.println();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Demonstration<\/h3>\n\n\n\n<p>Upload the previous code to your board. Then, open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n\n<p>Try pointing your smartphone\u2019s flashlight at the sensor\u2014you\u2019ll notice the light intensity values start to increase.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"355\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor-Serial-Monitor.jpg?resize=701%2C355&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"APDS9960 Color Detection Arduino IDE - Testing with ESP8266\" class=\"wp-image-169921\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor-Serial-Monitor.jpg?w=701&amp;quality=100&amp;strip=all&amp;ssl=1 701w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor-Serial-Monitor.jpg?resize=300%2C152&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 701px) 100vw, 701px\" \/><\/figure><\/div>\n\n\n<p>You can also experiment with colored lights or shine the flashlight onto a colorful object. The reflected light will hit the sensor, allowing it to detect the color of the object.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 APDS9960 Sensor - Testing Light Sensor\" class=\"wp-image-169922\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APDS9960-Testing-Light-Sensor.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to use the APDS9960 sensor module with the ESP8266. It can detect basic gestures, proximity, measure ambient light, and RGB light intensities.<\/p>\n\n\n\n<p>We&#8217;ve shown you some basic examples to put the sensor to the test and learn the basic methods to use its features.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this guide useful. We have more guides for ESP8266 sensors and modules:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-guides-sensors-modules\/\">ESP8266 NodeMCU: 30+ Free Guides for Sensors and Modules<\/a><\/li>\n<\/ul>\n\n\n\n<p>To learn more about the ESP8266, check out our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\" title=\"\">Home Automation using ESP8266<\/a> (eBook)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32 and ESP8266<\/a>&nbsp;(eBook)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\">Build Web Servers with ESP32 and ESP8266<\/a>&nbsp;(eBook)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\" title=\"\">Free ESP8266 Tutorials and Guides<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the APDS9960 sensor with the ESP8266 board using Arduino IDE. This sensor combines gesture detection, proximity sensing, and ambient RGB light measurement over I2C. In this &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 NodeMCU with APDS9960 Proximity, Light, RGB, and Gesture Sensor (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-apds9960-sensor-arduino\/#more-169899\" aria-label=\"Read more about ESP8266 NodeMCU with APDS9960 Proximity, Light, RGB, and Gesture Sensor (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":169903,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[214,265,246,300,240,264],"tags":[],"class_list":["post-169899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266","category-esp8266-project","category-esp8266-arduino-ide","category-0-esp8266","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/05\/ESP8266-APD966-Sensor-Guide.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/169899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=169899"}],"version-history":[{"count":6,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/169899\/revisions"}],"predecessor-version":[{"id":171911,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/169899\/revisions\/171911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/169903"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=169899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=169899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=169899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}