An ESP32 and VEML7700 lux sensor example using the Arduino IDE

esp32 and veml7700 layout
esp32 and veml7700 layout

In this article we look at the VEML7700  which is an ambient light digital 16-bit resolution sensor – we will take a look at some of the technical info on the sensor, show you the layout and a code example using the Arduino IDE

This is the sensor that I bought for this example

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


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


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

Name Link
LOLIN32 ESP32 WeMos Mini D1 LOLIN32 ESP32
VEML7700 Adafruit 4162 VEML7700 Lux Sensor – I2C Light Sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire



This is an easy sensor to connect – simply connect SDA and SCL from the ESP32 board and then connect the power pins.

You can see this in the layout below.

esp32 and veml7700 layout
esp32 and veml7700 layout


Code Example

This uses the library from

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

#include <Wire.h>
#include "DFRobot_VEML7700.h"
DFRobot_VEML7700 als;
void setup()
void loop()
  float lux;
  Serial.println(" lx");


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

Lux:108.22 lx
Lux:177.54 lx
Lux:192.98 lx
Lux:203.96 lx
Lux:62.78 lx
Lux:25.92 lx
Lux:20.70 lx
Lux:19.08 lx
Lux:18.68 lx
Lux:20.24 lx
Lux:19.57 lx
Lux:20.21 lx
Lux:37.35 lx
Lux:44.85 lx





Previous articleA look at the ESP32 PICO KIT development board
Next articleESP32 and TSL2591 light-to-digital converter example using the Arduino IDE