Ambient light, VEML7700
Lux over I2C at 0x10 with gain and integration time, 0.0042 lux a count at best, for Adafruit_VEML7700.h.
- 4 pins
- 1 setting
- In 1 project
The Ambient light, VEML7700 in brief
What it is, and every setting the properties panel gives it.
The VEML7700 is Vishay’s ambient light sensor, sold on small breakouts with a 3.3 V regulator and pull-ups so it runs from a 5 V Arduino. It reports light as a 16-bit count at a fixed I2C address, 0x10, and a sketch trades range for resolution with the gain and the integration time: from 0.0042 lux a count at the most sensitive setting to about half a lux a count at the gain and timing the library starts with. It has no interrupt pin; the threshold flags are read over the bus. In Mokxi a slider on the part sets the light from 0 to 120000 lux. The model follows the register map, starts shut down until the library turns it on, delivers a new count once per integration time and reproduces the real sensor’s habit of reading low in bright light, so the library’s corrected and automatic modes recover the slider’s value and a plain read does not.
- Family
- Sensors
- Pins
- 4
- lux
- 300
4 pins
Named as the editor names them, so a wire lands where you expect it.
How to read a VEML7700 light sensor with an Arduino
VIN to 5 V, GND to GND, SDA to A4 and SCL to A5; the breakout’s regulator and pull-ups take care of the rest. In the built-in project the VEML7700 shares those two wires with a TMP117 thermometer. The two sit at different addresses, 0x10 and 0x48, so one sketch reads both and prints light and temperature together every second.
With Adafruit’s library, veml.begin() finds the sensor and turns it on, and veml.readLux() returns lux as a float. Drag the lux slider on the part while the project runs and the next line on the serial monitor follows it. In a dim room any mode works; once the light passes a few hundred lux, ask for readLux(VEML_LUX_AUTO), which picks the gain and integration time for you and applies the correction for the sensor’s high-light curve.
On an ESP32 the breakout runs the same way from 3.3 V; Wire uses GPIO 21 for SDA and 22 for SCL unless you pass other pins to Wire.begin().
#include <Adafruit_VEML7700.h>
Adafruit_VEML7700 veml;
void setup() {
Serial.begin(9600);
if (!veml.begin()) {
Serial.println("No VEML7700 at 0x10");
while (1) {}
}
}
void loop() {
Serial.println(veml.readLux(VEML_LUX_AUTO));
delay(1000);
}Common Ambient light, VEML7700 errors and fixes
Questions and answers
What is the VEML7700’s I2C address?
0x10, and it cannot be changed. Any other I2C part on the same two wires just needs an address of its own.
How much light can the VEML7700 measure?
Up to about 120000 lux, direct sunlight, at its least sensitive settings, which is the range of the slider on the part. At the most sensitive setting one count is 0.0042 lux, for dim rooms.
Does the VEML7700 have an interrupt pin?
No. It can compare against high and low thresholds, but the flags are read over I2C; there is no pin to wake the board.
Why is the first reading after start-up late?
The sensor powers up shut down. The library switches it on in begin(), and the first count is ready only after one full integration time.
What is true about the Ambient light, VEML7700, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
The registers. Sixteen bits each, sent low byte first: ALS_CONF (0x00) with the
gain (x1, x2, x1/8, x1/4), the integration time (25 to 800 ms), the persistence, the
interrupt enable and the shutdown bit; the high and low thresholds (0x01, 0x02);
power saving (0x03); the ALS count (0x04); the white count (0x05); the interrupt flags
(0x06, cleared by the read); and the ID, 0xC481 (0x07). The sensor comes up shut down
and every library turns it on.
The timing. Once on, a new count lands every integration time, plus 500 to
4000 ms when power saving is on. Changing ALS_CONF starts the integration again.
The counts. The resolution is 0.0042 lux a count at gain x2 and 800 ms, from the current datasheet's table (an older revision said 0.0036), and doubles for each halving of gain or integration time, so 0.5376 lux a count at the library's x1/8 and 100 ms. The count saturates at 65535.
The high-light curve. The real sensor reads low as the light rises, and Vishay's
application note gives the polynomial that drivers apply to undo it. The model
follows that curve, so readLux(VEML_LUX_CORRECTED) and VEML_LUX_AUTO (in its
bright branch) give the slider back, and a plain readLux() reads low by the curve:
about 2.6 % at 300 lux, 7 % at 1000 lux, more above.
The threshold flags. With the interrupt enabled, a count above ALS_WH or below
ALS_WL for the persistence count in a row sets its flag.
Not modeled
The spectrum: the slider is the light in lux, and the white channel reads the same count as the ALS channel, where on the real part their ratio depends on the light source. Noise, the dark count, temperature drift and the 2.5 ms start-up are not modeled either.
From VEML7700 ambient light sensor, in full.
See the Ambient light, VEML7700 in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the Ambient light, VEML7700 in it.
Arduino libraries for the Ambient light, VEML7700
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Ambient light, VEML7700
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.