npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cabinfo.eu/veml6030

v1.0.4

Published

A package to communicate with VEML chipset through I2C

Downloads

5

Readme

npm Version Downloads Per Month GitHub last commit GitHub top language GitHub package.json version NPM

veml6030

Node.js I2C driver for the VISHAY VEML6030 ambient light sensor on Linux boards like the Raspberry Pi or BeagleBone.

Supports Node.js versions 10, 12, 14, 15 and 16.

VEML6030 chipset datasheet : https://www.vishay.com/docs/84366/veml6030.pdf

VEML6030 chipset application notes : https://www.vishay.com/docs/84367/designingveml6030.pdf?ICID=I-CT-TECH-RES-CLA-SEP_21-0

Contents

Features

  • Ambient light sensing
  • Autocalibration mode
  • Manual mode
  • Promise based asynchronous call methods

Installation

npm install --save veml6030

Usage

Report the ambient light with auto calibration mode example.

const VEML6030    = require('@cabinfo.eu/veml6030');

const veml6030 = new VEML6030({debug: true});

veml6030.init()
.then(() => {
    veml6030.readSensorData(true)
    .then(datas => console.log('%o', datas))
    .catch(error => console.log(error));
})
.catch(error => console.log(error));

Sample output:

{
  rawValue: 144,
  rawLuxValue: 66.3552
  luxValue: 66.8638,
  useCorrectionFormula: true
  gain: 0.25,
  integrationTime: 50,
  autocalibrate: false,
  retry: 1,
  overflow: false
}

Report the ambient light with manual configuration example.

const VEML6030    = require('@cabinfo.eu/veml6030');

const options = {
    debug: true,
    gain: 0.25,
    integrationTime: 50
};

const veml6030 = new VEML6030(options);

veml6030.init()
.then(() => {
    veml6030.readSensorData(false)
    .then(datas => console.log('Datas readed: %o', datas))
    .catch(error => console.log(error));
})
.catch(error => console.log(error));

Sample output:

{
  rawValue: 144,
  rawLuxValue: 66.3552
  luxValue: 66.8638,
  useCorrectionFormula: true
  gain: 0.25,
  integrationTime: 50,
  autocalibrate: false,
  retry: 1,
  overflow: false
}

VEML6030 class methods

Constructor options

VEML6030 class constructor accept an optionnal options object.

None of theses options are mandatory, so you can invoke VEML6030 constructor without any parameters. In this case it will use options default values.

Options:

|Option name|Description|Default Value| |:-----|:-----|:-----| |debug|If debug is set to true, VEML6030 class will print to console debug information|false| |i2cAddress|I2C address (in hex) of VEML6030 chipset|0x48| |gain|Fix the gain the chipset should use for reading (use it for manual calibration mode). Authorized value are 0.125, 0.25, 1 or 2. |1| |integrationTime|Fix the integration time (in ms) the chipset should use for reading (use it for manual calibration mode). Authorized values are 25, 50, 100, 200, 400 or 800.|100| |ALSPersistenceProtectNumber|Leave this option to default value|1| |ALSInterruptEnableSetting|Leave this option to default value|false| |ALSShutDownSetting|Leave this option to default value|false| |i2cBusNumber|I2C bus number. I most case leave this value to default value|1|

VEML6030 methods

init()

Returns a Promise that will be resolved with no arguments once the initial configuration has been wrote to the VEML6030 chipset, or will be rejected if an error occurs.

Configuration values are default ones if you invoke constructor without any options object. If you set some optionnal parameters in constructor call or if you invoke one or more parameter methods, it will be the current values that are send to chipset.

Once init resolve you can use the read readSensorData() method.

readSensorData()

Returns a Promise that will be resolved with an object once the VEML6030 chipset return the readed value, or will be rejected if an error occurs.

readSensorData accept one boolean parameter to indicat if you want an autocalibrating measure (prefered) or a raw measure with the current reading options values (gain, integration time, etc.)

If autocalibration parameter is set to true this method will adjust the gain and the integration time of the chipset according to VISHAY recommandations.

If you set the parameter to false a simple reading is done with the parameters you set. This mode is intended to permit you to implement your own calibration method.

We recommend using autocalibration once you don't need to implement your own measures scheme.

Object properties returned when promise resolve:

  • rawValue: The raw value readed from chipset
  • rawLuxValue: The optimized raw illumination value calculated from raw value (in lux) according to VISHAY recommandations
  • luxValue: The illumination value (in lux). If rawLuxValue is <= 100 luxValue and rawLuxValue are identical. If rawLuxValue is > 100 a correction formula is apply to luxValue according to VISHAY recommandations
  • useCorrectionFormula: Indicate if a correction formula is applied to luxValue (true) or not (false)
  • gain: The gain value used for reading
  • integrationTime: the integration time (in ms) used for reading
  • autocalibrate: Inditate if in autocalibration mode (true) or not (false)
  • retry: Number of measures done. If autocalibration mode this number is > 1 due to gain and integration time adjustments.
  • overflow: Indicate if an overflow is detected (true) or not (false)

Sample object:

{
  rawValue: 144,
  rawLuxValue: 66.3552
  luxValue: 66.8638,
  useCorrectionFormula: true
  gain: 0.25,
  integrationTime: 50,
  autocalibrate: false,
  retry: 1,
  overflow: false
}

VEML6030 constants

VEML6030 package publish folowing constants. You can use it when implementing your own implementation measures.

All theses constants are static, so you can use it like this:

const VEML6030 = require('@cabinfo.eu/veml6030');
console.log('Read command is: %o', VEML6030.ALS_READ_REGISTER);
  • ALS_SETTING_REGISTER: Send configuration command code. This constant value is 0x00.
  • ALS_WH_REGISTER: Send an high value for threshold. This constant value is 0x01. This command is currently not used in this package.
  • ALS_WL_REGISTER: Send an low value for threshold. This constant value is 0x02. This command is currently not used in this package.
  • ALS_POWER_SAVE_REGISTER: Power saving command. This constant value is 0x03. This command is currently not used in this package.
  • ALS_READ_REGISTER: Read command for ALS channel. This constant value is 0x04.
  • WHITE_READ_REGISTER: Read command for white channel. This constant value is 0x05. This constant value is 0x03. This command is currently not used in this package.
  • ALS_INT_REGISTER: Interrupt status command (use to detect low or high threshold). This constant value is 0x06. This command is currently not used in this package.
  • READ_BASE_RESOLUTION: . This constant value is 0.0036.

Related Packages

Roadmap

  • Implement shutdown/powerup during autocalibration according to Vishay documents.
  • Implement white channel reading.
  • Implement low and high threshold and interupt status reading.