The VCNL4040 is a simple IR presence and ambient light sensor. This sensor is excellent for detecting if something has appeared in front of the sensor. We often see this type of sensor on automatic towel dispensers, automatic faucets, etc. You can detect objects qualitatively up to 20cm away. This means you can detect if something is there, and if it is closer or further away since the last reading, but it’s difficult to say it is 7.2cm away. If you need quantitative distance readings (for example sensing that an object is 177mm away) check out the SparkFun 2 meter and 4 meter Time of Flight (ToF) sensors with mm accuracy.
The SparkFun Proximity VCNL4040 sensor is a great digital alternative to the popular analog based Sharp sensors. The VCNL4040 also has no dead zone and can read all the way up to the face of the sensor. This sensor also has an ambient light sensor built it which is excellent if you need a digital light sensor for your next glitter cannon.
We’ve written an Arduino library to flex every feature of this sensor. You can grab it from the Arduino Library Manager or from the SparkFun repo.
This board is one of our many Qwiic compatible boards! Simply plug and go. No soldering, no figuring out which is SDA or SCL, and no voltage regulation or translation required!