Raspberry Pi Pico and VEML7700 lux sensor circuitpython example

In this article we connect a VEML7700 lux sensor to a Raspberry Pi Pico running Circuitpython

Sensor Information

This is the sensor that I bought for this


Lets look at some information regarding the sensor from the manufacturer

The VEML7700 is a high accuracy ambient light digital 16-bit resolution sensor. It includes a high sensitive photo diode, a low noise amplifier, a 16-bit A/D converter and supports an easy to use I2C bus communication interface.
The ambient light result is as digital value available

FEATURES

Integrated modules: ambient light sensor (ALS)
Supply voltage range VDD: 2.5 V to 3.6 V
Communication via I2C interface
Floor life: 72 h, MSL 4, according to J-STD-020
Low shut down current consumption: typ. 0.5 μA

AMBIENT LIGHT FUNCTION

Filtron TM technology adaption: close to real human eye response
O-Trim TM technology adoption: ALS output tolerance≤ 10 %
16-bit dynamic range for ambient light detection from 0 lx to about 120 klx with resolution down to 0.0036 lx/ct,supports low transmittance (dark) lens design
100 Hz and 120 Hz flicker noise rejection
Excellent temperature compensation
High dynamic detection resolution
Software shutdown mode control

 

Parts Required

 

Name Link
Pico Raspberry Pi Pico Development Board
VEML7700 VEML7700 Low-power Ambient Light Digital I2C Sensor
Connecting cables Aliexpress product link

Amazon.com link

Ebay link

 

Schematic/Connection

I used the Adafruit VEML7700 sensor

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and veml7700

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_vcnl4040.mpy library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example which comes with the library

[codesyntax lang=”python”]

import time
import board
import adafruit_veml7700
import busio

# Create sensor object, communicating over the board's default I2C bus
i2c = busio.I2C(scl=board.GP1, sda=board.GP0) # uses board.SCL and board.SDA
veml7700 = adafruit_veml7700.VEML7700(i2c)

while True:
    print("Ambient light:", veml7700.light)
    time.sleep(0.5)

[/codesyntax]

Output

Here is what I saw in Thonny REPL window

Ambient light: 207
Ambient light: 134
Ambient light: 82
Ambient light: 172
Ambient light: 47
Ambient light: 5
Ambient light: 5

Links

https://www.vishay.com/docs/84286/veml7700.pdf

Related posts

Raspberry Pi Pico and MMC5603 3-axis AMR magnetic sensor circuitpython example

Raspberry Pi Pico and LTR329 UV Light Sensor circuitpython example

Raspberry Pi Pico and LTR303 UV Light Sensor circuitpython example

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More