# bbb-tcs34725

> A library to use the RGB color sensor with BeagleBoneBlack

Latest version **0.0.4** (published 2015-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install bbb-tcs34725
pnpm add bbb-tcs34725
yarn add bbb-tcs34725
bun add bbb-tcs34725
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2015-06-20 |
| First published | 2015-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jon McKay |
| Maintainers | sorokine |
| Keywords | rgb, color, sensor, beaglebone, tcs34725 |

## Links

- npm: https://www.npmjs.com/package/bbb-tcs34725
- Repository: https://github.com/sorokine/rgb-tcs34725
- Issues: https://github.com/sorokine/rgb-tcs34725/issues
- npm.io page: https://npm.io/package/bbb-tcs34725

## Dependencies (2)

- [i2c](https://npm.io/package/i2c.md) ^0.2.1
- [async](https://npm.io/package/async.md) ^0.9.0

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.0.4 (latest) — 2015-06-20
- 0.0.3 — 2015-03-08

## README

BBB-TCS34725
============

A JavaScript driver for the TCS34725 RGB sensor.  Modified from the original https://github.com/johnnyman727/rgb-tcs34725 for BeagleBoneBlack (BBB).  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](http://www.adafruit.com/product/1334).

![Breakout Image](http://www.adafruit.com/images/970x728/1334-00.jpg)

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 BBB-TCS34725```

## Hardware Connections to Tessel

You can connect the module to the following the ports on BBB:

VIN  ->  Unconnected 

GND  ->  GND 

3V3  ->  3V3 

SCL  ->  I2C2_SCL

SDA  ->  I2C2_SDA

INT  ->  GPIO_26 // configurable

LED  ->  GPIO_61 // configurable





## Example Usage
```.js
//var tessel = require('tessel');
var rgbLib = require('../');
//var rgb = rgbLib.use(tessel.port.A);
var rgb = rgbLib.use({ 
  "bus"     : "/dev/i2c-1", 
  "led_pin" : "P8_14", // will be ignored if not set
  "irq_pin" : "P8_26", // will be ignored if not set
  "module_id" : 0x44   // hardware ID as returned by i2c module, will be ignored if not set
});

var ledON = false;
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);
    });
    
    ledON = !ledON;
    rgb.setLED(ledON);
  }, 1000);
})
```

## API

### Commands

```library.use({ "bus" : "/dev/i2c-1", ...}, 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`.

---
_Source: https://npm.io/package/bbb-tcs34725 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
