Skip to content

blasco/arduino-adafruit-tsl2561

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Adafruit TSL2561 library for Mongoose OS

This is a port of the Adafruit Arduino driver for the TSL2561 sensor ported to run on the Mongoose OS ecosystem.

Usage is extremely simple....

in mos.yml, add to libs: section,

- origin: https://github.com/mongoose-os-libs/arduino-adafruit-tsl2561

in your init.js, add something like the following,

load('api_arduino_tsl2561.js');

and

//Initialize Adafruit_TSL2561 library
let tsl = Adafruit_TSL2561.create();
print('Adafruit_TSL2561.TSL2561_GAIN_16X -> ',Adafruit_TSL2561.TSL2561_GAIN_16X);
tsl.setGain(Adafruit_TSL2561.TSL2561_GAIN_16X);
tsl.setIntegrationTime(Adafruit_TSL2561.TSL2561_INTEGRATIONTIME_402MS);
tsl.begin();

let tslGetData = function() {
    let vis = tsl.getVisible();
    let ir = tsl.getInfrared();
    let lux = tsl.calculateLux(vis, ir);
    print('TSL2561:  Vis: ', vis ,', IR: ', ir, ', Lux: ',lux);
};

let tslTimer = Timer.set(10000 /* milliseconds */, true /* repeat */, tslGetData, null);

to use the library.

Enjoy!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 61.1%
  • JavaScript 25.5%
  • C 13.4%