I get the error...
Code: Select all
#!/usr/bin/env python3 import smbus import time # Get I2C bus bus = smbus.SMBus(1) # VEML6075 address, 0x10(16) bus.write_word_data(0x10, 0x00, 0x0040) time.sleep(1.0) uva = bus.read_word_data(0x10, 0x07) uvb = bus.read_word_data(0x10, 0x09) uvcomp1 = bus.read_word_data(0x10, 0x0A) uvcomp2 = bus.read_word_data(0x10, 0x0B) UVA = uva * 1 # Added this just to see what would happen, no error # Output data to screen print ("Raw UVA is :" %uva)
Traceback (most recent call last):
File "./veml6075.py", line 22, in <module>
print ("Raw UVA is :" %uva)
TypeError: not all arguments converted during string formatting
The data sheet can be found here https://www.vishay.com/docs/84304/veml6075.pdf
At the top of page 6 it says...
"The VEML6075 contains a CONF register (00h) used for operation control and parameter setup. Measurement results are stored in four separate registers, one each for UVA, UVD, UVB, UVcomp1, and UVcomp2 (07h to 0Bh respectively). All registers are accessible via I2C communication. Fig. 7 shows the basic I2C communication with the VEML6075. Each of the registers in the VEML6075 are 16 bit wide, so 16 bit should be written when a write command is sent, and 16 bit should be read when a read command is sent."
And this why I'm having to use "bus.write_word_data" and "bus.read_word_data". So far I haven't been able to print anything. I've Googled and found the error message but none of the solutions seemed to make any difference. This is the first device I've used that had 16 bit vs. 8 bit registers. Any help would be welcomed.