Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
LightSensor Class Reference

A class to configure and read the Vishay VEML6030 ambient light sensor. More...

#include <Lightsensor.h>

Public Member Functions

void begin ()
 Initialize the VEML6030 light sensor.
 LightSensor (uint8_t sdapin, uint8_t sclpin)
 Construct a new LightSensor object.
uint32_t readLight ()
 Read the current light level in lux.
void stop ()
 Stop the sensor.

Detailed Description

A class to configure and read the Vishay VEML6030 ambient light sensor.

The VEML6030 is a high-sensitivity ambient light sensor connected through the I2C bus at address VEML6030_I2C_ADDR (0x10). It provides a 16-bit dynamic range and adjustable gain and integration time for accurate lux readings.

Default connections:

Signal I2C Macro GPIO Description
SDA DEFAULT_I2C_SDA_PIN 12 I2C data
SCL DEFAULT_I2C_SCL_PIN 13 I2C clock
Address VEML6030_I2C_ADDR 0x10 Light sensor I2C address
Interrupt VEML6030_INTERRUPT 9 Optional interrupt output
Precondition
The I2C interface must be initialized (use TKJHAT::begin()).
See also
SparkFun Guide: https://learn.sparkfun.com/tutorials/qwiic-ambient-light-sensor-veml6030-hookup-guide/all#arduino-library
Application Note: https://www.vishay.com/docs/84367/designingveml6030.pdf
Datasheet: https://www.vishay.com/docs/84366/veml6030.pdf

{@

Constructor & Destructor Documentation

◆ LightSensor()

LightSensor::LightSensor ( uint8_t sdapin,
uint8_t sclpin )

Construct a new LightSensor object.

Parameters
sdapinGPIO pin connected to the I2C SDA line (default: GPIO 12)
sclpinGPIO pin connected to the I2C SCL line (default: GPIO 13)

Member Function Documentation

◆ begin()

void LightSensor::begin ( )

Initialize the VEML6030 light sensor.

Configures the sensor with default parameters:

  • Gain: 1/8
  • Integration time: 100 ms
  • Power: ON
  • Interrupts: disabled
Precondition
Call TKJHAT::begin() before this function.

◆ readLight()

uint32_t LightSensor::readLight ( )

Read the current light level in lux.

Returns
The ambient light level in lux, or a negative value on error.

◆ stop()

void LightSensor::stop ( )

Stop the sensor.

Powers down the sensor to save energy. The sensor will not respond to read commands until re-initialized.


The documentation for this class was generated from the following file: