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

one-wire-temps

v0.2.1

Published

A package to enable gathering one or more temperatures form the one-wire protocol using johnny-five and firmatta.

Downloads

25

Readme

one-wire-temps

Module for reading temperatures from a one-wire bus over firmata.

Overview

The OneWireTemps module is a non-blocking module which can read the temperature probes from the one-wire protocol. It is capable of handling many probes on the same bus.

The module works by cycling through each device on the bus and reading the temperature and storing it. The process then repeats perpetually.

Retreiving Measurements

At any time, the most recent temperture and updated time for each probe can be retreived by calling getSingleTemp(unitType, deviceNumber, callback) or all temps and last updated times can be retreived by calling getTemperatures(unitType, callback). The callback takes two arguments. The temperatue(s) and the lastUpdate(s).

UnitTypes

  • owts.unit_raw = UNIT_TYPE_RAW; - The raw reading returned from the probe.
  • owts.unit_celcius = UNIT_TYPE_CELCIUS; - The temperature converted into Celcius.
  • owts.unit_farenheit = UNIT_TYPE_FARENHEIT; - The temperature converted into Farenheit.

Configuration

An optional configuration object can be passed into the constructor with one or more properties.

  • cycleDelay - Time to delay the entire cycle each time it resets in milliseconds.
  • nextDeviceDelay - Time to delay the reading of each probe before moving to the next one in milliseconds. Example
// Lets have the temperatures refresh every 5 seconds.
var config = { cycleDelay:0, nextDeviceDelay:5000 };
var onewiretemps = new owts.obj(board, pin, config);

Events

  • Initialized - Called once all devices have been identified but before the temperature reading has started.
  • Ready - Called once all temperature probes have been read one time ( a single full cycle).
  • CycleComplete - Called everytime the temperature cycle completes.

Examples

  • Initialization
// Import dependencies
var five = require('johnny-five'), board
var owts = require('one-wire-temps');

// Establish ssome of the confiugration
var pin = 3;
var board = new five.Board();

// Create the OneWireTemps object
var onewiretemps = new owts.obj(board, pin, {cycleDelay:100});
  • A basic case to output all the temperatures every 100ms, regardless of how fast they are updated.
onewiretemps.on("Ready", function() {
	setInterval(onewiretemps.getTemperatures,100, owts.unit_farenheit, function(temps, lastUpdates){
		console.log(temps);
	});
});
  • Getting a single temperature from probe #2 once all the temperatures have been initialized the first time.
onewiretemps.on("Ready", function() {
	onewiretemps.getSingleTemp(owts.unit_farenheit, 2, function(temp, lastUpdate) {
		console.log(temp + ' @ ' + lastUpdate);
	});
});
  • Output all temperatures each time the temperature loop cycles.
onewiretemps.on("CycleComplete", function() {
	onewiretemps.getTemperatures(owts.unit_farenheit, function(temps, lastUpdate) {
		console.log(temps);
	});
});