Giter Club home page Giter Club logo

rpi-acu-rite-temperature's Introduction

rpi-acu-rite-temperature

Library for reading the Acu-Rite 06002M Wireless Temperature and Humidity Sensor using a Raspberry Pi with a 433Mhz receiver

Note: This software is neither produced by nor endorsed by Acu-Rite. The author of this library is not associated with Acu-Rite or its products in any way, apart from finding their 433 MHz remote humidity/temperature sensors useful for this kind of project.

This library was inspired by work originally done by Ray Wang.

rpi-acu-rite-temperature can be used for JavaScript/TypeScript programming in a Node.js environment, or the included C++ code can be used directly. It is the JavaScript/TypeScript interface that is documented here.

Full functionality requires a Raspberry Pi, but this code can be installed and compiled under MacOS or Windows in such a way that it returns simulated data for testing and development use.


Breaking changes:

As of version 2.0.0, rpi-acu-rite-temperature uses the pigpio library instead of wiringPi for GPIO functionality. This greatly improves the reliability of signal processing, but requires running code with elevated privileges (via sudo, or otherwise as root). Pin numbering now defaults to Broadcom GPIO numbering, wiringPi numbering is available using PinSystem.WIRING_PI, and PinSystem.SYS is not available.


Installation

npm install rpi-acu-rite-temperature

Usage

const { addSensorDataListener, removeSensorDataListener } = require('rpi-acu-rite-temperature');

...or...

import { addSensorDataListener, PinSystem, removeSensorDataListener } from 'rpi-acu-rite-temperature';

HtSensorData

The format of the data returned by this library:

export interface HtSensorData {
  batteryLow: boolean;
  channel: string;       // A, B, C, or - (dash) when dead air detected
  humidity: number;      // Integer 0-100
  miscData1: number;     // Bits  2-15 of the transmission.
  miscData2: number;     // Bits 17-23 of the transmission.
  miscData3: number;     // Bits 33-35 of the transmission.
  rawTemp: number;       // Integer tenths of a degree Celsius plus 1000 (original transmission data format)
  signalQuality: number; // Integer 0-100
  tempCelsius: number;
  tempFahrenheit: number;
  validChecksum: boolean; // Is the data fully trustworthy?
}

channel is either the single-letter channel identifier A, B, or C, or it's a - (dash), indicating that no signal at all (not even radio noise) has been detected for 60 seconds or more. Since an RF receiver module typically outputs a lot of random noise even when it isn't receiving a valid transmission, “dead air” generally means that you've selected the wrong pin number, or the RF module is disconnected, or it is otherwise not functioning.

Even after a dead air indication has been received, and before signal has been regained, you might receive a few more updates for channels A, B, or C. These are delivered while the signal quality rating of each channel degrades toward zero during the absence of reception.

humidity will be undefined if the signal was decoded as having a value greater than 100.

rawTemp will be undefined, and tempCelsius and tempFahrenheit as well, if the signal was decoded with a value outside of the range ±60°C.

signalQuality is measured over a five minute window, and may register low even for a strong signal until a full five minutes have passed.

It's best for validChecksum to be true, but the data provided has at least been validated by three parity bits even if the checksum doesn't come out right. When a weak signal makes updates infrequent, it may be possible, with care, to use somewhat questionable data.

addSensorDataListener

addSensorDataListener(pin: number | string, callback: HtSensorDataCallback): number;
addSensorDataListener(pin: number, pinSystem: PinSystem, callback: HtSensorDataCallback): number;

This function is used to register a callback that receives the above temperature/humidity data. You must specify the input pin to which your 433 MHz RF receiver is connected, and optionally specify a pin numbering system. The default is PinSystem.GPIO, for Broadcom GPIO numbers. Optionally you may use:

  • PinSystem.PHYS: physical pin numbers on the P1 connector (1-40) or the Rev. 2 P5 connector (53-56 for P5 3-6) (string suffix p)
  • PinSystem.WIRING_PI: WiringPi pin numbers (string suffix w)
  • PinSystem.VIRTUAL: Same as WiringPi (string suffix v)

For more information see: http://wiringpi.com/reference/setup/

You can also specify the pin and pin system together as a string value, such as '13p', which is physical pin 13 on the P1 connector.

The function returns a numeric ID which can be used by the function below to unregister your callback.

removeSensorDataListener

removeSensorDataListener(callbackId: number): void;

convertPin

