0

Print the correct integration time in VEML6075_simpletest.py
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Print the correct integration time in VEML6075_simpletest.py

by Attilio57 on Thu Jun 13, 2019 2:46 pm

I recently bought the board VEML6075 and I noticed that the proposed code to demonstrate the usage of the sensor (VEML6075_simpletest.py), prints an integration time value different from the one set in the same code (see https://learn.adafruit.com/adafruit-vem ... cuitpython)

I tried to understand the problem and I modified the file adafruit_veml6075.py found in the Adafruit_CircuitPython_VEML6075 library package (see https://github.com/adafruit/Adafruit_Ci ... n_VEML6075)

I added the import of the "collections" class:

import collections

and I loaded the _VEML6075_UV_IT elements in an ordered dictionary, not in a normal dictionary, replacing:

_VEML6075_UV_IT = { 50: 0x00,
100: 0x01,
200: 0x02,
400: 0x03,
800: 0x04 }

with:

_VEML6075_UV_IT = collections.OrderedDict ()

_VEML6075_UV_IT [50] = 0x0
_VEML6075_UV_IT [100] = 0x1
_VEML6075_UV_IT [200] = 0x2
_VEML6075_UV_IT [400] = 0x3
_VEML6075_UV_IT [800] = 0x4

In this way I got as a result of:

print ("Integration time:% d ms"% veml.integration_time)

the correct value.

The problem din't arise in setting the value but only in recalling the printing because the elements in the dictionary didn't appear in the order required for a key search in the function integration_time(self):

Before the change indicate, setting the integration time to 100 in the proposed code:

veml = adafruit_veml6075.VEML6075 (i2c, integration_time = 100)

the printed result was 400 ms.

Unmatched printed values were also obtained setting it to 50, 200 and 400 ms. 800 ms was the only value in which the set and printed value corresponded.

Attilio57
 
Posts: 3
Joined: Thu Jun 13, 2019 12:13 pm

Please be positive and constructive with your questions and comments.