The SparkFun Proximity Sensor Breakout - 20cm, VCNL4040 (Qwiic) is a versatile sensor module that combines proximity sensing and ambient light measurement capabilities. Equipped with the VCNL4040 sensor, it is capable of detecting objects within a 20cm range and measuring ambient light levels. This sensor is ideal for applications such as user presence detection, touchless gesture recognition, and light intensity monitoring. Its Qwiic connect system allows for easy daisy-chaining and quick setup with compatible microcontrollers, such as the Arduino platform.
Pin Name | Description |
---|---|
VIN |
Supply voltage for the sensor (2.5V to 3.6V) |
GND |
Ground connection |
SDA |
I2C data line |
SCL |
I2C clock line |
INT |
Interrupt pin (active low) |
To use the VCNL4040 sensor breakout with an Arduino UNO, follow these steps:
VIN
to a 3.3V output on the Arduino.GND
to a ground pin on the Arduino.SDA
to the A4 pin (SDA) on the Arduino.SCL
to the A5 pin (SCL) on the Arduino.INT
to an interrupt-capable pin on the Arduino if interrupt functionality is required.#include <Wire.h>
#include "SparkFun_VCNL4040_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_VCNL4040
VCNL4040 proximitySensor;
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("VCNL4040 Proximity Sensor Example");
if (proximitySensor.begin() == false) {
Serial.println("Sensor not detected. Please check wiring. Freezing...");
while (1);
}
}
void loop() {
Serial.print("Proximity: ");
Serial.println(proximitySensor.getProximity());
Serial.print("Ambient light: ");
Serial.println(proximitySensor.getAmbient());
delay(500);
}
Ensure that the SparkFun VCNL4040 library is installed in the Arduino IDE before uploading this code to the Arduino UNO.
Q: Can the sensor detect objects beyond 20cm? A: The sensor is optimized for a range of up to 20cm. While it may detect objects slightly beyond this range, accuracy and reliability decrease with distance.
Q: How do I change the I2C address of the sensor? A: The I2C address of the VCNL4040 sensor is fixed and cannot be changed.
Q: Is the sensor compatible with 5V systems? A: The sensor's I2C bus can tolerate up to 3.6V. For 5V systems, use a level shifter to prevent damage to the sensor.
Q: Can I use the sensor with a Raspberry Pi? A: Yes, the sensor can be used with a Raspberry Pi or any other microcontroller that supports I2C communication, provided the correct logic levels are used.
For further assistance, consult the SparkFun VCNL4040 datasheet and the Qwiic system documentation.