mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
33 lines
933 B
JavaScript
33 lines
933 B
JavaScript
/*
|
|
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
|
* Copyright (c) 2017 Intel Corporation.
|
|
*
|
|
* 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.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
//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);
|
|
});
|