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

rgb-tcs34725

v0.0.3

Published

A library to use the RGB color sensor with a JavaScript microcontroller

Downloads

8

Readme

rgb-tcs34725

A JavaScript driver for the TCS34725 RGB sensor. Use it to find the red, green, blue, or clear levels of anything you point it at. The API gives you access to the raw RGBC data, color temperatures, and lux intensity. You can buy the breakout board from Adafruit.

Breakout Image

The chip also has support for threshold interrupts on the clear channel and those APIs have been implemented here but not fully tested.

Installation

npm install rgb-tcs34725

Hardware Connections to Tessel

You can connect the module to any of the ports on Tessel:

VIN -> Unconnected

GND -> GND

3V3 -> 3V3

SCL -> SCL

SDA -> SDA

INT -> GPIO 1

LED -> GPIO 2

Example Usage

var tessel = require('tessel');
var rgbLib = require('../');
var rgb = rgbLib.use(tessel.port.A);

rgb.on('ready', function() {
  
  setInterval(function() {
    rgb.getRawData(function(err, colors) {
      if (err) throw err;

      console.log('RED:', colors.red);
      console.log('GREEN:', colors.green);
      console.log('BLUE:', colors.blue);
      console.log('CLEAR:', colors.clear);
    })
  }, 1000);
});

API

Commands

library.use(hardware, callback) initializes the module on the port of a microcontroller. It returns the rgb object and the callback has the form of callback(err, rgb).

rgb.getRawData(err, colors) returns rgbc data. colors has red, green, blue, and clear properties. Each of the colors is a 16 bit number.

rgb.calculateColorTemperature(callback(err, temp)) returns the color temperature as a 16 bit number representing Kelvins. The temperature it returns is in units of Kelvin.

rgb.calculateLux(callback(err, lux)) returns the light intensity as a 16 bit number that represents the light intensity.

rgb.enable(callback(err)) enables the module to read colors. It is called automatically when the use function is called.

rgb.disable() can be used to put the module to sleep and reduce power consumption. Call rgb.enable() to wake it back up.

rgb.setIntegrationTime(time, callback) sets the amount of time integrating values from an ADC (which determines color). Longer times produce more accurate numbers at low light levels. Available times can be found with rgb.integrationTimes.

rgb.setGain(gain, callback) sets the gain of the ADC. Available gains can be found with rgb.gains.