cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble with I2C interfacing...with a VEML7700 sensor

NPoli
Associate

I am trying to interface with a VEML7700 light sensor. Specifically I need to generate the following request:

<start><0x10><Wr><ACK><0x04><ACK><start><0x10><Rd><ACK><8bitdata><ACK><8bitdata><ACK><NAK><STOP> where: <Wr> is a single zero bit, <Rd> is a single one bit, and things in bold come FROM the sensor.

When i use the HAL_I2C_Master_Transmit and HAL_I2C_Master_Receive calls to first transmit the <0x10><Wr><0x04> and then the receive call to request the data I end up generating:

<start><0x10><Wr><ACK><0x04><ACK><STOP><Start><0x10><Rd><ACK><8bitdata><ACK><8bitdata><ACK><STOP>

That <STOP> in the middle is killing me. How do I make the request without having the HAL_I2C_Master_Transmit generate a <STOP>? That <STOP> in the middle resets the transaction with the sensor and all I get back are zeros. I have a sensor hooked up to a Pi and I can get proper responses using i2cget but it does not insert that <STOP>.

Thanks for insights. I'm going nuts here!

2 REPLIES 2
SShin.18
Associate II

I used I2C protocol for temperature and humidity sensor interfacing with STM32L4xx.

  1. I2C pins should be configured in Open drain mode with no pull_up pull_down (PUPD)
  2. when you are expecting reading from sensor then you should not configure command with auto end, command should be with software end.
  3. after sending command, restart configuration should be used and transfer direction should be changed to receive mode, without altering any other configuration values. only CR2 values should be changed.
  4. after receiving data from sensor stop condition should be send.
  5. access to the I2C Register should be made using 32bit access.

if all above configuration is used for I2C, interface should work fine.

check your sensors data sheet as I'm unaware with this sensor.

Keep Going =)

NPoli
Associate

Thanks. I thought that using software end was the approach. How do you set that up specifically?

Thanks so much for the reply. Your outline seems right.