Help on I2C for VEML7700

If doesn't fit into any other category ....
Post Reply
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Help on I2C for VEML7700

Post by AndyGadget »

Hi All,
I'm pulling my hair out over trying to get a VEML7700 I2C ambient light detector working.
Datasheet : https://www.vishay.com/docs/84286/veml7700.pdf

The device is correctly detected on the I2C bus at &H10 but I can only return zero values from registers &H04 and &H05 which should contain the ambient light values. I have tried various other configuration parameters in the control registers but still only zeroes returned.
With the control values in my code, a fresh reading should be returned after 900mS.
Is my code addressing the device in the right way or am I misunderstanding the IOBUFF usage?
(Running Annex32 WiFi 1.41 beta 5.)

Code: [Local Link Removed for Guests]

I2C.SETUP 13,15

' Reading ambient light level from VEML7700

IOBUFF.DIM(1, 2) ' Receive buffer
IOBUFF.DIM(0, 2) = &B00000010, &B00000000 ' Transmit buffer 
I2C.WRITE_IOBUFF(0,2), &H10, &H00
IOBUFF.DIM(0, 2) = &B00000000, &B00000000
I2C.WRITE_IOBUFF(0,2), &H10, &H03

for x = 1 to 20
  I2C.READ_IOBUFF(1), &H10, &H04, 2
  LHi = IOBUFF.READ(1, 0)
  LLo = IOBUFF.READ(1, 1)
  wlog LHi, LLo
  pause 100
next x
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Help on I2C for VEML7700

Post by PeterN »

Hi Andy,

I did not dig deep but perhaps found a good guideline from someone with a similar problem with this sensor.
https://www.raspberrypi.org/forums/view ... p?t=198082

Good luck
GSontag
Posts: 18
Joined: Wed Feb 10, 2021 9:38 am
Location: Antony,France
Has thanked: 2 times
Been thanked: 5 times

Re: Help on I2C for VEML7700

Post by GSontag »

Hello Andy,
I had a look at the data sheet:
Image

The address to write is acording the datasheet : h20
and to read is h21

The slave address is 7bits then shifted left and a bit for write (0) or read (1) is added to form an 8bit address.command

May be the beginning of the problem.

Gérard
You do not have the required permissions to view the files attached to this post.
Tool Kit 1.22
Annex32 WiFi 1.43.2
Windows 10-64b
Firefox 86.0
Serial TeraTerm 4.105
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Help on I2C for VEML7700

Post by AndyGadget »

Thanks Peter and GSontag.

Comparing my code to CiccioCB's for the ADS1115
HERE
he is using the base address of the device. The I2C commands take care of the bit shifting for the read and write functions.

I've tried the parameters in the Python sample but still returning zeroes, although I have realised that I was sending MSB,LSB where it should be LSB, MSB. I'm now sure that the zero values are actually read from the device as setting to an invalid address returns an IO buffer length of zero and throws an invalid subscript error. I can also pre-initialise the read buffer and these values are overwritten.

I am now going to load up the Adafruit Arduino sketch for this to check that the device is actually working correctly.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Help on I2C for VEML7700

Post by AndyGadget »

just an update on this . . .

I loaded up an Arduino sketch and the device works correctly.
I've tried my Annex code with configuration variations on the original and a different ESP32 module but still only zeroes back from the sensor.
I've also tried an old version of Annex and re-wrote the program using the deprecated I2C.ReadRegArray but still no joy, so I'm giving up for now.
Post Reply