Skip to content

Commit 3234662

Browse files
authored
Merge pull request #349 from tyeth/add-VEML7700
Add VEML7700 Lux sensor
2 parents 0f11dc5 + ae7fd17 commit 3234662

File tree

4 files changed

+99
-2
lines changed

4 files changed

+99
-2
lines changed

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=Adafruit WipperSnapper
2-
version=1.0.0-beta.51
2+
version=1.0.0-beta.52
33
author=Adafruit
44
maintainer=Adafruit <adafruitio@adafruit.com>
55
sentence=Arduino client for Adafruit.io WipperSnapper
66
paragraph=Arduino client for Adafruit.io WipperSnapper
77
category=Communication
88
url=https://github.com/adafruit/Adafruit_IO_Arduino
99
architectures=*
10-
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit SleepyDog Library, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit DPS310, Adafruit SCD30, Sensirion I2C SCD4x, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit TSL2591 Library, Adafruit PM25 AQI Sensor, Adafruit LC709203F, Adafruit seesaw Library
10+
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit SleepyDog Library, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit DPS310, Adafruit SCD30, Sensirion I2C SCD4x, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit TSL2591 Library, Adafruit PM25 AQI Sensor, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit seesaw Library

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
293293
_tsl2591->configureDriver(msgDeviceInitReq);
294294
drivers.push_back(_tsl2591);
295295
WS_DEBUG_PRINTLN("TSL2591 Initialized Successfully!");
296+
} else if (strcmp("veml7700", msgDeviceInitReq->i2c_device_name) == 0) {
297+
_veml7700 = new WipperSnapper_I2C_Driver_VEML7700(this->_i2c, i2cAddress);
298+
if (!_veml7700->begin()) {
299+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize VEML7700!");
300+
_busStatusResponse =
301+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
302+
return false;
303+
}
304+
_veml7700->configureDriver(msgDeviceInitReq);
305+
drivers.push_back(_veml7700);
306+
WS_DEBUG_PRINTLN("VEML7700 Initialized Successfully!");
296307
} else if (strcmp("scd40", msgDeviceInitReq->i2c_device_name) == 0) {
297308
_scd40 = new WipperSnapper_I2C_Driver_SCD40(this->_i2c, i2cAddress);
298309
if (!_scd40->begin()) {

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "drivers/WipperSnapper_I2C_Driver_SI7021.h"
3535
#include "drivers/WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h"
3636
#include "drivers/WipperSnapper_I2C_Driver_TSL2591.h"
37+
#include "drivers/WipperSnapper_I2C_Driver_VEML7700.h"
3738

3839
#define I2C_TIMEOUT_MS 50 ///< Default I2C timeout, in milliseconds.
3940

@@ -85,6 +86,7 @@ class WipperSnapper_Component_I2C {
8586
WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr;
8687
WipperSnapper_I2C_Driver_MCP9601 *_mcp9601 = nullptr;
8788
WipperSnapper_I2C_Driver_TSL2591 *_tsl2591 = nullptr;
89+
WipperSnapper_I2C_Driver_VEML7700 *_veml7700 = nullptr;
8890
WipperSnapper_I2C_Driver_SCD40 *_scd40 = nullptr;
8991
WipperSnapper_I2C_Driver_PM25 *_pm25 = nullptr;
9092
WipperSnapper_I2C_Driver_SI7021 *_si7021 = nullptr;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*!
2+
* @file WipperSnapper_I2C_Driver_VEML7700.h
3+
*
4+
* Device driver for the VEML7700 digital luminosity (light) sensor.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Tyeth Gundry 2022 for Adafruit Industries.
11+
*
12+
* MIT license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
#ifndef WipperSnapper_I2C_Driver_VEML7700_H
16+
#define WipperSnapper_I2C_Driver_VEML7700_H
17+
18+
#include "WipperSnapper_I2C_Driver.h"
19+
#include <Adafruit_VEML7700.h>
20+
21+
/**************************************************************************/
22+
/*!
23+
@brief Class that provides a driver interface for a VEML7700 sensor.
24+
*/
25+
/**************************************************************************/
26+
class WipperSnapper_I2C_Driver_VEML7700 : public WipperSnapper_I2C_Driver {
27+
public:
28+
/*******************************************************************************/
29+
/*!
30+
@brief Constructor for a VEML7700 sensor.
31+
@param i2c
32+
The I2C interface.
33+
@param sensorAddress
34+
The 7-bit I2C address of the sensor.
35+
*/
36+
/*******************************************************************************/
37+
WipperSnapper_I2C_Driver_VEML7700(TwoWire *i2c, uint16_t sensorAddress)
38+
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
39+
_i2c = i2c;
40+
_sensorAddress = sensorAddress;
41+
}
42+
43+
/*******************************************************************************/
44+
/*!
45+
@brief Destructor for an VEML7700 sensor.
46+
*/
47+
/*******************************************************************************/
48+
~WipperSnapper_I2C_Driver_VEML7700() { delete _veml; }
49+
50+
/*******************************************************************************/
51+
/*!
52+
@brief Initializes the VEML7700 sensor and begins I2C.
53+
@returns True if initialized successfully, False otherwise.
54+
*/
55+
/*******************************************************************************/
56+
bool begin() {
57+
_veml = new Adafruit_VEML7700();
58+
// Attempt to initialize and configure VEML7700
59+
return _veml->begin(_i2c);
60+
}
61+
62+
/*******************************************************************************/
63+
/*!
64+
@brief Performs a light sensor read using the Adafruit
65+
Unified Sensor API. Always uses VEML_LUX_AUTO,
66+
controlling sensor integration time and gain.
67+
@param lightEvent
68+
Light sensor reading, in lux.
69+
@returns True if the sensor event was obtained successfully, False
70+
otherwise.
71+
*/
72+
/*******************************************************************************/
73+
bool getEventLight(sensors_event_t *lightEvent) {
74+
// Get sensor event populated in lux via AUTO integration and gain
75+
lightEvent->light = _veml->readLux(VEML_LUX_AUTO);
76+
77+
return true;
78+
}
79+
80+
protected:
81+
Adafruit_VEML7700 *_veml; ///< Pointer to VEML7700 light sensor object
82+
};
83+
84+
#endif // WipperSnapper_I2C_Driver_VEML7700

0 commit comments

Comments
 (0)