Qwiic UV Sensor (VEML6075) Hookup Guide

Pages
Contributors: Englandsaurus
Favorited Favorite 2

Library Overview

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

First, you'll need the SparkFun VEML6075 Arduino library. You can obtain these libraries through the Arduino Library Manager. Search for Sparkfun VEML6075 Arduino Library to install the latest version. If you prefer downloading the library from the GitHub repository and manually installing it, you can grab them here:

Before we get started developing a sketch, let's look at a pertinent enum, VEML6075_error_t. Many of our functions will return this data type as a way of pointing out errors. The enum is shown below, notice how negative numbers are returned for errors, while a 1 is returned for a success.

language:c
typedef enum {
    VEML6075_ERROR_READ            = -4,
    VEML6075_ERROR_WRITE           = -3,
    VEML6075_ERROR_INVALID_ADDRESS = -2,
    VEML6075_ERROR_UNDEFINED       = -1,
    VEML6075_ERROR_SUCCESS         = 1
} VEML6075_error_t;

Setup

  • boolean begin(void) --- Returns true if the VEML6075 is attached properly.

  • VEML6075_error_t begin(TwoWire &wirePort) --- Give begin() a TwoWire port to specify the I2C port

  • void setDebugStream(Stream &debugPort = Serial) --- Enables debug statements, defaults to Serial for output

  • boolean isConnected(void) --- Returns true if the VEML6075 is attached properly.

Configuration

  • VEML6075_error_t setIntegrationTime(veml6075_uv_it_t it) --- Set integration time for a measurement to 50, 100, 200, 400, or 800 ms. The options for the veml6075_uv_it_t enum are shown below. IT_50MS,
    • IT_50MS
    • IT_100MS
    • IT_200MS
    • IT_400MS
    • IT_800MS
    • IT_RESERVED_0
    • IT_RESERVED_1
    • IT_RESERVED_2
    • IT_INVALID    

  • veml6075_uv_it_t getIntegrationTime(void) --- Returns the current integration time

  • VEML6075_error_t setHighDynamic(veml6075_hd_t hd) --- Changes to high dynamic mode by passing in DYNAMIC_HIGH and normal dynamic mode by passing in DYNAMIC_NORMAL. High dynamic mode increases the resolution by a factor of 2.

  • veml6075_hd_t getHighDynamic(void) --- Returns the current high dynamic setting.

  • VEML6075_error_t setTrigger(veml6075_uv_trig_t trig) --- Set's trigger to continuos read (NO_TRIGGER) or (TRIGGER_ONE_OR_UV_TRIG)

  • veml6075_uv_trig_t getTrigger(void) --- Returns current trigger mode as NO_TRIGGER, TRIGGER_ONE_OR_UV_TRIG or TRIGGER_INVALID.

  • VEML6075_error_t trigger(void) --- Triggers once.

  • VEML6075_error_t setAutoForce(veml6075_af_t af) --- With auto force enabled, the UV sensor will conduct one measurement whenever the host writes TRIGGER_ONE_OR_UV_TRIG to setTrigger(), otherwise, the VEML6075 continuously takes measurements. Passing in AF_DISABLE or AF_ENABLE will disable and enable the auto force mode.

  • veml6075_af_t getAutoForce(void) --- Returns the current auto force setting as AF_DISABLE, AF_ENABLE, or AF_INVALID

  • VEML6075_error_t powerOn(boolean enable = true) --- Powers the VEML6075 on from shutdown mode.

  • VEML6075_error_t shutdown(boolean shutdown = true) --- Puts the VEML6075 in shutdown mode (800 nA)

  • uint16_t rawUva(void) --- Reads raw UVA data

  • uint16_t rawUvb(void) --- Reads raw UVB data

  • float uva(void) --- Returns UVA data, adjusted with values from the UV compensation registers.

  • float uvb(void) --- Returns UVA data, adjusted with values from the UV compensation registers.

  • float index(void) --- Returns the UV index.

  • float a(void) --- Returns UVA data, adjusted with values from the UV compensation registers.

  • float b(void) --- Returns UVA data, adjusted with values from the UV compensation registers.

  • float i(void) --- Returns the UV index.

  • uint16_t uvComp1(void) --- Gets value for UV compensation

  • uint16_t uvComp2(void) --- Gets value for UV compensation

  • uint16_t visibleCompensation(void) --- Gets value for visible compensation

  • uint16_t irCompensation(void) --- Gets value for IR compensation

  • VEML6075_error_t deviceID(uint8_t * id) --- Prints device ID on debug stream.

  • VEML6075_error_t deviceAddress(uint8_t * address) --- Prints device address on debug stream.