15 #ifndef WipperSnapper_I2C_Driver_AS7331_H 16 #define WipperSnapper_I2C_Driver_AS7331_H 19 #include <Adafruit_AS7331.h> 21 #define AS7331_BREAKTIME_200US 25 61 _as7331 =
new Adafruit_AS7331();
65 bool setupSuccess =
true;
67 setupSuccess &=
_as7331->powerDown(
true);
71 setupSuccess &=
_as7331->setGain(AS7331_GAIN_4X);
72 setupSuccess &=
_as7331->setIntegrationTime(AS7331_TIME_64MS);
73 setupSuccess &=
_as7331->setMeasurementMode(AS7331_MODE_CONT);
74 setupSuccess &=
_as7331->setClockFrequency(AS7331_CLOCK_1024MHZ);
76 setupSuccess &=
_as7331->setStandby(
false);
79 setupSuccess &=
_as7331->powerDown(
false);
114 unsigned long now = millis();
119 if (!_as7331->readAllUV_uWcm2(&uva, &uvb, &uvc))
136 #endif // WipperSnapper_I2C_Driver_AS7331_H #define AS7331_BREAKTIME_200US
Recommended break time (val * 8µs)
Definition: WipperSnapper_I2C_Driver_AS7331.h:21
#define WS_DEBUG_PRINT(...)
Prints debug output.
Definition: Wippersnapper.h:63
~WipperSnapper_I2C_Driver_AS7331()
Destructor for an AS7331 sensor.
Definition: WipperSnapper_I2C_Driver_AS7331.h:50
bool _readSensor()
Reads all UV channels from the AS7331, caches UVB, and prints UVA/UVB/UVC as debug output...
Definition: WipperSnapper_I2C_Driver_AS7331.h:113
#define WS_DEBUG_PRINTVAR(...)
Prints variable (any type)
Definition: Wippersnapper.h:72
#define WS_DEBUG_PRINTLNVAR(...)
Prints variable with newline.
Definition: Wippersnapper.h:75
WipperSnapper_I2C_Driver_AS7331(TwoWire *i2c, uint16_t sensorAddress)
Constructor for an AS7331 sensor.
Definition: WipperSnapper_I2C_Driver_AS7331.h:39
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:33
Adafruit_AS7331 * _as7331
Pointer to AS7331 sensor object.
Definition: WipperSnapper_I2C_Driver_AS7331.h:102
bool begin()
Initializes the AS7331 sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver_AS7331.h:58
Class that provides a driver interface for an AS7331 UV sensor.
Definition: WipperSnapper_I2C_Driver_AS7331.h:28
uint16_t _sensorAddress
The I2C driver's unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1340
bool getEventRaw(sensors_event_t *rawEvent)
Gets the AS7331's current UVB reading in uW/cm2 as raw event.
Definition: WipperSnapper_I2C_Driver_AS7331.h:93
unsigned long _lastRead
Last sensor read time.
Definition: WipperSnapper_I2C_Driver_AS7331.h:103
#define ONE_SECOND_IN_MILLIS
Used for period checks.
Definition: WipperSnapper_I2C_Driver.h:26
float _cachedUVB
Cached UVB reading in uW/cm2.
Definition: WipperSnapper_I2C_Driver_AS7331.h:104
TwoWire * _i2c
Pointer to the I2C driver's Wire object.
Definition: WipperSnapper_I2C_Driver.h:1339