A Vishay library for devices VEML6040 R+G+B+W and VEML6075 UVA+UVB optical sensors. Data is stored in a dedicated data structure.

Dependents:   vmel60xx_hello_world

This device library is for use with the Vishay VEML6040 and VEML6075 optical sensors. Ambient light conditions are gathered and stored in a user accessible data structure veml60xx_struct. The library has enough intelligence to determine which device is connected and performs the appropriate functions.

The VEML6040 detects Red, Green, Blue and White light data, which is easily converted to relative Lux intensities.

The VEML6075 detects UVA and UVB light which is converted to a UV Index value.

Since both devices use the same I2C address, they cannot be on the same I2C bus at the same time.

Tested on a K64F

Revision:
3:dda770fa7228
Parent:
2:c17b84879a2f
Child:
4:0ce65ee5697f
--- a/veml60xx.cpp	Mon Apr 25 22:35:08 2016 +0000
+++ b/veml60xx.cpp	Wed Apr 27 22:24:37 2016 +0000
@@ -89,24 +89,24 @@
     if(Pntr.is6075) {
         switch (c) {
             case VEML60xx_CONF_BITS_IT_50m40m: 
-                Pntr.uva_step = VEML6075_UVA_RESP * 16.0;
-                Pntr.uvb_step = VEML6075_UVB_RESP * 16.0;
-                break;
-            case VEML60xx_CONF_BITS_IT_100m80m:
-                Pntr.uva_step = VEML6075_UVA_RESP * 8.0;
-                Pntr.uvb_step = VEML6075_UVB_RESP * 8.0;
-                break;
-            case VEML60xx_CONF_BITS_IT_200m160m:
-                Pntr.uva_step = VEML6075_UVA_RESP * 4.0;
-                Pntr.uvb_step = VEML6075_UVB_RESP * 4.0;
-                break;
-            case VEML60xx_CONF_BITS_IT_400m320m:
                 Pntr.uva_step = VEML6075_UVA_RESP * 2.0;
                 Pntr.uvb_step = VEML6075_UVB_RESP * 2.0;
                 break;
+            case VEML60xx_CONF_BITS_IT_100m80m:
+                Pntr.uva_step = VEML6075_UVA_RESP * 1.0;    //reference dwell time (100mS) from app note
+                Pntr.uvb_step = VEML6075_UVB_RESP * 1.0;
+                break;
+            case VEML60xx_CONF_BITS_IT_200m160m:
+                Pntr.uva_step = VEML6075_UVA_RESP * 0.5;
+                Pntr.uvb_step = VEML6075_UVB_RESP * 0.5;
+                break;
+            case VEML60xx_CONF_BITS_IT_400m320m:
+                Pntr.uva_step = VEML6075_UVA_RESP * 0.25;
+                Pntr.uvb_step = VEML6075_UVB_RESP * 0.25;
+                break;
             case VEML60xx_CONF_BITS_IT_800m640m:
-                Pntr.uva_step = VEML6075_UVA_RESP * 1.0;
-                Pntr.uvb_step = VEML6075_UVB_RESP * 1.0;
+                Pntr.uva_step = VEML6075_UVA_RESP * 0.125;
+                Pntr.uvb_step = VEML6075_UVB_RESP * 0.125;
                 break;
             default:
                 Pntr.uva_step = 0.0;
@@ -264,4 +264,4 @@
     return false;
 }
             
-    
\ No newline at end of file
+