Component guide · Intermediate · 3 min read
I2C Proximity and Presence Sensors

SparkFun VCNL4040 Qwiic, Vishay VCNL4200 and VCNL3030X01, RAK12017 ITR20001 and ST STHS34PF80 Human Presence Sensor
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
These small sensors measure how close something is by sending infrared light and reading the reflection, over I2C. The VCNL4040 works to about 20 cm and also measures ambient light; the VCNL4200 reaches further, up to about 1.5 m. The STHS34PF80 is different: it senses body heat to detect people, even when they sit still.
Key specs at a glance
- Interface
- I2C, address 0x60 on VCNL4040
- Supply
- 2.5 to 3.6V on the chips; boards often include a regulator
- Range
- About 20 cm (VCNL4040), up to 1.5 m (VCNL4200)
- Extras
- Ambient light on VCNL4040 and VCNL4200
- Presence
- STHS34PF80 thermal presence and motion
- Connectors
- Qwiic on SparkFun, WisBlock on RAK
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1SparkFun Proximity Sensor Breakout – VCNL4040 (Qwiic)₹879
Option 2Vishay VCNL4200 High Sensitivity Long Distance Proximity & Ambient Light Sensor (ALS) Module₹389
Option 3Vishay VCNL3030X01-GS08 Proximity Sensor with IR Emitter & I2C, AEC-Q101, 2.5 to 3.6V₹369
Option 4RAKwireless IR Proximity Sensor Everlight Electronics ITR20001 RAK12017 Module – 1-5cm Detection, 3.3V₹829
Option 5STMicroelectronics STHS34PF80 Human Body Sensing Module – Digital Output₹929
What the VCNL4040, VCNL4200 and other I2C proximity and presence sensors is
The VCNL4040 and similar I2C proximity sensors combine an IR proximity sensor and ambient light sensor, used for short-range presence, phone-style screen-off and touchless buttons.
Use a VCNL4040 for touchless buttons, paper-present detection or wake-on-approach. The raw value rises as an object gets closer; it is not calibrated in millimetres, so record values for your own target and set thresholds.
The STHS34PF80 suits occupancy sensing in rooms and on desks because it sees a still person, unlike a PIR. The RAK12017 module brings a reflective IR sensor to the RAK WisBlock system.
VCNL4040, VCNL4200 and other I2C proximity and presence sensors pinout
The pins on the VCNL4040, VCNL4200 and other I2C proximity and presence sensors and what each one does.
| Pin | Function |
|---|---|
| VCC | 3.3V (or 5V on boards with a regulator) |
| GND | Ground |
| SDA | I2C data |
| SCL | I2C clock |
| INT | Optional interrupt output |
- VCC
- 3.3V (or 5V on boards with a regulator)
- GND
- Ground
- SDA
- I2C data
- SCL
- I2C clock
- INT
- Optional interrupt output
Wiring the VCNL4040, VCNL4200 and other I2C proximity and presence sensors
Keep a clear window in front of the sensor. A cover glass can reflect IR and give a false reading unless it has a gasket around the sensor.
| VCNL4040, VCNL4200 and other I2C proximity and presence sensors pin | Connection | Note |
|---|---|---|
| VCC | 3.3V | Check the board |
| GND | GND | Common ground |
| SDA | ESP32 GPIO21 | A4 on Uno via level-safe board |
| SCL | ESP32 GPIO22 | A5 on Uno |
- VCC
- Connection:
- 3.3V
- Note:
- Check the board
- GND
- Connection:
- GND
- Note:
- Common ground
- SDA
- Connection:
- ESP32 GPIO21
- Note:
- A4 on Uno via level-safe board
- SCL
- Connection:
- ESP32 GPIO22
- Note:
- A5 on Uno
Example code
Uses the Adafruit VCNL4040 library. Tune the 1000 threshold for your target and distance.
#include <Wire.h>
#include <Adafruit_VCNL4040.h>
Adafruit_VCNL4040 vcnl;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!vcnl.begin()) {
Serial.println("VCNL4040 not found");
while (1) delay(10);
}
}
void loop() {
uint16_t prox = vcnl.getProximity();
uint16_t lux = vcnl.getLux();
Serial.print("Proximity: "); Serial.print(prox);
Serial.print(" Light: "); Serial.print(lux); Serial.println(" lux");
if (prox > 1000) Serial.println("Hand detected");
delay(200);
}Setup and tuning
VCC 3.3 V (breakouts accept 5 V), GND, SDA and SCL.
use the Adafruit VCNL4040 or SparkFun library.
proximity works best up to about 20 cm.
use IR-transparent covers and avoid crosstalk with a gasket.
set proximity thresholds and interrupts for low power.
What you need
Shop this list8 of 8 found in our store · ₹3,901
SparkFun Proximity Sensor Breakout – VCNL4040 (Qwiic): the part this guide coversSparkFun Proximity Sensor Breakout – VCNL4040 (Qwiic)₹879
Vishay VCNL4200 High Sensitivity Long Distance Proximity & Ambient Light Sensor (ALS) Module: another version this guide coversVishay VCNL4200 High Sensitivity Long Distance Proximity & Ambient Light Sensor (ALS) Module₹389
Vishay VCNL3030X01-GS08 Proximity Sensor with IR Emitter & I2C, AEC-Q101, 2.5 to 3.6V: another version this guide coversVishay VCNL3030X01-GS08 Proximity Sensor with IR Emitter & I2C, AEC-Q101, 2.5 to 3.6V₹369
RAKwireless IR Proximity Sensor Everlight Electronics ITR20001 RAK12017 Module – 1-5cm Detection, 3.3V: another version this guide coversRAKwireless IR Proximity Sensor Everlight Electronics ITR20001 RAK12017 Module – 1-5cm Detection, 3.3V₹829
STMicroelectronics STHS34PF80 Human Body Sensing Module – Digital Output: another version this guide coversSTMicroelectronics STHS34PF80 Human Body Sensing Module – Digital Output₹929
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Solderless breadboard: to build without solderingSolderless Breadboard₹68
Alternatives and when to choose them
- APDS9960 gesture sensor: proximity plus gestures and colour.
- Sharp IR distance sensors: analog distance.
- Mini PIR motion sensors: motion only.
Common mistakes to avoid
- Cover glass crosstalk.
- Expecting cm distance.
- No thresholds for low power.
- Dark targets at long range.
Frequently asked questions
How far can the VCNL4040 detect objects?
Up to about 20 cm, depending on the object's reflectivity.
Why does it detect something with nothing there?
Light leaks through the cover glass; add a gasket.
Can it measure distance in cm?
No. It gives relative proximity counts, not an exact distance.
Does it also measure light?
Yes. It also has an ambient light sensor for lux readings.
Can I use interrupts?
Yes. Set proximity thresholds and connect the INT pin to an interrupt.
Parts for this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.
