SparkFun Spectral UV Sensor - AS7331  v2.1.2-21-g3e22fb4
Library for the SparkFun Spectral UV Sensor - AS7331
Loading...
Searching...
No Matches
sfDevAS7331.h File Reference

Header file for the SparkFun Spectral UV Sensor - AS7331. More...

#include <stdint.h>
#include <sfTk/sfToolkit.h>
#include <sfTk/sfTkII2C.h>
Include dependency graph for sfDevAS7331.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  sfe_as7331_reg_cfg_osr_t
 
union  sfe_as7331_reg_cfg_agen_t
 
union  sfe_as7331_reg_cfg_creg1_t
 
union  sfe_as7331_reg_cfg_creg2_t
 
union  sfe_as7331_reg_cfg_creg3_t
 
union  sfe_as7331_reg_cfg_optreg_t
 
union  sfe_as7331_reg_meas_osr_status_t
 
class  sfDevAS7331
 

Enumerations

enum  as7331_dev_op_state_t { DEVICE_MODE_CFG = 0x2 , DEVICE_MODE_MEAS = 0x3 }
 
enum  as7331_gain_t {
  GAIN_2048 = 0x0000 , GAIN_1024 , GAIN_512 , GAIN_256 ,
  GAIN_128 , GAIN_64 , GAIN_32 , GAIN_16 ,
  GAIN_8 , GAIN_4 , GAIN_2 , GAIN_1
}
 
enum  as7331_conv_clk_freq_t { CCLK_1_024_MHZ = 0x00 , CCLK_2_048_MHZ , CCLK_4_096_MHZ , CCLK_8_192_MHZ }
 
enum  as7331_meas_mode_t { MEAS_MODE_CONT = 0x0 , MEAS_MODE_CMD , MEAS_MODE_SYNS , MEAS_MODE_SYND }
 
enum  as7331_conv_time_t {
  TIME_1MS = 0x0 , TIME_2MS , TIME_4MS , TIME_8MS ,
  TIME_16MS , TIME_32MS , TIME_64MS , TIME_128MS ,
  TIME_256MS , TIME_512MS , TIME_1024MS , TIME_2048MS ,
  TIME_4096MS , TIME_8192MS , TIME_16384MS
}
 
enum  as7331_divider_val_t {
  DIV_2 = 0x0 , DIV_4 , DIV_8 , DIV_16 ,
  DIV_32 , DIV_64 , DIV_128 , DIV_256
}
 
enum  as7331_uv_type { AS7331_UVA , AS7331_UVB , AS7331_UVC }
 

Variables

const uint8_t kDefaultAS7331Addr = 0x74
 
const uint8_t kSecondaryAS7331Addr = 0x75
 
const uint8_t kTertiaryAS7331Addr = 0x76
 
const uint8_t kQuaternaryAS7331Addr = 0x77
 
const uint8_t kDefaultAS7331DeviceID = 0x21
 
const uint8_t kAS7331DeviceIDTopNibble = 0x2
 
const uint8_t kSfeAS7331RegCfgOsr = 0x00
 
const uint8_t kSfeAS7331RegCfgAgen = 0x02
 
const uint8_t kSfeAS7331RegCfgCreg1 = 0x06
 
const uint8_t kSfeAS7331RegCfgCreg2 = 0x07
 
const uint8_t kSfeAS7331RegCfgCreg3 = 0x08
 
const uint8_t kSfeAS7331RegCfgBreak = 0x09
 
const uint8_t kSfeAS7331RegCfgEdges = 0x0A
 
const uint8_t kSfeAS7331RegCfgOptReg = 0x0B
 
const uint8_t kSfeAS7331RegMeasOsrStatus = 0x00
 
const uint8_t kSfeAS7331RegMeasTemp = 0x01
 
const uint8_t kSfeAS7331RegMeasMres1 = 0x02
 
const uint8_t kSfeAS7331RegMeasMres2 = 0x03
 
const uint8_t kSfeAS7331RegMeasMres3 = 0x04
 
const uint8_t kSfeAS7331RegMeasOutConvL = 0x05
 
const uint8_t kSfeAS7331RegMeasOutConvH = 0x06
 

Detailed Description

Header file for the SparkFun Spectral UV Sensor - AS7331.

This file contains the class definitions, constants, and enums for interacting with the AS7331 sensor.

SfeAS7331Driver is a comms-agnostic driver for the AS7331 Spectral UV sensor that uses the SparkFun Toolkit. The SfeAS7331ArdI2C class defines the Arduino specific behavior for initializing and interacting with devices.

I2C Addressing

7-bit address defined as [1, 1, 1, 0, 1, A1, A0] where A1/A0 are the physical address pins tied high or low.

