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

temper-usb

v0.1.0

Published

Node TEMPer USB library and CLI

Downloads

48

Readme

Temper

NPM version Build Status Coverage Status Dependency Status

TEMPer USB reader for NodeJS

Use connect to an interact with a temper USB compatible sensor. This project has been tested to work on a raspberry pi and should be easy to integrate into any NodeJS project. There is also a basic CLI which outputs JSONL optionally.

Usage

There is both a CLI and a library:

CLI

Get the current temp:

$ sudo temper
Found 1 devices
2017/02/27 23:52:20.793
  Device on bus 1
    S0: 32
    S1: 24.83984375

Get the current temp every 1s, in F, and and output as one JSON entry per line

$ sudo temper -f -p 1000 -j
Found 1 devices
[{"date":"2017-02-27T23:53:27.221Z","busNumber":1,"data":{"0":89.6,"1":76.71171875}}]

Library

import {getTemperDevices} from 'temper-usb'; // const getTemperDevices = require('temper-usb').getTemperDevices;
getTemperDevices().forEach((td) => td.getTemperature().then(console.log).catch(console.err));
// {"0": 89.6, "1": 76.71171875}

Often you want to test without have a USB pluggined in. For this, MockTemperDevice, which was used for testing has been exported.

import {mock, TemperDevice} from 'temper-usb';
const td = new mock.MockTemperDevice();
console.log(td instanceof TemperDevice); // True
td.getTemperature().then(console.log).catch(console.err); // in C
// { '0': 32.5, '1': 48 } 

Installation

Install temper as a dependency:

npm install --save temper-usb

If you want to install scripts globally, use -g. If you have install issues, checkout usb for more info on installing the correct usb libraries.

Permissions

As noted here and included in this project for reference. If you don't want to run this as sudo, copy etc/99-tempsensor.rules into /etc/udev/rules.d/. You will do something like:

sudo cp /path/to/my/project/node_modules/temper-usb/etc/99-tempsensor.rules /etc/udev/rules.d/

To test restart or reinsert the usb then you should see the following:

pi@raspberrypi:~ $ lsusb | grep "0c45:7401"
Bus 001 Device 013: ID 0c45:7401 Microdia 
pi@raspberrypi:~ $ sudo ls -l /dev/usb*
total 0
crw-rw-rw- 1 root root 180, 96 Mar  4 15:29 hiddev0

Debugging

We use debug. In node set env variable DEBUG=temper-usb:* or in a browser localStorage.debug='temper-usb:*' to see debugging output.

Notes and a Thank You

This project borrows heavily from temper-python and is a vague reimplementation in another language. They have documented many error cases in that project. It is also much more well tested and complete than this.

License

Apache-2.0 License