Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thomas-bouvier/sht31-node
🌡 A simple Node.js library for the SHT31/SHT35 sensors
https://github.com/thomas-bouvier/sht31-node
home-automation i2c sensor sht31 sht35
Last synced: 7 days ago
JSON representation
🌡 A simple Node.js library for the SHT31/SHT35 sensors
- Host: GitHub
- URL: https://github.com/thomas-bouvier/sht31-node
- Owner: thomas-bouvier
- License: mit
- Created: 2019-09-06T16:56:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-25T18:38:28.000Z (almost 5 years ago)
- Last Synced: 2024-12-12T21:41:33.814Z (10 days ago)
- Topics: home-automation, i2c, sensor, sht31, sht35
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sht31-node
[![npm](https://img.shields.io/npm/v/sht31-node.svg)](https://www.npmjs.com/package/sht31-node)
A simple Node.js library to read temperature and humidity values from the SHT31/SHT35 sensors.
This library relies on [this datasheet](http://www.mouser.com/ds/2/682/Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital-1145192.pdf).
## Requirements
* A Raspberry Pi
* I2C must be enabled
* SHT31 or SHT35 sensor [Adafruit](https://www.adafruit.com/product/2857)
* Node.js v7.6 or newer## Installation
```bash
# 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.
```javascript
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](https://github.com/aphotix). Initially a fork of [@alwint3r](https://github.com/alwint3r)'s well written [sht31-node](https://github.com/alwint3r/sht31-node) package.