This is a utility function for converting between Raspberry Pi pin numbering systems. You can:

  1. pass a numeric pin number, the pin system of that pin number, and the pin system you wish to convert to.
  2. pass a numeric GPIO number and the pin system you wish to convert to.
  3. pass a pin number and pin system as one combined string, followed by the pin system you wish to convert to. The pin system for the original pin number is specified by an appended letter (g, p, w, or v, as described above), defaulting to GPIO if no letter is provided.

The function returns the converted pin value. If there is no valid conversion, the function returns -1.

export function convertPin(pin: number, pinSystemFrom: PinSystem, pinSystemTo: PinSystem): number;
export function convertPin(gpioPin: number, pinSystemTo: PinSystem): number;
export function convertPin(pin: string, pinSystemTo: PinSystem): number;

rpi-acu-rite-temperature's People

Contributors

kshetline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rpi-acu-rite-temperature's Issues

Adding the library to a new project fails

When trying to install the library, the command npm install rpi-acu-rite-temperature fails.
Please help with details regarding installation (postinstall steps failing)

node -v
v12.16.0
npm -v
6.13.4
tsc -v
Version 3.8.3
OS: MacOS 10.14.3

cd rpi-sensors
npm init ......
npm install rpi-acu-rite-temperature

[email protected] install /Users/someuser/rpi-sensors/node_modules/rpi-acu-rite-temperature
npm i [email protected] && node-gyp configure

npm notice created a lockfile as package-lock.json. You should commit this file.

  • [email protected]
    added 1 package from 50 contributors and audited 1 package in 0.423s
    found 0 vulnerabilities

[email protected] postinstall /Users/someuser/rpi-sensors/node_modules/rpi-acu-rite-temperature
tsc && node-gyp rebuild

Version 3.8.3
Syntax: tsc [options] [file...]

Examples: tsc hello.ts
tsc --outFile file.js file.ts
tsc @args.txt
tsc --build tsconfig.json

Options:
-h, --help Print this message.
-w, --watch Watch input files.
--pretty Stylize errors and messages using color and context (experimental).
--all Show all compiler options.
-v, --version Print the compiler's version.
--init Initializes a TypeScript project and creates a tsconfig.json file.
-p FILE OR DIRECTORY, --project FILE OR DIRECTORY Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
-b, --build Build one or more projects and their dependencies, if out of date
-t VERSION, --target VERSION Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'.
-m KIND, --module KIND Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'.
--lib Specify library files to be included in the compilation.
'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'esnext' 'dom' 'dom.iterable' 'webworker' 'webworker.importscripts' 'scripthost' 'es2015.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.array.include' 'es2017.object' 'es2017.sharedmemory' 'es2017.string' 'es2017.intl' 'es2017.typedarrays' 'es2018.asyncgenerator' 'es2018.asynciterable' 'es2018.intl' 'es2018.promise' 'es2018.regexp' 'es2019.array' 'es2019.object' 'es2019.string' 'es2019.symbol' 'es2020.bigint' 'es2020.promise' 'es2020.string' 'es2020.symbol.wellknown' 'esnext.array' 'esnext.symbol' 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint'
--allowJs Allow javascript files to be compiled.
--jsx KIND Specify JSX code generation: 'preserve', 'react-native', or 'react'.
-d, --declaration Generates corresponding '.d.ts' file.
--declarationMap Generates a sourcemap for each corresponding '.d.ts' file.
--sourceMap Generates corresponding '.map' file.
--outFile FILE Concatenate and emit output to single file.
--outDir DIRECTORY Redirect output structure to the directory.
--removeComments Do not emit comments to output.
--noEmit Do not emit outputs.
--strict Enable all strict type-checking options.
--noImplicitAny Raise error on expressions and declarations with an implied 'any' type.
--strictNullChecks Enable strict null checks.
--strictFunctionTypes Enable strict checking of function types.
--strictBindCallApply Enable strict 'bind', 'call', and 'apply' methods on functions.
--strictPropertyInitialization Enable strict checking of property initialization in classes.
--noImplicitThis Raise error on 'this' expressions with an implied 'any' type.
--alwaysStrict Parse in strict mode and emit "use strict" for each source file.
--noUnusedLocals Report errors on unused locals.
--noUnusedParameters Report errors on unused parameters.
--noImplicitReturns Report error when not all code paths in function return a value.
--noFallthroughCasesInSwitch Report errors for fallthrough cases in switch statement.
--types Type declaration files to be included in compilation.
--esModuleInterop Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
@ Insert command line options and files from a file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: tsc && node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.