Source: https://mokxi.com/libraries/adafruit-veml7700
Updated: 2026-11-22

Libraries / Sensors

Arduino library · Sensors

# Adafruit VEML7700: lux across a wide range

Yes. You can use the Adafruit VEML7700 library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Ambient light, VEML7700). The example below, "Lux from a VEML7700, plain and corrected", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <Adafruit_VEML7700.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit VEML7700 does

The VEML7700 is Vishay’s ambient light sensor, a 16-bit count weighted to match how the eye sees brightness. It spans dim rooms to daylight, but no single setting covers the whole range: the gain (1/8, 1/4, 1 or 2) and the integration time (25 to 800 ms) decide both how fine each count is and where the count tops out. Adafruit’s library, version 2, handles its registers at the fixed address 0x10.

begin() picks the least sensitive pair, gain 1/8 and 100 ms, where one count is about 0.54 lux, which suits a lit room. readLux() multiplies the count by the resolution for the current setting; the finest is 0.0042 lux per count at gain 2 and 800 ms. In bright light the sensor’s response bends, and VEML_LUX_CORRECTED applies Vishay’s correction for it, while VEML_LUX_AUTO steps the gain and time by itself until the count lands in a useful range.

Compared with the BH1750, which has its own page, the VEML7700 adds a white channel, interrupt thresholds and power-saving modes, at the cost of more settings to understand. In Mokxi the veml7700 part follows the high-light curve that the corrected reading undoes, so the example prints a plain and a corrected lux. The white channel reads the same count as ALS there, since the slider has no spectrum.

Library Manager name | Adafruit VEML7700

Author | Adafruit

Include | #include <Adafruit_VEML7700.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Ambient light, VEML7700

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_VEML7700.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit VEML7700" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit VEML7700 to lib_deps in PlatformIO. Mokxi follows the calls of release 2.1.6, so a sketch written here builds there too.

What to know in the simulator: Resolution 0.0042 lux a count at gain x2 and 800 ms, from the current datasheet. The part follows the high-light curve the corrected readings undo; the white channel reads the same count as ALS, since the slider has no spectrum.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- ESP32-S3-CAM
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_VEML7700 veml = Adafruit_VEML7700()

Creates the driver.

### veml.begin()

Checks the chip answers at 0x10, sets gain 1/8 and 100 ms and powers it on. Returns false when it is missing.

### veml.readLux()

Lux at the current setting, waiting two integration times so the count is fresh. VEML_LUX_NORMAL_NOWAIT skips the wait.

### veml.readLux(VEML_LUX_AUTO)

Chooses gain and integration time for the light it finds, correcting in bright light. Slower, since it may take several readings.

### veml.setGain(VEML7700_GAIN_2)

Sets the gain; getGainValue() returns it as a number, such as 0.125.

### veml.setIntegrationTime(VEML7700_IT_800MS)

Sets how long each count gathers light; getIntegrationTimeValue() returns it in ms.

### veml.readALS()

The raw ambient light count. readWhite() reads the white channel.

### veml.setHighThreshold(20000)

A raw count that trips the interrupt, with setLowThreshold() for the other edge. interruptEnable(true) arms it and interruptStatus() says which edge was crossed.

### veml.powerSaveEnable(true)

Adds idle time between measurements to cut current; setPowerSaveMode() picks how long.

## Example: Lux from a VEML7700, plain and corrected

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 A4 to Ambient light, VEML7700 SDA
- Arduino Uno R3 A5 to Ambient light, VEML7700 SCL
- Arduino Uno R3 5V to Ambient light, VEML7700 VIN
- Arduino Uno R3 GND to Ambient light, VEML7700 GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Sensor not found

begin() got no reply at 0x10. Check the two bus wires and VIN, and that nothing else on the bus claims 0x10.

### Lux stops rising around 35000 in bright light

At gain 1/8 and 100 ms the count saturates at 65535, about 35000 lux. Shorten the integration time to 25 ms, or use VEML_LUX_AUTO, which also applies the bright-light correction.

### A dark room reads 0 lux

At the default setting each count is about 0.54 lux, so anything dimmer rounds to zero. Raise the gain to 2 and the time to 800 ms, or let VEML_LUX_AUTO choose.

### loop() becomes slow after setting 800 ms

A waiting readLux() waits two integration times, 1.6 seconds at that setting. Use VEML_LUX_NORMAL_NOWAIT and read less often, or pick a shorter time.

## Questions and answers

### Should I use plain or corrected lux?

Corrected, once the light gets bright: it undoes the sensor’s nonlinear response there. The example prints both so you can see the gap at 300 lux.

### Why does the example print 292 and then about 300 lux?

The part is set to 300 lux and follows the sensor’s high-light curve, so the plain reading is a little low and the corrected one recovers it.

## Projects that use Adafruit VEML7700

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Temperature and light on one I2C bus A TMP117 temperature sensor and a VEML7700 light sensor share the Uno’s SDA and SCL at their own addresses, and the serial monitor prints both every second.

## Keep going

### Learn

- Arduino BH1750 Light Sensor: Lux, Wiring, Code
- I2C Explained: Addresses, Acknowledges and Pull-Ups

### Parts

- Ambient light, VEML7700

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280
- Sensirion I2C SHT3x
- SHT4x
- forcedBMX280
- BlueDot BME280 Library
- Grove - Barometer Sensor BME280
- SparkFun SCD4x Arduino Library

Every built-in library · Open the editor

## Try Adafruit VEML7700 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
