npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ds2482-temperature

v0.3.0

Published

Provides an interface for Dallas DS18B20 temperature sensors over the DS2482 onewire bridge

Downloads

11

Readme

DS18B20 Onewire Temperature Sensor

![Gitter](https://badges.gitter.im/Join Chat.svg)

Provides an interface for Dallas DS18B20 temperature sensors over the DS2482 onewire bridge

Install

$ npm install ds2482-temperature

Usage

const DS18B20 = require('ds2482-temperature');

const sense = new DS18B20();

sense.init()
.then(() => sense.search())
.then(() => sense.readTemperatures())

.then(temps => {
  console.log(temps); // Returns a list of temperature reading from all found sensors
})

.catch(err => {
  console.error(err);
});

Streaming

const DS18B20 = require('ds2482-temperature');

const sense = new DS18B20();

sense.init()

.then(() => {
  sense.on('data', val => {
    console.log(val);
  });

  sense.on('error', err => {
    console.error(err);
  });
});

API

new DS18B20([options])

Creates an interface for Dallas DS18B20 temperature sensors. The instance inherites from readable stream and will search and emit measurements for all found sensors when a data listener is added.

Options:

  • wire an instance of wire
  • i2c an instance of i2c
  • address the i2c address of the bridge chip, default: 0x18
  • device the location of the i2c interface, default: /dev/i2c-1
  • units the temperature units, default: C
  • pollRate the rate to poll the sensors when streaming, default: 30 secs

sense.init()

Resets the bridge chip and any onewire devices connected to it

Returns: Promise <Uint8> resolves with DS2482 status register


sense.search()

Searches the bus and returns a list of found temperature sensors

Returns: Promise <Array <Sensor>> resolves with list of sensors

[
  <Sensor "2826274402000012">,
  <Sensor "28493331020000bf">,
  <Sensor "280b135f020000d9">
]

sense.readTemperatures()

Initiates a measurement and returns the temperature readings from all known sensors

Returns: Promise <Array {rom:String, value:Number, units:Sting}> resolves with list of temperatures

[
  {rom: "2826274402000012", value: 22.9375, units: "C"},
  {rom: "28493331020000bf", value: 22.875, units: "C"},
  {rom: "280b135f020000d9", value: 21.9375, units: "C"},
]

sense.destroy()

Destroys the streaming interface


new DS18B20.Sensor(rom [, options])

Creates a temperature sensor instance. The instance inherites from readable stream and will emit measurements from the sensor when a data listener is added.

Arguments:

  • rom the ROM address of the sensor as a 16 character hex encoded string

Options:

  • wire an instance of wire
  • i2c an instance of i2c
  • address the i2c address of the bridge chip, default: 0x18
  • device the location of the i2c interface, default: /dev/i2c-1
  • units the temperature units, default: C
  • pollRate the rate to poll the sensor when streaming, default: 30 secs

sensor.readTemperature()

Initiates a measurement and returns the temperature reading from a particular sensor

Returns: Promise <Number> resolves with temperature

22.9375

sensor.destroy()

Destroys the streaming interface