Home » Raspberry Pi and VEML7700 lux sensor python example

Raspberry Pi and VEML7700 lux sensor python example

by shedboy71

In this article we look at a ambient light digital 16-bit resolution sensor – this time its the VEML7700 and we will connect it a raspberry Pi and the example is in python

This is the sensor that I will be using


Lets look at some information regarding the sensor

Sensor Information

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

Here are the parts required to build this, there are various links you can choose from – I personally buy from Aliexpress as it is usually cheaper but you will probably have to wait 3+ weeks

Name Link
Raspberry Pi 4 Aliexpress

Amazon. com link

Ebay search

VEML7700 Lux Sensor Amazon link

Ebay link

Dupont Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Amazon.com link

Ebay link

Schematic/Connection

Another I2C sensor so easy to connect up to any Raspberry Pi

Raspberry pi and veml7700

Raspberry pi and veml7700

Code Example

This uses a library from Adafruit which you can install like this from the terminal

  • sudo pip3 install adafruit-circuitpython-veml7700

I then opened the Mu editor and entered the following code example, which is the same as the default example

[codesyntax lang=”python”]

import time
import board
import busio
import adafruit_veml7700
 
i2c = busio.I2C(board.SCL, board.SDA)
veml7700 = adafruit_veml7700.VEML7700(i2c)
 
while True:
    print("Ambient light:", veml7700.light)
    time.sleep(0.1)

[/codesyntax]

Output

Run this example and you should see the following , cover the sensor and alter the light on it

Ambient light: 3423
Ambient light: 991
Ambient light: 84
Ambient light: 92
Ambient light: 102
Ambient light: 104
Ambient light: 2573
Ambient light: 3120
Ambient light: 3148

Links

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

 

 

 

You may also like

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