Skip to content

Latest commit

 

History

History

sparkfun_proximity_vcnl4040

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

VCNL4040 - Proximity Sensor (Sparkfun)

Summary

This project aims to implement a hardware driver interacting with the VCNL4040 proximity sensor via APIs of GSDK.

VCNL4040 integrates a proximity sensor (PS), ambient light sensor (ALS), and a high power IRED into one small package. It incorporates photodiodes, amplifiers, and analog to digital converting circuits into a single chip by CMOS process. The 16-bit high resolution ALS offers excellent sensing capabilities with sufficient selections to fulfill most applications whether dark or high transparency lens design. High and low interrupt thresholds can be programmed for both ALS and PS, allowing the component to use a minimal amount of the microcontroller's resources. With the ability to detect objects up to 20 cm, it is often used in automatic towel and soap dispensers or automatic faucets.

The patented Filtron technology achieves ambient light spectral sensitivity closest to real human eye response and offers the best background light cancellation capability (including sunlight) without utilizing the microcontrollers’ resources. This sensor is excellent if you need a digital light sensor for your next glitter cannon.

Required Hardware

Hardware Connection

A VCNL4040 sensor board can be easily connected up with two I2C wires (SDA and SCL) along with 3v3 and GND. For the designated boards, SparkFun Qwiic compatible STEMMA QT connectors can be used.

connection

Setup

You can either create a project based on an example project or start with an empty example project.

Create a project based on an example project

  1. From the Launcher Home, add the BRD4314A to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with filter "VCNL4040".

  2. Click Create button on the Third Party Hardware Drivers - VCNL4040 - Proximity Sensor (Sparkfun) example. Example project creation dialog pops up -> click Create and Finish and Project should be generated. Create_example

  3. Build and flash this example to the board.

Start with an empty example project

  1. Create an "Empty C Project" for the "BGM220 Explorer Kit Board" using Simplicity Studio v5. Use the default project settings.

  2. Copy the file app/example/sparkfun_proximity_vcnl4040/app.c into the project root folder (overwriting the existing file).

  3. Install the software components:

    • Open the .slcp file in the project.

    • Select the SOFTWARE COMPONENTS tab.

    • Install the following components

      • [Services] → [Timers] → [Sleep Timer]
      • [Services] → [IO Stream] → [IO Stream: USART] → instance name: vcom
      • [Application] → [Utility] → [Log]
      • [Third Party Hardware Drivers] -> [Sensors] -> [VCNL4040 - Proximity Sensor (Sparkfun)] → use default configuration config
  4. Build and flash the project to your device

Note:

  • Make sure that the SDK extension already be installed. If not please follow this documentation.

  • SDK Extension must be enabled for the project to install "VCNL4040 - Proximity Sensor (Sparkfun)" component.

How It Works

API Overview

The driver is divided into two layers: platform and interface layer. The platform layer performs the interaction between the sensor and the microcontroller by I2C protocol (I2CSPM platform service). The interface layer provides users public APIs to communicate with or control the operation of the sensor.

sparkfun_vcnl4040_platform.c : Implementation for communication between the microcontroller and sensor board through the Silabs I2CSPM platform service.

sparkfun_vcnl4040.c : Implements public APIs to interface with VCNL4040 - Sparkfun Proximity Sensor.

sparkfun_vcnl4040_config.h : Defines the configuration for interrupt operation mode.

Testing

The below chart represents the workflow of a simple testing program. The left chart shows the initialization steps that are needed before reading data and the right chart shows the periodic measuring process.

flowchart

Use Putty or another program to read the serial output. The BGM220P uses by default a baudrate of 115200. You should expect a similar output to the one below.

console

Report Bugs & Get Support

To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.

Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo.