Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VEML7700 Lux sensor #349

Merged
merged 5 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=Adafruit WipperSnapper
version=1.0.0-beta.51
version=1.0.0-beta.52
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino client for Adafruit.io WipperSnapper
paragraph=Arduino client for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_IO_Arduino
architectures=*
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
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
2 changes: 1 addition & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#endif

#define WS_VERSION \
"1.0.0-beta.51" ///< WipperSnapper app. version (semver-formatted)
"1.0.0-beta.52" ///< WipperSnapper app. version (semver-formatted)

// Reserved Adafruit IO MQTT topics
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic
Expand Down
11 changes: 11 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_tsl2591->configureDriver(msgDeviceInitReq);
drivers.push_back(_tsl2591);
WS_DEBUG_PRINTLN("TSL2591 Initialized Successfully!");
} else if (strcmp("veml7700", msgDeviceInitReq->i2c_device_name) == 0) {
_veml7700 = new WipperSnapper_I2C_Driver_VEML7700(this->_i2c, i2cAddress);
if (!_veml7700->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize VEML7700!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_veml7700->configureDriver(msgDeviceInitReq);
drivers.push_back(_veml7700);
WS_DEBUG_PRINTLN("VEML7700 Initialized Successfully!");
} else if (strcmp("scd40", msgDeviceInitReq->i2c_device_name) == 0) {
_scd40 = new WipperSnapper_I2C_Driver_SCD40(this->_i2c, i2cAddress);
if (!_scd40->begin()) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "drivers/WipperSnapper_I2C_Driver_SI7021.h"
#include "drivers/WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h"
#include "drivers/WipperSnapper_I2C_Driver_TSL2591.h"
#include "drivers/WipperSnapper_I2C_Driver_VEML7700.h"

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

Expand Down Expand Up @@ -85,6 +86,7 @@ class WipperSnapper_Component_I2C {
WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr;
WipperSnapper_I2C_Driver_MCP9601 *_mcp9601 = nullptr;
WipperSnapper_I2C_Driver_TSL2591 *_tsl2591 = nullptr;
WipperSnapper_I2C_Driver_VEML7700 *_veml7700 = nullptr;
WipperSnapper_I2C_Driver_SCD40 *_scd40 = nullptr;
WipperSnapper_I2C_Driver_PM25 *_pm25 = nullptr;
WipperSnapper_I2C_Driver_SI7021 *_si7021 = nullptr;
Expand Down
84 changes: 84 additions & 0 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_VEML7700.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*!
* @file WipperSnapper_I2C_Driver_VEML7700.h
*
* Device driver for the VEML7700 digital luminosity (light) sensor.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Brent Rubell 2022 for Adafruit Industries.
tyeth marked this conversation as resolved.
Show resolved Hide resolved
* Copyright (c) Tyeth Gundry 2022 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef WipperSnapper_I2C_Driver_VEML7700_H
#define WipperSnapper_I2C_Driver_VEML7700_H

#include "WipperSnapper_I2C_Driver.h"
#include <Adafruit_VEML7700.h>

/**************************************************************************/
/*!
@brief Class that provides a driver interface for a VEML7700 sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_VEML7700 : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for a VEML7700 sensor.
@param i2c
The I2C interface.
@param sensorAddress
The 7-bit I2C address of the sensor.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_VEML7700(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
}

/*******************************************************************************/
/*!
@brief Destructor for an VEML7700 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_VEML7700() { delete _veml; }

/*******************************************************************************/
/*!
@brief Initializes the VEML7700 sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_veml = new Adafruit_VEML7700();
// Attempt to initialize and configure VEML7700
return _veml->begin();
}

/*******************************************************************************/
/*!
@brief Performs a light sensor read using the Adafruit
Unified Sensor API.
@param lightEvent
Light sensor reading, in lux.
@returns True if the sensor event was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventLight(sensors_event_t *lightEvent) {
// Get sensor event
tyeth marked this conversation as resolved.
Show resolved Hide resolved
lightEvent->light = _veml->readLux(VEML_LUX_AUTO);

return true;
}

protected:
Adafruit_VEML7700 *_veml; ///< Pointer to VEML7700 light sensor object
};

#endif // WipperSnapper_I2C_Driver_VEML7700