VEML6075 UV Sensor

Last updated last month

This documentation includes installation guidelines and sample code for your hardware.

Windows 10 IoT Core Library

VEML6075Sensor library is responsible for communicating with the VEML6075 UV sensor.

To use the library, add the following using statement to the top of your C# code.

using TurtaIoTHAT;

Then, create an instance of the VEML6075Sensor class.

VEML6075Sensor veml;

Now you're ready to access the library by calling the veml instance.

Initialization

VEML6075Sensor

Initiates the VEML6075 sensor to get UVA, UVB and UVIndex.

VEML6075Sensor()
  • Parameters

    • None

Basic Members

Calculate Average UV Index

Calculates the Average UV Index.

double Calculate_Average_UV_Index()
  • Parameters

    • None

  • Returns

    • Double: Average UV Index.

Calculate UV Index A

Calculates the UV Index A.

double Calculate_UV_Index_A()
  • Parameters

    • None

  • Returns

    • Double: UV Index A.

Calculate UV Index B

Calculates the UV Index B.

double Calculate_UV_Index_B()
  • Parameters

    • None

  • Returns

    • Double: UV Index B.

Advanced Members

Configure Sensor

Configures the VEML6075 sensor. Verifies if the settings are stored.

async Task<bool> Config(IntegrationTime UV_IT, DynamicSetting HD, Trigger UV_TRIG, ActiveForceMode UV_AF, PowerMode SD)
  • Parameters

    • IntegrationTime UV_IT: UV integration time.

    • DynamicSetting HD: Dynamic setting.

    • Trigger UV_TRIG: Measurement trigger.

    • ActiveForceMode UV_AF: Active force mode.

    • PowerMode SD: Power mode.

  • Returns

    • Bool: True if settings are stored. False if not.

Trigger One Measurement

Triggers one time measurement for Active Force Mode enabled scenarios.

void TriggerOneMeasurement()
  • Parameters

    • None

  • Returns

    • None

Calculate Compensated UVA

Calculates compensated UVA.

double Calculate_Compensated_UVA()
  • Parameters

    • None

  • Returns

    • Double: Compensated UVA.

Calculate Compensated UVB

Calculates compensated UVB.

double Calculate_Compensated_UVB()
  • Parameters

    • None

  • Returns

    • Double: Compensated UVB

Read RAW UVA

Reads RAW UVA.

UInt16 Read_RAW_UVA()
  • Parameters

    • None

  • Returns

    • UInt16: RAW UVA Value.

Read RAW UVB

Reads RAW UVB.

UInt16 Read_RAW_UVB()
  • Parameters

    • None

  • Returns

    • UInt16: RAW UVB Value.

Read RAW UVD

Reads RAW UVD.

UInt16 Read_RAW_UVD()
  • Parameters

    • None

  • Returns

    • UInt16: RAW UVD Value.

Read RAW UV COMP 1

Reads Noise Compensation Channel 1 data which allows only visible noise to pass through.

UInt16 Read_RAW_UVCOMP1()
  • Parameters

    • None

  • Returns

    • UInt16: UV Comp 1 Value.

Read RAW UV COMP 2

Reads Noise Compensation Channel 2 data which allows only infrared noise to pass through.

UInt16 Read_RAW_UVCOMP2()
  • Parameters

    • None

  • Returns

    • UInt16: UV Comp 2 Value.

Disposal

To clean up the resources used by the class, call the Dispose() method it when the application is closing.

void Dispose()

This method cleans the resources used by the class.

Samples

You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Windows10IoTCore address. There is one example of this library.

VEML6075 Sample App

This application demonstrates reading UV data from the sensor.

To run the example:

  1. Open the sample project you downloaded.

  2. Make sure "ARM" is selected from the solution platforms selection.

  3. Deploy the sample to the Raspberry Pi using the "F5" key.

Sample Code

MainPage.xaml.cs
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using TurtaIoTHAT;
namespace VEML6075SampleApp
{
public sealed partial class MainPage : Page
{
// VEML6075 Sensor
static VEML6075Sensor veml;
// Sensor timer
Timer sensorTimer;
public MainPage()
{
this.InitializeComponent();
// Initialize sensor and timer
Initialize();
}
private async void Initialize()
{
// Initialize and configure sensor
await InitializeVEML6075();
// Configure timer to 2000ms delayed start and 2000ms interval
sensorTimer = new Timer(new TimerCallback(SensorTimerTick), null, 2000, 2000);
}
private async Task InitializeVEML6075()
{
// Create sensor instance
veml = new VEML6075Sensor();
// Advanced sensor configuration
await veml.Config(
VEML6075Sensor.IntegrationTime.IT_800ms,
VEML6075Sensor.DynamicSetting.High,
VEML6075Sensor.Trigger.NoActiveForceTrigger,
VEML6075Sensor.ActiveForceMode.NormalMode,
VEML6075Sensor.PowerMode.PowerOn
);
}
private static void SensorTimerTick(object state)
{
// Write sensor data to output / immediate window
Debug.WriteLine("UVA........: " + veml.Read_RAW_UVA().ToString());
Debug.WriteLine("UVB........: " + veml.Read_RAW_UVB().ToString());
Debug.WriteLine("UVA Index..: " + veml.Calculate_UV_Index_A().ToString());
Debug.WriteLine("UVB Index..: " + veml.Calculate_UV_Index_B().ToString());
Debug.WriteLine("UV Index...: " + veml.Calculate_Average_UV_Index().ToString());
Debug.WriteLine("-----");
}
}
}

Result

When you run the sample, it prints the UV data to the Visual Studio Output / Immediate Window.

UVA........: 1.2345
UVB........: 1.2345
UVA Index..: 1.2345
UVB Index..: 1.2345
UV Index...: 1.2345
-----

To stop the application, use the "Stop" button on the Visual Studio.