Easy IoT is a simplest IoT Solution presented by DFRobot
By robidouxj
#14537
I had difficulties setting this up for raspberry pi. While I've used i2c components, I was unfamiliar with programming to the i2c bus directly. With other sensors I've used, I was able to find python packages that handled the i2c for the component.

After a bit of research, I contacted Vishay and they were quite helpful. With there assistance I was able to develop a simple test program in Python for the VEML7700. In addition to the datasheet, useful information can be found at:
http://www.vishay.com/docs/84323/designingveml7700.pdf

Here is the sample python script I wrote using smbus:
Code: Select all
import smbus
import time

bus = smbus.SMBus(1)

addr = 0x10

#Write registers
als_conf_0 = 0x00
als_WH = 0x01
als_WL = 0x02
pow_sav = 0x03

#Read registers
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)

while True:
	#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
	#Reference www.vishay.com/docs/84323/designingveml7700.pdf
	# 'Calculating the LUX Level'
	
	val = word * gain
	val = round(val,1) #Round value for presentation
		
	print "Lux: " + str(val) + " lx"
Hopefully this helps the next pi programmer trying to use this component. Good luck.

Joe Robidoux