sht31-node
v1.0.1
Published
A simple solution to read temperature and humidity from the SHT31 sensor.
Downloads
46
Readme
sht31-node
A simple solution to read temperature and humidity from the SHT31 sensor.
This library relies on this datasheet.
Requirements
- A Raspberry Pi
- I2C must be enabled
- SHT31 or SHT35 sensor Adafruit
- Node.js v7.6 or newer
Usage
Simply require and instantiate the package as a class. The readSensorData
method returns a promise.
const { SHT31 } = require('sht31-node')
// Parameters are unecessary when using a B+, A+, Zero, Zero W, Pi 2, or Pi 3
const sht31 = new SHT31()
sht31.readSensorData().then(data => {
// Temperature in Fahrenheit
const temperature = Math.round(data.temperature * 1.8 + 32)
const humidity = Math.round(data.humidity)
console.log(`The temperature is: ${temperature}°F`)
console.log(`The Humidity is: ${humidity}%`)
}).catch(console.log)
Credits
Original work by @aphotix. Initially a fork of @alwint3r's well written sht31-node package.