I'm posting a reply here because I ran into similar problems trying to write python script for this component. This one of only two results I got google searching veml7700 and raspberry pi. I contacted Vishay and they were very helpful in working with this component.
Here is the sample python script I wrote for the VEML7700:
Code: Select all
bus = smbus.SMBus(1)
addr = 0x10
als_conf_0 = 0x00
als_WH = 0x01
als_WL = 0x02
pow_sav = 0x03
als = 0x04
white = 0x05
interrupt = 0x06
# These settings will provide the max range for the sensor (0-120Klx)
# but at the lowest precision:
# LSB MSB
confValues = [0x00, 0x13] # 1/8 gain, 25ms IT (Integration Time)
#Reference data sheet Table 1 for configuration settings
interrupt_high = [0x00, 0x00] # Clear values
#Reference data sheet Table 2 for High Threshold
interrupt_low = [0x00, 0x00] # Clear values
#Reference data sheet Table 3 for Low Threshold
power_save_mode = [0x00, 0x00] # Clear values
#Reference data sheet Table 4 for Power Saving Modes
bus.write_i2c_block_data(addr, als_conf_0, confValues)
bus.write_i2c_block_data(addr, als_WH, interrupt_high)
bus.write_i2c_block_data(addr, als_WL, interrupt_low)
bus.write_i2c_block_data(addr, pow_sav, power_save_mode)
#The frequency to read the sensor should be set greater than
# the integration time (and the power saving delay if set).
# Reading at a faster frequency will not cause an error, but
# will result in reading the previous data
time.sleep(.04) # 40ms
word = bus.read_word_data(addr,als)
gain = 1.8432 #Gain for 1/8 gain & 25ms IT
# 'Calculating the LUX Level'
val = word * gain
val = round(val,1) #Round value for presentation
print "Lux: " + str(val) + " lx"
I hope this helps the next pi user with trying to interface with this component. good luck.