VEML6075 UV Sensor

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

Python Library

Turta_VEML6075 library is responsible for communicating with the VEML6075 sensor.

To install the library from the (PyPI) Python Package Index, enter the following command to the console.

pip install turta-iothat

Add the following statement to the top of your Python code.

from turta_iothat import Turta_VEML6075

Then, create an instance of the Turta_VEML6075 class.

veml6075 = Turta_VEML6075.VEML6075Sensor()

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

Initialization

The library automatically initializes the required components when its instance is being created, so there is no need to do a manual initialization.

Basic Members

Calculate Average UV Index

Calculates the Average UV Index.

float calculate_average_uv_index()
  • Parameters

    • None

  • Returns

    • Float: Average UV Index.

Calculate UV Index A

Calculates the UV Index A.

float calculate_uv_index_a()
  • Parameters

    • None

  • Returns

    • Float: UV Index A.

Calculate UV Index B

Calculates the UV Index B.

float calculate_uv_index_b()
  • Parameters

    • None

  • Returns

    • Float: UV Index B.

Advanced Members

Calculate Compensated UVA

Calculates compensated UVA.

float calculate_compensated_uva()
  • Parameters

    • None

  • Returns

    • Float: Compensated UVA.

Calculate Compensated UVB

Calculates compensated UVB.

float calculate_compensated_uvb()
  • Parameters

    • None

  • Returns

    • Float: Compensated UVB

Samples

You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Raspbian/Python address, and then copy it to the Raspberry Pi. There is one example of this library.

VEML6075 Sample App

This application demonstrates printing UV Index, UVA Index and UVB Index calculations from the sensor.

To run the example:

  1. Copy the library and sample code to a folder on the Raspberry Pi.

  2. Open terminal, and go to the folder you copied the codes.

  3. Run the sample with the following command:

python VEML6075SampleApp.py

Sample Code

VEML6075SampleApp.py
#! /usr/bin/python

import time
from turta_iothat import Turta_VEML6075
#Install IoT HAT library with "pip install turta-iothat"

#Initialize
veml6075 = Turta_VEML6075.VEML6075Sensor()

#Wait 1 second for the first sensor readings.
time.sleep(1.0)

try:
    while True:
        #Read & print UV Index
        print("UV Index........: " + str(round(veml6075.calculate_average_uv_index(), 4)))

        #Read & print UV Index A
        print("UV Index A......: " + str(round(veml6075.calculate_uv_index_a(), 4)))

        #Read & print UV Index B
        print("UV Index B......: " + str(round(veml6075.calculate_uv_index_b(), 4)))

        #Rest a bit
        print("-----")
        time.sleep(10.0)

#Exit on CTRL+C
except KeyboardInterrupt:
    print('Bye.')

Result

When you run the sample, it prints UV readings to the terminal. The example output should be like this:

UV Index........: 3.4567
UV Index A......: 2.3456
UV Index B......: 1.2345
-----

To stop the Python script, just press CTRL + C.

Last updated