npm install node-sht20
pnpm install node-sht20
yarn add node-sht20
Usage in TypeScript (with ES Modules):
import SHT20 from 'node-sht20';
const sensor = new SHT20({ bus: 1 });
async function start() {
await sensor.open();
const { temperature, humidity } = await sensor.read();
console.log(`Temperature: ${temperature.value} ${temperature.unit}`);
console.log(`Humidity: ${humidity.value} ${humidity.unit}`);
// Temperature in another unit
const degreeFahrenheit = temperature.toFahrenheit();
console.log(`Temperature: ${degreeFahrenheit.value} ${degreeFahrenheit.unit}`);
await sensor.close();
}
start();
👤 Julian Wowra development@julianwowra.de
- Github: @JulianWowra
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.