2017-05-08 17:52:46 -07:00
|
|
|
/*
|
|
|
|
|
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
|
|
|
|
* Copyright (c) 2017 Intel Corporation.
|
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2017-05-08 17:52:46 -07:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-05-08 17:52:46 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//Load the library
|
|
|
|
|
var upm = require('jsupm_htu21d');
|
|
|
|
|
|
|
|
|
|
//Create a sensor instance
|
|
|
|
|
var sensor = new upm.HTU21D(0);
|
|
|
|
|
|
|
|
|
|
//Update sensor data and print the values every second
|
|
|
|
|
var ival = setInterval(function () {
|
|
|
|
|
sensor.sampleData();
|
|
|
|
|
console.log("Relative Humidity: " + sensor.getHumidity() + "%");
|
|
|
|
|
console.log("Compensated RH: " + sensor.getCompRH() + "%");
|
|
|
|
|
console.log("Temperature: " + sensor.getTemperature() + "C");
|
|
|
|
|
console.log("Dew Point: " + sensor.getDewPoint() + "C");
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
//Clear interval and exit on ^C
|
|
|
|
|
process.on('SIGINT', function()
|
|
|
|
|
{
|
|
|
|
|
clearInterval(ival);
|
|
|
|
|
process.exit(0);
|
|
|
|
|
});
|