@agilatech/lynxari-si1145-device
v1.1.0
Published
SI1145 UV/IR/Visible light device driver for use in the Agilatech Lynxari system
Downloads
10
Maintainers
Readme
IoT Platform
Lynxari SI1145 IR/Visible/UV light sensor device driver
This device driver is specifically designed to be used with the Agilatech® Lynxari IoT Platform. Please see agilatech.com to download a copy of the system.
Install
$> npm install @agilatech/lynxari-si1145-device
Design
This device driver is designed for both streaming and periodic monitored data collection from the Silicon Labs SI1145 sensor.
The driver software does not include any functionality for proximity sensing. This feature may be enabled in a future release, but don't count on it. The main purpose of this addon is for simple light sensing.
The UV Index provided by the SI1145 sensor is not based on direct UV measurement, but is calculated by the linear releationship of combined IR and Visible sunlight and is weighted according to the CIE Erythemal Action Spectrum. The resulting UV index is the standardized World Health Organization simplified consumer UV exposure level ranging from 1 to 11.
In any case, this sensor is uncalibrated, so none of the returned values should be considered accurate. The values returned are in the right ballpark within a 15-20% tolerance.
Although Lynxari can run on most any operating system, this driver uses Linux-specific protocols, so it will not work directly on Windows.
Usage
This device driver is designed to be consumed by the Agilatech® Lynxari IoT system. As such, it is not really applicable or useful in other environments.
To use it with Lynxari, insert its object definition as an element in the devices array in the devlist.json file.
{
"name": "SI1145",
"module": "@agilatech/lynxari-si1145-device",
"options": {
"devicePoll": 1000,
"streamPeriod": 60000
}
}
Device config object
The device config object is an element in the devlist.json device configuration file, which is located in the Lynxari root directory. It is used to tell the Lynxari system to load the device, as well as several operational parameters.
name is simply the name given to the device. This name can be used in queries and for other identifcation purposes.
module is the name of the npm module. The module is expected to exist in this directory under the node_modules directory. If the module is not strictly an npm module, it must still be found under the node_modules directory.
options is an object within the device config object which defines all other operational parameters. In general, any parameters may be defined in this options object, and most modules will have many several. The three which are a part of every Lynxari device are 'devicePoll', 'streamPeriod', and 'deltaPercent'. The si1145 options also can define the bus number. Finally, all parameter values can have a range defined by specifying '_range'.
"devicePoll":<period>
Period in milliseconds in which device will be polled to check for new data
"streamPeriod":<period>
Period in milliseconds for broadcast of streaming values
"deltaPercent":<percent>
Percent of the data range which must be exceeded (delta) to qualify as "new" data
"bus":<i2c bus number>
Linux filesystem device for hardware bus, i.e. 1
devicePoll and streamPeriod
devicePoll is given in milliseconds, and defines how often the device will be polled for new values. This paramter is primary useful in sensors which sit idle waiting to be polled, and not for devices which supply values on their own schedule (i.e. for pull ranther that push).
streamPeriod is also given in milliseconds, and defines how often the device will publish its values on the data stream. Streaming is disabled if this parameter is set to 0.
deltaPercent explained
deltaPercent is the percentage of the current numerical data range which a polled data value must exceed to be considred "new". As an example, consider a temperature range of 100, a deltaPercent of 2, and the current temerature of 34. In such a case, a device poll must produce a value of 36 or greater, or 32 or less than in order to be stored as a current value. 35 or 33 will be ignored. deltaPercent may be any value greater than 0 or less than 100, and may be fractional. If not defined, the default is 5 percent.
Defining the value ranges
Value ranges may also be defined in the config, and are closely related to deltaPercent. If not defined, the software will keep track of minimum and maximum values and derive the range from them. However, that takes time for the software to "learn" the ranges, so they can be defined in the config object:
"ir_range":<numeric range>
"visible_range":<numeric range>
"uv_range":<numeric range>
where the <numeric range> is a number representing the absolute range of the value.
module config
Every module released by Agilatech includes configuration in a file named 'config.json' and we encourage any other publishers to follow the same pattern. The parameters in this file are considered defaults, since they are overriden by definitions appearing in the options object of the Lynxari devlist.json file.
The construction of the config.json mirrors that of the options object, which is simply a JSON object with key/value pairs. Here is an example of an 'config.json' file which streams values every 10 seconds, polls the device every second, requires an 8% delta change to register a new monitored value, and defines valid ranges on all parameters:
{
"streamPeriod":10000,
"devicePoll":1000,
"deltaPercent":8,
"bus":1,
"ir_range":20000,
"visible_range":20000
"uv_range":11
}
(please note that ir and visible values are in lux, while uv is the World Health UV index)
Default values
If not specified in the config object, the program uses the following default values:
streamPeriod : 10000 (10,000ms or 10 seconds)
devicePoll : 1000 (1,000ms or 1 second)
deltaPercent : 5 (polled values must exceed the range by ± 5%)
bus : 1 (I2C bus /dev/i2c-1)
Properties
All drivers contain the following 4 core properties:
- state : the current state of the device, containing either the value chron-on or chron-off to indicate whether the device is monitoring data isochronally (a predefinied uniform time period of device data query).
- id : the unique id for this device. This device id is used to subscribe to this device streams.
- name : the given name for this device.
- type : the given type category for this device, (sensor, actuator, etc)
Monitored Properties
In the on state, the driver software for this device monitors three values.
- ir - infrared light
- visible - visible light
- uv - ultraviolet exposure index
Streaming Properties
In the on state, the driver software continuously streams three values in isochronal fashion with a period defined by streamPeriod. Note that a streamPeriod of 0 disables streaming.
- ir_stream
- visible_stream
- uv_stream
State
This device driver has a binary state: on or off. When off, no parameter values are streamed or available, and no commands are accepted other than the turn-on transition. When on, the device is operations and accepts all commands. The initial state is off.
Transitions
turn-on : Sets the device state to on. When on, the device is operational and accepts all commands. Values are streamed, and the device is polled periodically to keep monitored values up to date.
turn-off : Sets the device state to off, When off, no parameter values are streamed or available, and no commands are accepted other than the turn-on transition.
Compatibility
This driver is designed to run within the Lynxari IoT platform. While Lynxari will run on nearly any operating system, this driver employs UNIX-specific protocols and as such will run on the following operating systems:
- 32 or 64-bit Linux
- macOS and OS X
- SunOS
- AIX
Copyright
Copyright © 2018 Agilatech®. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.