<< Click to Display Table of Contents >>

Navigation:  Bits and PCs Blog - 2025.12.06 >

VEML7700 and VEML6030 High Accuracy Ambient Light Sensors - 2025.11.01

Previous pageReturn to chapter overviewNext page

The Vishay VEML7700 and VEML6030 chips are among the best I2C ambient light sensors. They return very accurate Lux readings over an incredibly wide range, from 0 to over 140000 lux with resolution down to 0.0042 lux-per-count using a 16-bit A/D converter. (The range is almost as good as the Cheap LDR Lux Sensor :-) They are sensitive to the same range of light as the human eye, so you don't need code to remove the infrared light component from the readings. They also contain a separate wide-range 'white channel' sensor, have 100Hz and 120Hz flicker noise rejection, and excellent temperature compensation.

Both chips are almost the same. Except the VEML6030 has a programmable interrupt output (INT), can have two I2C addresses (0x10 and 0x48), and is much smaller in size. The VEML7700 has a fixed address (0x10) and does not have the interrupt output, but you can poll it to see if the interrupt is pending with readInterruptStatus().

These chips also have very low power operation through shut down or power saving mode, making them ideal for battery operation. Refer to the application notes for details.

This post also presents an improved VEML7700 library with non-blocking methods so your program doesn't hang for up to 2 seconds while a reading is taken.

 

Modules

The chips are tiny, so it's best to buy a module. Two modules were evaluated, the Adafruit VEML7700 and the Sparkfun VEML6030. See the links at the end of this page.

veml7700-adafruit veml6030-sparkfun

The Adafruit board runs on 3.3 or 5V because it has a nice on-board 3V regulator and on-board level shifters for I2C, and it has a 3Vo OUTPUT which is a 3V output from the regulator. The Sparkfun board runs ONLY on 3.3V, and has an additional /INT output.

Both boards have power LEDS which look nice, but at low light levels these interfere with the readings! Thankfully, both boards have a jumper on the back which can be cut to disconnect the LED.

Readings are taken at a rate which depends on the configured integration time (25..800ms). The official libraries use delay() everywhere to wait until the reading is ready. These methods block for many milliseconds (up to 2x the delay), which is not good. It would have been nice if Vishay had provided a polled "ready" status bit instead of having to use delays. But the Mattlabs library solves this problem with the non-blocking readyToRead() method, so you don't need to use delays and the program can keep running while waiting for a reading. See the example in the source code.

The Lux readings are linear up to 1000 Lux, but higher levels (using a gain of 1/8 or 1/4) are non-linear and must be adjusted using the correction formula (see App Notes p5, "Calculating the Lux Level"). An optimised version of this formula is used in the correctLux() method.

 

Dynamic Range Adjustment

The chips have an adjustable gain and integration time to configure the chip. To support the full Lux range, these settings must be dynamically adjusted according to the actual light level. The application note contains an algorithm for automatically optimising these settings according to the light level, see App Notes p21 and the flowchart below. This can be very slow - at low light levels the algorithm takes up to 2 seconds! Blocking for this long is not usually acceptable in a microcontroller program, so the Mattlabs library code (see below) has an optimised non-blocking version called autoReadLux().

 

veml7700-algorithm

 

Vishay Data Sheets

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

Vishay Application Notes

https://www.vishay.com/docs/84323/designingveml7700.pdf
https://www.vishay.com/docs/84367/designingveml6030.pdf

 

Mattlabs C++ Source Code

Copy/paste the code into your sketch files. It should run on any Arduino compatible board. It's been tested on an STM32F103RB Nucleo and an Arduino Uno. Note that the Uno does not support floating point in sprintf(), so you must use %lu (see commented out line in the sketch), or use the Mattlabs floating point conversion routines. Although the Lux readings are returned as float values, they can be converted to 'unsigned long' (ulong) unless you are reading very low Lux levels and need the decimal places.

Most methods return true=success or false=failed. The same code works for the VEML7700 and VEML6030 versions.

Unlike the Adafruit and Sparkfun libraries, the Mattlabs library has non-blocking functions which do not lock up the microcontroller with delays while waiting for readings, see the readyToRead() and autoReadLux() methods.

  VEML7700LightSensor.h   [Click to show/hide the code]

Here's an example sketch...

  VEML7700.ino   [Click to show/hide the code]

 

I2C Addresses

Adafruit VEML7700: One fixed address, 0x10.

Sparkfun VEML6030: Two addresses, selectable via the ADDR pin, 0x48 (ADDR=VDD) or 0x10 (ADDR=GND). Use the jumper on the back.

 

Adafruit Board

https://learn.adafruit.com/adafruit-veml7700/overview

Schematic
https://learn.adafruit.com/adafruit-veml7700/downloads

Sparkfun Board

https://learn.sparkfun.com/tutorials/qwiic-ambient-light-sensor-veml6030-hookup-guide

Schematic
https://cdn.sparkfun.com/assets/learn_tutorials/9/1/5/SparkFun_Ambient_Light_Sensor_VEML6030.pdf

 

Official Arduino Libraries

The Mattlabs library (see above) is recommended, but these implementations can be used for reference.

Adafruit Library
This library is OK, but at low light levels the auto-resolution algorithm blocks for over 2 seconds - it is not usable! Instead of using shutDown(true/false) to start a new conversion as is shown in the Vishay flow chart, it doubles the length of the delay, making it even slower. I think it doesn't implement the algorithm correctly either, the check for >10000 counts is not done as shown in the flow chart (but maybe that doesn't matter). The Mattlabs library does not have these problems.
https://github.com/adafruit/Adafruit_VEML7700

Sparkfun Library
This library is not recommended. It does not use the 'correction formula', it does not implement the auto-resolution algorithm, and it requires the unnecessary "Sparkfun Toolkit".
https://github.com/sparkfun/SparkFun_VEML7700_Arduino_Library