Home CodeArduino Microbit and VEML7700 lux sensor Arduino based example

Microbit and VEML7700 lux sensor Arduino based 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 to our Microbit

This is the sensor that I will be using


Lets look at some information regarding the sensor

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

Once again for ease of use I connect an expansion board to the microbit, I feel this makes it easier to connect to a sensor like the one pictured above using connecting wire

Schematic/Connection

microbit and veml7700

microbit and veml7700

 

Code Example

This uses the library from https://github.com/DFRobot/DFRobot_VEML7700

I tried an Adafruit one – could not get the library to work, various errors. The one above worked out of the box

[codesyntax lang=”cpp”]

#include <Wire.h>
#include "DFRobot_VEML7700.h"

DFRobot_VEML7700 als;

void setup()
{
  Serial.begin(9600);
  als.begin();
}

void loop()
{
  float lux;
  
  als.getALSLux(lux);
  Serial.print("Lux:");
  Serial.print(lux);
  Serial.println(" lx");
  
  delay(200);
}

[/codesyntax]

Output

Open the serial monitor and you should see something like this, shine light, cover the sensor to change the lux values

Lux:160.80 lx
Lux:159.59 lx
Lux:153.44 lx
Lux:130.30 lx
Lux:86.00 lx
Lux:25.92 lx
Lux:20.50 lx
Lux:16.27 lx
Lux:13.18 lx
Lux:10.57 lx
Lux:8.41 lx

Links

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

 

 

 

You may also like

Leave a Comment