Enum Definitions

  • Device Operating Mode
  • Sensor Gain
  • Conversion Clock Frequency
  • Measurement Mode
  • Time Conversion Values
  • Predivider Values
  • UV Type
Author
SparkFun Electronics
Date
2025

SPDX-License-Identifier: MIT

Configuration Register Descriptions

  • Configuration Registers
  • Measurement Registers

Classes

Repository

https://github.com/sparkfun/SparkFun_AS7331_Arduino_Library

Product Links

Enumeration Type Documentation

◆ as7331_conv_clk_freq_t

Enumerator
CCLK_1_024_MHZ 
CCLK_2_048_MHZ 
CCLK_4_096_MHZ 
CCLK_8_192_MHZ 

◆ as7331_conv_time_t

Enumerator
TIME_1MS 
TIME_2MS 
TIME_4MS 
TIME_8MS 
TIME_16MS 
TIME_32MS 
TIME_64MS 
TIME_128MS 
TIME_256MS 
TIME_512MS 
TIME_1024MS 
TIME_2048MS 
TIME_4096MS 
TIME_8192MS 
TIME_16384MS 

◆ as7331_dev_op_state_t

Enumerator
DEVICE_MODE_CFG 
DEVICE_MODE_MEAS 

◆ as7331_divider_val_t

Enumerator
DIV_2 
DIV_4 
DIV_8 
DIV_16 
DIV_32 
DIV_64 
DIV_128 
DIV_256 

◆ as7331_gain_t

Enumerator
GAIN_2048 
GAIN_1024 
GAIN_512 
GAIN_256 
GAIN_128 
GAIN_64 
GAIN_32 
GAIN_16 
GAIN_8 
GAIN_4 
GAIN_2 
GAIN_1 

◆ as7331_meas_mode_t

Enumerator
MEAS_MODE_CONT 
MEAS_MODE_CMD 
MEAS_MODE_SYNS 
MEAS_MODE_SYND 

◆ as7331_uv_type

Enumerator
AS7331_UVA 
AS7331_UVB 
AS7331_UVC 

Variable Documentation

◆ kAS7331DeviceIDTopNibble

const uint8_t kAS7331DeviceIDTopNibble = 0x2

◆ kDefaultAS7331Addr

const uint8_t kDefaultAS7331Addr = 0x74

◆ kDefaultAS7331DeviceID

const uint8_t kDefaultAS7331DeviceID = 0x21

◆ kQuaternaryAS7331Addr

const uint8_t kQuaternaryAS7331Addr = 0x77

◆ kSecondaryAS7331Addr

const uint8_t kSecondaryAS7331Addr = 0x75

◆ kSfeAS7331RegCfgAgen

const uint8_t kSfeAS7331RegCfgAgen = 0x02

◆ kSfeAS7331RegCfgBreak

const uint8_t kSfeAS7331RegCfgBreak = 0x09

◆ kSfeAS7331RegCfgCreg1

const uint8_t kSfeAS7331RegCfgCreg1 = 0x06

◆ kSfeAS7331RegCfgCreg2

const uint8_t kSfeAS7331RegCfgCreg2 = 0x07

◆ kSfeAS7331RegCfgCreg3

const uint8_t kSfeAS7331RegCfgCreg3 = 0x08

◆ kSfeAS7331RegCfgEdges

const uint8_t kSfeAS7331RegCfgEdges = 0x0A

◆ kSfeAS7331RegCfgOptReg

const uint8_t kSfeAS7331RegCfgOptReg = 0x0B

◆ kSfeAS7331RegCfgOsr

const uint8_t kSfeAS7331RegCfgOsr = 0x00

◆ kSfeAS7331RegMeasMres1

const uint8_t kSfeAS7331RegMeasMres1 = 0x02

◆ kSfeAS7331RegMeasMres2

const uint8_t kSfeAS7331RegMeasMres2 = 0x03

◆ kSfeAS7331RegMeasMres3

const uint8_t kSfeAS7331RegMeasMres3 = 0x04

◆ kSfeAS7331RegMeasOsrStatus

const uint8_t kSfeAS7331RegMeasOsrStatus = 0x00

◆ kSfeAS7331RegMeasOutConvH

const uint8_t kSfeAS7331RegMeasOutConvH = 0x06

◆ kSfeAS7331RegMeasOutConvL

const uint8_t kSfeAS7331RegMeasOutConvL = 0x05

◆ kSfeAS7331RegMeasTemp

const uint8_t kSfeAS7331RegMeasTemp = 0x01

◆ kTertiaryAS7331Addr

const uint8_t kTertiaryAS7331Addr = 0x76