Download the sample code from https://github.com/Turta-io/Sensor-uHAT/blob/master/Samples/Python/light.py​
Copy the sample code to a folder on the Raspberry Pi.
Open terminal, and then go to the folder you copied the sample.
Run the sample with the following command:
python3 light.py
light.py#!/usr/bin/env python3​#This sample demonstrates reading the IR and UV Index.#Install Sensor uHAT library with "pip3 install turta-sensoruhat"​from time import sleepfrom turta_sensoruhat import Turta_UV_Light​#Initializelight = Turta_UV_Light.UVAmbientLightSensor()​try:while True:#Read UV Indexuv = light.read_uv()​#Read Raw IRir = light.read_ir()​#Print the readingsprint("UV Index........: " + str(round(uv, 1)))print("IR Raw Value....: " + str(ir))​#Waitsleep(2.0)​#Exit on CTRL+Cexcept KeyboardInterrupt:print('Bye.')
When you run the sample, it prints the light data. The example output should be like this:
UV Index........: 3.4IR Raw Value....: 0-----
To stop the Python script, just press CTRL + C.