🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

rpi-1-wire

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpi-1-wire

One-wire sensors for the Raspberry Pi and similar devices running Node JS.

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

RPi 1-Wire

One-wire temperature sensors for the Raspberry Pi and similar devices running Node JS.

Prerequisites

  • A Raspberry Pi or similar device with 1-Wire GPIO.
  • Node JS >= 12.

Installation

$ npm i rpi-1-wire

You need to enable the 1-Wire bus: run sudo raspi-config then select Interface Options -> 1-Wire.

Usage

Asynchronous methods (return a promise).

// Test the 1-wire service is connected.
await isConnected();
// Get a list of attached sensor ids.
await getSensors();
// Get temperature from all sensors.
await getTemperature();
// Get temperature from a sensor.
await getSensorTemperature(id, options);

Target API

This is the target for v1.0.

Asynchronous methods (return a promise).

// Get a list of sensors.
getSensors();
// Get temperature from all sensors.
getTemperature(options);
// Get temperature from a sensor.
getSensorTemperature(id, options);

Synchronous methods (blocking).

// Get a list of sensors.
getSensorsSync();
// Get temperature from all sensors.
getTemperatureSync(options);
// Get temperature from a sensor.
getSensorTemperatureSync(id, options);
import { getTemperature } from 'rpi-1-wire';

// Get temperature from all sensors.
getTemperature();
// Promise<{
//   { id: '2812b3345', value: 21.345 },
//   { id: '282223345', value: 22.4 },
// }>

// Get temperature in Farenheit from all sensors.
getTemperature({ unit: 'F' });
// Promise<{
//   2812b3345: { id: '2812b3345', value: 55.345 },
//   28c12b335: { id: '2812b3345', value: 57.4 },
// }>

// Get temperature in Kelvin from all sensors.
getTemperature({ unit: 'K' });
// Promise<{
//   2812b3345: { id: '2812b3345', value: 291.345 },
//   28c12b335: { id: '282223345', value: 295.4 },
// }>

// Get temperature in all units from all sensors.
getTemperature({ unit: 'K,C,F' });
// Promise<{
//   2812b3345: { id: '2812b3345', values: { K: 291.345, C: 21.345, F: 55.345 },
//   28c12b335: { id: '2812b3345', values: { K: 295.4, C: 22.4, F: 57.4 },
// }>
import { getSensorTemperature } from 'rpi-1-wire';

// Get temperature from a sensor.
getSensorTemperature('2812b3345');
// Promise<21.345>

// Get temperature in Farenheit from a sensor.
getSensorTemperature('2812b3345', { unit: 'F' });
// Promise<55.345>

// Get temperature in Kelvin from a sensor.
getSensorTemperature('2812b3345', { unit: 'K' });
// Promise<291.345>

// Get temperature in all units from a sensor.
getTemperature({ unit: 'K,C,F' });
// Promise<{ K: 291.345, C: 21.345, F: 55.345 }>
import { getSensors } from 'rpi-1-wire';

// Get attached sensors.
getSensors();
// Promise<[ '2812b3345', '28c12b335' ]>

FAQs

Package last updated on 15 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts