A simple Node.js library to read temperature and humidity values from the SHT31/SHT35 sensors.
This library relies on this datasheet.
- A Raspberry Pi
- I2C must be enabled
- SHT31 or SHT35 sensor Adafruit
- Node.js v7.6 or newer
# Run this in your favourite terminal
npm i sht31-node
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)
Original work by @aphotix. Initially a fork of @alwint3r's well written sht31-node package.