Simple test
Ensure your device works with this simple test.
examples/veml6070_simpletest.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4# VEML6070 Driver Example Code
5
6import time
7
8import board
9
10import adafruit_veml6070
11
12i2c = board.I2C() # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
14
15uv = adafruit_veml6070.VEML6070(i2c)
16# Alternative constructors with parameters
17# uv = adafruit_veml6070.VEML6070(i2c, 'VEML6070_1_T')
18# uv = adafruit_veml6070.VEML6070(i2c, 'VEML6070_HALF_T', True)
19
20# take 10 readings
21for j in range(10):
22 uv_raw = uv.uv_raw
23 risk_level = uv.get_index(uv_raw)
24 print(f"Reading: {uv_raw} | Risk Level: {risk_level}")
25 time.sleep(1)
DisplayIO Simpletest
This is a simple test for boards with built-in display.
examples/veml6070_displayio_simpletest.py
1# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2# SPDX-FileCopyrightText: 2024 Jose D. Montoya
3#
4# SPDX-License-Identifier: MIT
5
6# Simple demo of the VEML6070 UV sensor using a built-in display.
7import time
8
9import board
10from adafruit_display_text.bitmap_label import Label
11from displayio import Group
12from terminalio import FONT
13
14import adafruit_veml6070
15
16# create a main_group to hold anything we want to show on the display.
17main_group = Group()
18# Initialize I2C bus and sensor.
19i2c = board.I2C() # uses board.SCL and board.SDA
20uv = adafruit_veml6070.VEML6070(i2c)
21
22# Create a Label to show the readings. If you have a very small
23# display you may need to change to scale=1.
24display_output_label = Label(FONT, text="", scale=2)
25
26# place the label in the middle of the screen with anchored positioning
27display_output_label.anchor_point = (0, 0)
28display_output_label.anchored_position = (4, board.DISPLAY.height // 2)
29
30# add the label to the main_group
31main_group.append(display_output_label)
32
33# set the main_group as the root_group of the built-in DISPLAY
34board.DISPLAY.root_group = main_group
35
36# begin main loop
37while True:
38 # Update the label.text property to change the text on the display
39 uv_raw = uv.uv_raw
40 display_output_label.text = f"Reading: {uv_raw} Risk Level: {uv.get_index(uv_raw)} lux"
41 # wait for a bit
42 time.sleep(0.5)