VEML6030 PiicoDev sensor gain & integration time

Your VEML6030 driver has
_DEFAULT_SETTINGS = b’\x00’ # initialise gain:1x, integration 100ms, persistence 1, disable interrupt
With these settings the max lux value is 3775, which means the device saturates in bright sunlight.
How can I change the gain to 0.125 and integration time to 25mS in your driver?

Thanks
Bob Peake

Hi Bob,

Taking a look through the datasheet of the VEML6030 and finding the settings that you want. Compiling those bits into a 16 bit hex string then replacing that in the VEML module and uploading it to your target board (Pico, micro:bit, Pi…) would be the process.

1 Like

Hi Bob,

Welcome to the forum!!

Which dev board were you using to connect to the sensor?

Changing the _DEFAULT_SETTING in the device driver (PiicoDev_VEML6030.py on the Pico) will allow you to chop and change the settings.

As Liam mentioned you’ll need the datasheet to dial in the settings that you want and converting them to hex to save a few bytes of flash.

Liam.

1 Like

Liam,

Thanks for your reply below

You asked which board I am using. I purchased a couple of PiicoDev VEML6030 Ambient Light Sensor modules, and I am using one with a Wemos D1 mini ESP8266 board and attempting to use the other with a Raspberry Pi Pico mounted on a Core Piico Dev expansion board.

The application is to measure the level of full intensity sunlight falling on rooftop solar panels, so the VEML6030Â needs to be set up for full intensity sunlight.

I found it straight forward with the Arduino IDE to create a sketch to work with the VEML6030 module on the 8266 using the “SparkFun_VEML_Ambient_Light_Sensor.h” package. In this setup the VEML6030 gain and integration time are variables that can be set up in the application sketch, making it easy to setup the VEML6030 for a wide range of light environments. I did this first because I am much more familiar with the Arduino IDE.

I was then hoping to get the Core VEML6030 module working with the RPi Pico, mainly because of the lower power consumption of the Pico. The example code provided in the Core tutorial works well indoors, but saturates at about 3775 lux in direct sunlight (as per VEML6030 specification). I was hoping to discover a couple of gain and integration time commands that could be included in the application code (similar to the SparkFun arrangement) and would be recognised by the PiicoDev_VEML6030.py driver, but your advice below suggests that I have to modify the driver each time I want to vary the gain and integration time.

My reading of the VEML6030 data sheet suggests I need to change the default settings from b’\x00’ to b’\x13’ to set the gain to 0.125 and the integration time to 25mS, the recommendations for maximum light levels. So far I have not had much success doing this, but that is more likely my lack of familiarity with Thonny than anything else. However, I would be interested to have confirmation that b’\x13’ is correct for the settings I want.

As an alternate I may also try some other VEML6030 micropython drivers that do make the setup parameters available from the application code.

Thanks again,

Bob.

4 Likes

Hi Bob,

Adding support for easier configuration is definitely a good suggestion. I’ve migrated this feedback over to our PiicoDev VEML6030 Github Repo and we’ll explore some options in the coming days/weeks.

3 Likes

Good morning Graham,

Thanks for looking into this. I look forward to hearing more.

I would like to commend Core on the design of the PiicoDev hardware modules. I find the ability to daisy chain I2C modules via a robust plug and socket system makes a prototyping system that is much more reliable than the typical breadboard setup.

Regards

Bob.

3 Likes

I’m hooking into this now @Robert47730 and will have a fresh commit ready by then end-of-day.

1 Like

@Robert47730 the latest commit in the repo now features the setGain() function that accepts 0.125, 0.5, 1, 2 as input arguments.

You can initialise the sensor to 1/8 gain by eg.

from PiicoDev_VEML6030 import PiicoDev_VEML6030
from PiicoDev_Unified import sleep_ms

# Initialise Sensor
light = PiicoDev_VEML6030()
light.setGain(0.125) # set gain to 1/8, increase maximum illumination, decrease resolution

while True:
    print(light.read())
    sleep_ms(1000)

Since all links in guides point to the repo, if you’re on RPi Pico or micro:bit you can just redownload the PiicoDev_VEML6030.py file from a tutorial, or from here.

Integration time to follow.

2 Likes

Thanks for the update. I look forward to trying it out later in the week. I am sure it will make the VEML6030 module easier to use in a full range of light conditions.

Regards

Bob.

1 Like