Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Vi for VELM6075

I am looking if someone has any experience connecting a UV sensor VELM6075 via the i2c vi in Linx ? I am not how to configure the write and read vi ...

0 Kudos
Message 1 of 5
(1,469 Views)

Hey jagica, i have no experience on this sensor, but i'll try to help by telling you how i do connect i2c sensors when i don't have the library for that on LabVIEW. First, you can always use custom command functions to send and receive values from your main firmware, if you would like to use the arduino library inside your main loop (it was just an example).

 

however, sometimes we do look for something more challenging.

 

generally i go for the arduino library in github:https://github.com/NorthernWidget/VEML6075
there we find an example: https://github.com/NorthernWidget/VEML6075/blob/master/examples/VEML6075_Demo/VEML6075_Demo.ino

note that the creator does not use the wire.h library here, so it must be somewhere else. lets check the library files:

https://github.com/NorthernWidget/VEML6075/blob/master/VEML6075.h

and

https://github.com/NorthernWidget/VEML6075/blob/master/VEML6075.cpp

 

keep all those files opened and ready for reading!

 

now, the first thing the creator do on the example void setup() is calling UV.begin(). let's check out what this function does:

 

uint8_t VEML6075::begin()
// Initialize library for subsequent pressure measurements
{

Wire.begin(); // Arduino Wire library initializer

Wire.beginTransmission(ADR);
Wire.write(0x00);
Wire.write(0x00);
Wire.write(0x00);
return Wire.endTransmission(true); //Return sucess or failue of I2C connection
}

 

heey this is exactly what we do in LabVIEW when connecting through i2c. let me post a print screen (not a snippet):

jorgemondadori_0-1621596785376.png

Well, i don't know why the user does that. Let's check datasheet: https://cdn.sparkfun.com/assets/3/c/3/2/f/veml6075.pdf

looking at table 2, it looks like writing at 0x00 powers on the sensor.

 

ok now lets check the rest of the example code (just for fun, because for reading we just needed to point to reg 0x07 and read all remaining registers)
void loop() {
Serial.print("UVA = ");
Serial.print(UV.GetUVA()); //Get compensated UVA value
Serial.print(" UVB = ");
Serial.println(UV.GetUVB()); //Get compensated UVB value
delay(1000);
}

the creator uses UV.GeUVA() and UV.GetUVB() functions. lets see what those do in the library (i'll look for one only here):

hmmm those librarys call other libraries converting it, lets avoid all this math now. but looking closely, GetUVA() calls a function called ReadWord(). lets check this one!

 

hmm ok, know this function points using command, we need to check header .h file.

 

AHA!

 

in the header file we fing some definitions:

#define UVA_CMD 0x07
#define UVB_CMD 0x09
#define COMP1_CMD 0x0A
#define COMP2_CMD 0x0B

 

which are the exact address from table 5 from the datasheet!

 

now we just need to write using i2c to the first register address and request reading the next 8 bytes (for getting all data)

 

jorgemondadori_1-1621597854822.png

 

And i don't know if this will work. but now you have your path to follow.

 

let us know if this works!

 

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 2 of 5
(1,428 Views)

Hello Jorge,

 

Thanks for your response ! I have tried more or less what you proposed. (see in attachment) The VI run without errors, but the values read are not OK. I probably did something wrong in the math, or elsewhere. I had to read 10 bytes, and not 8, since there is a reserved byte after 0x07.

I'll be happy if you have any idea about what might be wrong.   😀

 

Jagica.   

0 Kudos
Message 3 of 5
(1,388 Views)

yeap, you do need to work your math.

 

can't help you, i don`t have this sensor here. but i'm glad that the post helped you to get those registers out through i2c! mark that answer as solution if you believe it answered your question.

 

to solve your math problem, check the library. here is how they make the conversion:

 

long ConversionTime = (1 << ((Config & 0x70) >> 4))*50; //Calculate ms conversion time = (2^UV_IT) * 50
if((Config | 0x02) >> 1) { //Test single shot bit
while((millis() - StartTime) < ConversionTime); //Wait if more time is needed
}
//In either case, measurment process is the same
float UVB = ReadWord(UVB_CMD);
float Comp1 = ReadWord(COMP1_CMD);
float Comp2 = ReadWord(COMP2_CMD);
float UVB_Comp = UVB - c*Comp1 - d*Comp2;

 

you also said the values are not ok, but do you see a correct direction in the signal(ie. the more radiation, bigger the signal)?

 

in my first answer i told you about custom command. if you do not want to work the math around, i suggest trying custom command. Let me post a tutorial for you:

 

https://blog.digilentinc.com/how-to-use-linx-custom-commands/

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 4 of 5
(1,374 Views)

Hello Jorge,

 

I believe the sensor is not measuring. The values I am reading are either 0 or 1....I probably need to initialize correctly the UV_Conf register (0x00), I guess some bit must be turn on to 1.

I'll give it a try when I found some time....and let you know.

0 Kudos
Message 5 of 5
(1,353 Views)