Arduino projects

proximity sensor based on Arduino Uno

This article discusses how to interface and use the VCNL4010 proximity/light sensor with the Arduino Uno development board. The use of proximity/light sensors is important in various applications including mobile devices and industrial controls.

The VCNL4010 sensor is a fully integrated proximity and ambient light sensor. It is designed for short-range detection – no more than 200 mm – with an optimal distance of about 10-150 mm. It is easy to use with any I2C-capable microcontroller. It is 5V compliant, so you can use 3.3V or 5V without risk of damage.

proximity sensor based on Arduino Uno

VCNL4010 proximity sensor.

Choosing the right sensor

To determine the right sensor for your application, you should consider at least three things:

● First is accuracy. It is very important to get a sensor that can measure how close the reading is to the true distance.

● Second, the smallest reading or change in reading that can be reported, or what we call resolution.

● Finally, the level of accuracy or minimum reading that can be taken repeatedly and reliably.

Only these three are not enough, we also need to correctly match the application where we plan to use it. If the sensor will be used in an application to determine the level of liquid, object detection or distance measurement, then an ultrasonic sensor may be a better choice. But if the application involves light detection or heat dissipation measurement, infrared or proximity sensors can work well.

Required Components

● Arduino Uno development board

● VCNL4010 proximity/light sensor

● Arduino IDE

● Jumper

● Breadboard

Circuit Schematic

Circuit diagram.

Make the following connections between the sensor and the Arduino Uno:

● 5V of Arduino development board is connected to sensor Vin

● Arduino ground/GND to sensor ground/GND

● A5 (SCL) to sensor SCL

● A4 (SDA) sensor SDA

proximity sensor based on Arduino Uno

VCNL4010 power supply pins

The VCNL4010 has three power supply pins: VIN, 3Vo, and GND.

Vin is the power pin. The VCNL4010 uses 3VDC for its logic circuits, so a regulator is included on the board that can take 3-5 VDC and step it down safely. Power the board with the same power supply as the microcontroller logic levels. 3Vo is the 3.3V output of the regulator. GND is the common ground.

Data Pin Description

The VCNL4010 also has three data pins: SCL, SDA, and INT.

SCL is the I2C clock pin, it is connected to the microcontroller I2C clock line. SDA is the I2C data pin, it is connected to the microcontroller I2C data line, using 3V or 5V logic. INT is the interrupt output, used to sound an alarm when the sensor detects certain information.

Installing the library files

To start using the sensor, you will need to download the VCNL4010 library . This library can also be downloaded using the Arduino Library Manager.

In the Arduino IDE, click Sketch > Include Library > Manage Libraries .

proximity sensor based on Arduino Uno

“Manage Libraries” in the Arduino IDE.

Type ” Adafruit VCNL4010 ” and click ” install “.

Add the Adafruit VCNL4010 Arduino library.

proximity sensor based on Arduino Uno

Test Demo

We are ready to test our setup. Go to File > Examples > Adafruit_VCNL4010 > vcnl4010test and upload it to your Arduino board.

proximity sensor based on Arduino Uno

Run the demo program.

Open the serial monitor at 9600 baud. You should see ambient light and proximity data printed out, indicating that you have successfully connected the proximity sensor to the Arduino Uno.

The connection is successful.

NOTE: The values ​​printed are unitless. The closer the object is, the higher the number.

Check Also
Close
Back to top button