Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Latest commit

 

History

History
40 lines (27 loc) · 1.14 KB

README.md

File metadata and controls

40 lines (27 loc) · 1.14 KB

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!