Skip to content

🌡 A simple Node.js library for the SHT31/SHT35 sensors

License

Notifications You must be signed in to change notification settings

thomas-bouvier/sht31-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sht31-node

npm

A simple Node.js library to read temperature and humidity values from the SHT31/SHT35 sensors.

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

Installation

# Run this in your favourite terminal
npm i sht31-node

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.

About

🌡 A simple Node.js library for the SHT31/SHT35 sensors

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published