https://github.com/alwint3r/sht31-node
Module for reading SH31 sensor through i2c on Raspberry Pi
https://github.com/alwint3r/sht31-node
i2c iot raspberry-pi sensor sht31
Last synced: about 2 months ago
JSON representation
Module for reading SH31 sensor through i2c on Raspberry Pi
- Host: GitHub
- URL: https://github.com/alwint3r/sht31-node
- Owner: alwint3r
- License: mit
- Created: 2017-03-08T16:38:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-12T06:21:16.000Z (over 8 years ago)
- Last Synced: 2025-04-06T13:37:20.845Z (about 1 year ago)
- Topics: i2c, iot, raspberry-pi, sensor, sht31
- Language: JavaScript
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SHT31 Library for Node.js
=========================
Read temperature and humidity from SHT31 via i2c on a Raspberry Pi.
## Requirements
* Have Node v6 or newer installed.
* I2C enabled. See [this link](https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial) for more information about enabling I2C on Raspberry Pi.
## Installation
```bash
npm install --save sht31
```
or if you're using yarnpkg
```bash
yarnpkg add sht31
```
## Usage Example
```js
const SHT31 = require(`sht31`);
// NOTE: you might need to change the I2C bus number or
// SHT31 address.
// In this case, SHT31 address is 0x44
// and I2C bus number is 1
const sht31 = new SHT31(0x44, 1);
sht31
.init()
.then(() => sht31.readSensorData())
.then((data) => {
// data object follows this format:
// { temperature: Number, humidity: Number }
// temperature is in celcius unit.
console.log(data);
})
.catch((err) => {
// Handle error here
// ...
});
```