VEML6070 I2C problems in reading (CYBLE 222014)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
NIFR_4499596
Level 2
Level 2
Welcome! 5 replies posted First question asked

Hi everybody,

I'm working on CYBLE222014, to read data from an UV sensor from Vishay (VEML6070). This sensor has one write register(0x70>>1) and two read register(0x71>>1 and 0x73>>1), for UV MSB and LSB. In the  datasheet they say to inizialize the sensor with 2 step: first read ACK register(0x18>>1) and second write 0x06 in write register(0x70>>1); than you can read the UV value from the 2 registers, but if i run my code i read only 0x0000. I think i make a mistake in the read function, but I checked many times and seems OK.

Any idea to solve?

Best Regards

Francesco

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Briefly reading your I2C_Utils are doing more complicated things than mine.

By any chance, can you modify my program to use the slave_address of your sensor and register command?

Or use some blank project with my i2c_utils.c/h just set slave_address to your sensor and call read_reg,

since VEML_6075 and VEML_6070 sound quite close, those utilities may work.

Then you can compare functions for difference(s).

moto

View solution in original post

0 Likes
11 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I wonder if you added pull-up resistors externally?

Both SCL and SDA need to be pulled up with 2K ~ 10K resistors to VDD.

If you have already  done it, I'm sorry.

moto

0 Likes

Yes I added 4.7K resistor.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Then it should be fine.

I like to use 4.7K, too.

Sorry for disturbing.

moto

0 Likes

I tested the sensor with Arduino and works fine so the hardware should be OK. The problem is in the code I wrote, but I don't undrestand where I made a mistake.

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Just for your information.

Attached is my old program for Vishay veml6075 for CY8CKIT-044.

So both sensor and board are different,

but I hope that I2C functions could be some hint.

moto

0 Likes

Thank you Moto,

the differences are in this  photo:

pastedImage_0.png

I don't understand if to read a data I have to call:

I2C_I2CMasterSendStart(VEML6070_I2C_ADDRESS_W, 0, 1);

I2C_I2CMasterWriteByte(....);

and then call the read function

I2C_I2CMasterSendRestart(VEML6070_I2C_ADDRESS_R_MSB, 1, 1) ;

I2C_I2CMasterReadByte()

and then call the stop and do the same to read the LSB register.

From the picture seems i  have to call only the SendStart(VEML_6070_i2C_ADDRESS_R_MSB,1,1) and than read the byte, and do the same with the other register read for LSB.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Briefly reading your I2C_Utils are doing more complicated things than mine.

By any chance, can you modify my program to use the slave_address of your sensor and register command?

Or use some blank project with my i2c_utils.c/h just set slave_address to your sensor and call read_reg,

since VEML_6075 and VEML_6070 sound quite close, those utilities may work.

Then you can compare functions for difference(s).

moto

0 Likes

Ok, I try and let you know!

Francesco

0 Likes

I tried with your code but nothing changed, i get 0x0000 everytime i ask to read UV register

0 Likes

Hi Momo,

Thank you so much. From your comments and re-reading datasheet, I was able to get it running. The problems were the timing and the delay, after setting your CyDelay(1) and the 300us during the read,write and stop function everything works!!!

Francesco

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Francesco-san,

Thanks for the good news!

You made my day 😉

Best Regards,

22-May-2020

Motoo Tanaka

0 Likes