Skip to content
Driver for color sensor tcs34725 -- https://github.com/rzr/webthing-iotjs/wiki/Sensor
Branch: master
Clone or download
Pull request Compare This branch is 1 commit ahead of rzr:master.
rzr aframe: Fix mistake
Change-Id: I86de56d61642e37ee0a99a9d7a4007e2e844a40c
Signed-off-by: Philippe Coval <p.coval@samsung.com>
Latest commit cb122b9 Jul 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example aframe: Fix mistake Jul 15, 2019
lib lib: Avoid to display exception for i2c Mar 5, 2019
.dockerignore docker: Support node:8 image until LTS fixed Feb 25, 2019
.eslintignore eslint: Ignore iotjs modules Mar 5, 2019
.eslintrc.js eslint: Add config for es5 for IoT.js Feb 20, 2019
.gitignore git: Ignore files Feb 20, 2019
Dockerfile docker: Use IoT.js as default runtime Feb 26, 2019
LICENSE legal: Licence under Apache-2.0 like iotjs Feb 20, 2019
Makefile build: Fix make help Jul 2, 2019
README.md doc: Add aframe-webthing picture Jul 15, 2019
color-sensor-js.js lib: Add color-sensor-js.js for IoT.js Feb 20, 2019
docker-compose.yml
favicon.ico www: Add favicon.ico from webthings-webapp Mar 18, 2019
index.html www: Add glitch.me URLs Mar 23, 2019
index.js lib: Add index.js for module Feb 20, 2019
package-lock.json 0.0.8 Jul 15, 2019
package.json 0.0.8 Jul 15, 2019

README.md

COLOR-SENSOR-JS

GitHub forks license NPM IRC Channel

NPM

INTRODUCTION

This module is supporting TCS34725 I2C sensor and also provide a simulator that return random colors.

Presentation

It should work with Adafruit RGB Color Sensor with IR Filter and White LED - TCS34725 [ADA1334] :

USAGE:

Node.js and IoT.js runtimes are supported.

Usage is straightforward.

By default simulator is used, and output are in web hex format (#RrGgBb), but lower level use is also possible.

For using I2C TCS34725 sensor, check i2c chapter first.

USING IOT.JS:

Install recent version of IoT.js:

git clone --recursive --depth 1 https://github.com/samsunginternet/color-sensor-js
cd color-sensor-js

make test
#| iotjs lib/simulator.js
#| log: value=[7779,36778,11173,42766]
#| log: test: test/iotjs

make start
#| {"color": "#badc0d"}
#| {"color": "#c0ffee"}
#| (...)

# Or to use actual sensor:
make start run_args=tcs34725
#| iotjs example tcs34725
#| {"color": "#ff514a"}
#| (...)

# Raw driver's values:
iotjs lib/tcs34725.js 
#| log: value=[65535,20885,19074,65535]

USING NODE.JS:

# git clone or use install released package:

npm install color-sensor-js
cd node_modules/color-sensor-js

npm install --only=prod
npm test
#| > node lib/simulator
#| log: value=[11409,49339,1907,5849]

npm start
#| node example
#| {"color": "#c0ffee"}
#| (...)

# Or to use actual sensor:
node example tcs34725
#| {"color": "#ff514a"}
#| (...)

# Raw driver's values:
node lib/tcs34725.js 
#| log: value=[65535,20908,19103,65535]

NOTES:

On issues make sure that your system have I2C, device should be visible by user before using it:

sudo apt-get install i2c-tools make git
i2cdetect -y 1
#|      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
#| (...)
#| 20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- --
#| (...)

On Raspbian, pi "user" is in "i2c" group of file "/dev/i2c-1" (matching RaspberryPi's header).

WEBTHING EXAMPLE:

An extra example is provided for use from the Web (WebOfThings).

It's using Mozilla's IoT Schema and can be used as standalone or connected to things Gateway:

cd example/color-sensor-webthing 
npm install
npm start

curl http://localhost:8888/properties/color
#| {"color":"#6ab302"}

TCS34725 sensor can be selected from command line, and port eventually changed:

cd example/color-sensor-webthing/
npm install
npm start 8888 tcs34725

May I recommend to give a try with IoT.js runtime, it is faster and consuming much less resources:

make -C example/color-sensor-webthing start

schemas

CLIENTS:

Webthings servers are designed to be connected Mozilla's IoT which play the client role, but nothing prevent to create your own, in CLI (using IoT.js or Node.js) or browser.

For web app clients try to open this page, some are listed:

Note, if you want to create your app offline you can use static contents:

Off course, prefix path (and suffix if loading from file:) should be adjusted, or overloaded using CGI params.

You can even run webthings in the cloud:

aframe-webthing

DEMOS:

demo

In "webthing-iotjs-opendata-20190202rzr" video, sensor is observing the lamp color, but it can work with any regular material.

Presentation

A-Frame can also been used for rendering.

RESOURCES:

You can’t perform that action at this time.