Coder Social home page Coder Social logo

momenso / node-dht-sensor Goto Github PK

View Code? Open in Web Editor NEW
308.0 20.0 72.0 503 KB

Node.js Humidity and Temperature sensor addon

License: GNU Lesser General Public License v3.0

Python 0.36% C++ 8.52% JavaScript 3.44% C 87.69%
raspberry-pi nodejs dht22 dht11

node-dht-sensor's Introduction

node-dht-sensor

A simple node.js module for reading temperature and relative humidity using a compatible DHT sensor.

npm npm LICENSE

Installation

$ npm install node-dht-sensor

Please note that differently from versions 0.0.x there's no need to pre-install the BCM2835 library [2].

Usage

To initialize the sensor, you have to specify the sensor type and the GPIO pin where the sensor is connected to. It should work for DHT11, DHT22 and AM2302 sensors.

You should use sensorType value to match the sensor as follows:

Sensor sensorType value
DHT11 11
DHT22 or AM2302 22

If the initialization succeeds when you can call the read function to obtain the latest readout from the sensor. Readout values contains a temperature and a humidity property.

First Example

example1

This sample queries a DHT11 sensor connected to the GPIO 4 and prints out the result on the console.

var sensor = require("node-dht-sensor");

sensor.read(11, 4, function(err, temperature, humidity) {
  if (!err) {
    console.log(`temp: ${temperature}°C, humidity: ${humidity}%`);
  }
});

Multiple Sensors Example

example2

The following example shows a method for querying multiple sensors connected to the same Raspberry Pi. For this example, we have two sensors:

  1. A DHT11 sensor connected to GPIO 17
  2. High-resolution DHT22 sensor connected to GPIO 4
var sensorLib = require("node-dht-sensor");

var app = {
  sensors: [
    {
      name: "Indoor",
      type: 11,
      pin: 17
    },
    {
      name: "Outdoor",
      type: 22,
      pin: 4
    }
  ],
  read: function() {
    for (var sensor in this.sensors) {
      var readout = sensorLib.read(
        this.sensors[sensor].type,
        this.sensors[sensor].pin
      );
      console.log(
        `[${this.sensors[sensor].name}] ` +
          `temperature: ${readout.temperature.toFixed(1)}°C, ` +
          `humidity: ${readout.humidity.toFixed(1)}%`
      );
    }
    setTimeout(function() {
      app.read();
    }, 2000);
  }
};

app.read();

Promises API

Promises API provides an alternative read method that returns a Promise object rather than using a callback. The API is accessible via require('node-dht-sensor').promises.

var sensor = require("node-dht-sensor").promises;

// You can use `initialize` and `setMaxTries` just like before
sensor.setMaxRetries(10);
sensor.initialize(22, 17);

// You can still use the synchronous version of `read`:
// var readout = sensor.readSync(22, 4);

sensor.read(22, 17).then(
  function(res) {
    console.log(
      `temp: ${res.temperature.toFixed(1)}°C, ` +
        `humidity: ${res.humidity.toFixed(1)}%`
    );
  },
  function(err) {
    console.error("Failed to read sensor data:", err);
  }
);

Using async/await:

const sensor = require("node-dht-sensor").promises;

async function exec() {
  try {
    const res = await sensor.read(22, 4);
    console.log(
      `temp: ${res.temperature.toFixed(1)}°C, ` +
        `humidity: ${res.humidity.toFixed(1)}%`
    );
  } catch (err) {
    console.error("Failed to read sensor data:", err);
  }
}

exec();

Test mode

A test mode of operation is available since version 0.2.0. In this mode of operation, the library does not communicate with the sensor hardware via the GPIO but instead it returns a pre-configured readout value. You can use the test mode during development without the need to have an actual sensor connected.

To enable the test mode, fake values must be defined at initialization. In the example below we specify fixed values for temperature equal to 21°C and humidity equal to 60%.

sensor.initialize({
  test: {
    fake: {
      temperature: 21,
      humidity: 60
    }
  }
});

After initialization, we can call the read method as usual.

sensor.read(22, 4, function(err, temperature, humidity) {
  if (!err) {
    console.log(
      `temp: ${temperature.toFixed(1)}°C, ` +
        `humidity: ${humidity.toFixed(1)}%`
    );
  }
});

And the result will always be the configured readout value defined at initialization.

$ node examples/fake-test.js
temp: 21.0°C, humidity: 60.0%
$ node examples/fake-test.js
temp: 21.0°C, humidity: 60.0%

You can find a complete source code example in examples/fake-test.js.

Reference for building from source

Standard node-gyp commands are used to build the module. So, just make sure you have node and node-gyp as well as the Broadcom library to build the project.

  1. In case, you don't have node-gyp, install it first:

    $ sudo npm install -g node-gyp
    $ sudo update-alternatives --install /usr/bin/node-gyp node-gyp /opt/node-v10.15.3-linux-armv7l/bin/node-gyp 1
  2. Generate the configuration files

    $ node-gyp configure
  3. Build the component

    $ node-gyp build

Tracing and Debugging

Verbose output from the module can be enabled by by specifying the --dht_verbose=true flag when installing the node via npm.

$ npm install node-dht-sensor --dht_verbose=true

if you are interested in enabling trace when building directly from source you can enable the -Ddht_verbose flag when running node-gyp configure.

$ node-gyp configure -- -Ddht_verbose=true

Appendix A: Quick Node.js installation guide

There are many ways you can get Node.js installed on your Raspberry Pi. Here is just one of way you can do it.

$ wget https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-armv7l.tar.xz
$ tar xvfJ node-v14.15.4-linux-armv7l.tar.xz
$ sudo mv node-v14.15.4-linux-armv7l /opt
$ sudo update-alternatives --install /usr/bin/node node /opt/node-v14.15.4-linux-armv7l/bin/node 1
$ sudo update-alternatives --set node /opt/node-v14.15.4-linux-armv7l/bin/node
$ sudo update-alternatives --install /usr/bin/npm npm /opt/node-v14.15.4-linux-armv7l/bin/npm 1

Please note that you may have to use armv6l instead of arm7l if you have an early Raspberry Pi model.

References

[1]: Node.js download - https://nodejs.org/en/download/

[2]: BCM2835 - http://www.airspayce.com/mikem/bcm2835/

[3]: Node.js native addon build tool - https://github.com/TooTallNate/node-gyp

[4]: GPIO: Raspbery Pi Models A and B - https://www.raspberrypi.org/documentation/usage/gpio/

node-dht-sensor's People

Contributors

dependabot[bot] avatar fiws avatar kothique avatar mariuszkosmatka avatar momenso avatar mpursche avatar mwittig avatar olekenneth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-dht-sensor's Issues

getting an error when installing the library

hi All,

I am getting following error when trying to install the library on pi:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli 'node-dht-sensor' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: /home/pi/.npmrc. (matches userconfig)
5 silly cache add args [ 'node-dht-sensor', null ]
6 verbose cache add spec node-dht-sensor
7 silly cache add parsed spec { raw: 'node-dht-sensor',
7 silly cache add scope: null,
7 silly cache add name: 'node-dht-sensor',
7 silly cache add rawSpec: '',
7 silly cache add spec: '',
7 silly cache add type: 'range' }
8 verbose addNamed node-dht-sensor@

9 silly addNamed semver.valid null
10 silly addNamed semver.validRange *
11 silly addNameRange { name: 'node-dht-sensor', range: '', hasData: false }
12 silly mapToRegistry name node-dht-sensor
13 silly mapToRegistry using default registry
14 silly mapToRegistry registry https://registry.npmjs.org/
15 silly mapToRegistry uri https://registry.npmjs.org/node-dht-sensor
16 verbose addNameRange registry:https://registry.npmjs.org/node-dht-sensor not in flight; fetching
17 verbose request uri https://registry.npmjs.org/node-dht-sensor
18 verbose request no auth needed
19 info attempt registry request try #1 at 10:19:49
20 verbose request id 1f20a176687171af
21 verbose etag "B7YPB0FKNLKETDYQX2WQ50DG0"
22 http request GET https://registry.npmjs.org/node-dht-sensor
23 http 304 https://registry.npmjs.org/node-dht-sensor
24 silly get cb [ 304,
24 silly get { date: 'Sun, 17 May 2015 10:19:50 GMT',
24 silly get via: '1.1 varnish',
24 silly get 'cache-control': 'max-age=60',
24 silly get etag: '"B7YPB0FKNLKETDYQX2WQ50DG0"',
24 silly get age: '0',
24 silly get connection: 'keep-alive',
24 silly get 'x-served-by': 'cache-ams4130-AMS',
24 silly get 'x-cache': 'MISS',
24 silly get 'x-cache-hits': '0',
24 silly get 'x-timer': 'S1431857990.313875,VS0,VE372',
24 silly get vary: 'Accept' } ]
25 verbose etag https://registry.npmjs.org/node-dht-sensor from cache
26 verbose get saving node-dht-sensor to /home/pi/.npm/registry.npmjs.org/node-dht-sensor/.cache.json
27 silly addNameRange number 2 { name: 'node-dht-sensor', range: '
', hasData: true }
28 silly addNameRange versions [ 'node-dht-sensor',
28 silly addNameRange [ '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7' ] ]
29 verbose addNamed [email protected]
30 silly addNamed semver.valid 0.0.7
31 silly addNamed semver.validRange 0.0.7
32 silly cache afterAdd [email protected]
33 verbose afterAdd /home/pi/.npm/node-dht-sensor/0.0.7/package/package.json not in flight; writing
34 verbose afterAdd /home/pi/.npm/node-dht-sensor/0.0.7/package/package.json written
35 silly install resolved [ { author: { name: 'David Momenso' },
35 silly install resolved name: 'node-dht-sensor',
35 silly install resolved description: 'Read data from DHT sensors on Raspberry Pi',
35 silly install resolved version: '0.0.7',
35 silly install resolved repository: { url: 'https://github.com/momenso/node-dht-sensor' },
35 silly install resolved main: './build/Release/node-dht-sensor',
35 silly install resolved dependencies: {},
35 silly install resolved engines: { node: '>=0.12 <0.13' },
35 silly install resolved license: 'LGPL',
35 silly install resolved scripts: { install: 'node-gyp rebuild' },
35 silly install resolved gypfile: true,
35 silly install resolved gitHead: '01f52b7eb4acb024e6c0592dfcf6e0092c0dce42',
35 silly install resolved bugs: { url: 'https://github.com/momenso/node-dht-sensor/issues' },
35 silly install resolved homepage: 'https://github.com/momenso/node-dht-sensor',
35 silly install resolved _id: '[email protected]',
35 silly install resolved _shasum: '5646264968973e15fb650fa2444d151299834367',
35 silly install resolved _from: 'node-dht-sensor@*',
35 silly install resolved _npmVersion: '2.5.1',
35 silly install resolved _nodeVersion: '0.12.0',
35 silly install resolved _npmUser: { name: 'momenso', email: '[email protected]' },
35 silly install resolved maintainers: [ [Object] ],
35 silly install resolved dist:
35 silly install resolved { shasum: '5646264968973e15fb650fa2444d151299834367',
35 silly install resolved tarball: 'http://registry.npmjs.org/node-dht-sensor/-/node-dht-sensor-0.0.7.tgz' },
35 silly install resolved directories: {},
35 silly install resolved _resolved: 'https://registry.npmjs.org/node-dht-sensor/-/node-dht-sensor-0.0.7.tgz',
35 silly install resolved readme: 'ERROR: No README data found!' } ]
36 info install [email protected] into /home/pi
37 info installOne [email protected]
38 verbose installOne of node-dht-sensor to /home/pi not in flight; installing
39 verbose lock using /home/pi/.npm/_locks/node-dht-sensor-2c3fc3d2e9bcb4e3.lock for /home/pi/node_modules/node-dht-sensor
40 silly install write writing node-dht-sensor 0.0.7 to /home/pi/node_modules/node-dht-sensor
41 silly cache addNamed cb [email protected]
42 verbose unbuild node_modules/node-dht-sensor
43 verbose gentlyRm vacuuming /home/pi/node_modules/node-dht-sensor
44 verbose tar unpack /home/pi/.npm/node-dht-sensor/0.0.7/package.tgz
45 verbose tar unpacking to /home/pi/node_modules/node-dht-sensor
46 verbose gentlyRm vacuuming /home/pi/node_modules/node-dht-sensor
47 silly gunzTarPerm modes [ '755', '644' ]
48 silly gunzTarPerm extractEntry package.json
49 silly gunzTarPerm extractEntry .npmignore
50 silly gunzTarPerm extractEntry README.md
51 silly gunzTarPerm extractEntry LICENSE
52 silly gunzTarPerm extractEntry test-spec.js
53 silly gunzTarPerm extractEntry test.js
54 silly gunzTarPerm extractEntry binding.gyp
55 silly gunzTarPerm extractEntry node-dht-sensor.cpp
56 info preinstall [email protected]
57 silly install resolved []
58 verbose about to build /home/pi/node_modules/node-dht-sensor
59 info build /home/pi/node_modules/node-dht-sensor
60 verbose linkStuff [ false, false, false, '/home/pi/node_modules' ]
61 info linkStuff [email protected]
62 verbose linkBins [email protected]
63 verbose linkMans [email protected]
64 verbose rebuildBundles [email protected]
65 info install [email protected]
66 verbose unsafe-perm in lifecycle true
67 info [email protected] Failed to exec install script
68 verbose unlock done using /home/pi/.npm/_locks/node-dht-sensor-2c3fc3d2e9bcb4e3.lock for /home/pi/node_modules/node-dht-sensor
69 verbose stack Error: [email protected] install: node-gyp rebuild
69 verbose stack Exit status 1
69 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
69 verbose stack at EventEmitter.emit (events.js:110:17)
69 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:14:12)
69 verbose stack at ChildProcess.emit (events.js:110:17)
69 verbose stack at maybeClose (child_process.js:1008:16)
69 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
70 verbose pkgid [email protected]
71 verbose cwd /home/pi
72 error Linux 3.18.11+
73 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "node-dht-sensor"
74 error node v0.12.1
75 error npm v2.5.1
76 error code ELIFECYCLE
77 error [email protected] install: node-gyp rebuild
77 error Exit status 1
78 error Failed at the [email protected] install script 'node-gyp rebuild'.
78 error This is most likely a problem with the node-dht-sensor package,
78 error not with npm itself.
78 error Tell the author that this fails on your system:
78 error node-gyp rebuild
78 error You can get their info via:
78 error npm owner ls node-dht-sensor
78 error There is likely additional logging output above.
79 verbose exit [ 1, true ]
80 verbose unbuild node_modules/node-dht-sensor
81 info preuninstall [email protected]
82 info uninstall [email protected]
83 verbose unbuild rmStuff [email protected] from /home/pi/node_modules
84 info postuninstall [email protected]
85 verbose gentlyRm vacuuming /home/pi/node_modules/node-dht-sensor
86 silly gentlyRm purging /home/pi/node_modules/node-dht-sensor
87 silly gentlyRm removing /home/pi/node_modules
88 silly gentlyRm finished vacuuming up to /home/pi

who can help me out?

Install on Raspberry Pi failing - gyp ERR! stack Error: `make` failed with exit code: 2

Using sudo npm install node-dht-sensor to try and install on my RaspberryPi is failing

I may be missing a pre req - but I can't seem to figure out what.

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2

Environment Details

$ node -v
v0.10.28
$ node -v
v0.10.28
$ python --version
Python 2.7.3
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1) 

Command line output and debug files:

https://gist.github.com/mrkd/3adfe82f5e135a528168

Example Schematics

Connecting a DHT22 module to your Raspberry Pi
example1

Connecting a DHT11 and DHT22 sensors.
example2

Always returning 0, 0 for temperature and humidity

I must be going crazy, but I can swear I've quadruple checked my breadboard configuration connectivity to my GPIO, but the results is always an array of temperature and humidity with the values of 0.

Any thoughts on this?

can't install

I have libbcm in 1.39
nodejs in v0.12.0 and it can't be installed

pi@raspberrypi ~/dht22 $ npm install --save node-dht-sensor
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
|
> [email protected] install /home/pi/dht22/node_modules/node-dht-sensor
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory '/home/pi/dht22/node_modules/node-dht-sensor/build'
  CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
../node-dht-sensor.cpp:205:26: error: ‘Arguments’ does not name a type
../node-dht-sensor.cpp:205:37: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h: In function ‘v8::Handle<v8::Value> Read(const int&)’:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
../node-dht-sensor.cpp:206:17: error: within this context
../node-dht-sensor.cpp:216:41: error: no matching function for call to ‘v8::Object::New()’
../node-dht-sensor.cpp:216:41: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:2388:24: note: static v8::Local<v8::Object> v8::Object::New(v8::Isolate*)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:2388:24: note:   candidate expects 1 argument, 0 provided
../node-dht-sensor.cpp:217:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:217:69: error: no matching function for call to ‘v8::Number::New(float&)’
../node-dht-sensor.cpp:217:69: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:218:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:218:75: error: no matching function for call to ‘v8::Number::New(float&)’
../node-dht-sensor.cpp:218:75: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:219:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:219:72: error: no matching function for call to ‘v8::Boolean::New(bool)’
../node-dht-sensor.cpp:219:72: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(v8::Isolate*, bool)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:220:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:220:68: error: no matching function for call to ‘v8::Number::New(int)’
../node-dht-sensor.cpp:220:68: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:221:18: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp: At global scope:
../node-dht-sensor.cpp:224:30: error: ‘Arguments’ does not name a type
../node-dht-sensor.cpp:224:41: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h: In function ‘v8::Handle<v8::Value> ReadSpec(const int&)’:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
../node-dht-sensor.cpp:225:17: error: within this context
../node-dht-sensor.cpp:227:14: error: request for member ‘Length’ in ‘args’, which is of non-class type ‘const int’
../node-dht-sensor.cpp:228:44: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:228:85: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:229:21: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:229:37: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:232:28: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:234:45: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:234:94: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:235:22: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:235:38: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:241:49: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:241:86: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:242:26: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:242:42: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:246:22: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:255:41: error: no matching function for call to ‘v8::Object::New()’
../node-dht-sensor.cpp:255:41: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:2388:24: note: static v8::Local<v8::Object> v8::Object::New(v8::Isolate*)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:2388:24: note:   candidate expects 1 argument, 0 provided
../node-dht-sensor.cpp:256:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:256:69: error: no matching function for call to ‘v8::Number::New(float&)’
../node-dht-sensor.cpp:256:69: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:257:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:257:75: error: no matching function for call to ‘v8::Number::New(float&)’
../node-dht-sensor.cpp:257:75: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:258:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:258:72: error: no matching function for call to ‘v8::Boolean::New(bool)’
../node-dht-sensor.cpp:258:72: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(v8::Isolate*, bool)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:259:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:259:68: error: no matching function for call to ‘v8::Number::New(int)’
../node-dht-sensor.cpp:259:68: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp:260:18: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp: At global scope:
../node-dht-sensor.cpp:263:32: error: ‘Arguments’ does not name a type
../node-dht-sensor.cpp:263:43: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h: In function ‘v8::Handle<v8::Value> Initialize(const int&)’:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
../node-dht-sensor.cpp:264:17: error: within this context
../node-dht-sensor.cpp:266:14: error: request for member ‘Length’ in ‘args’, which is of non-class type ‘const int’
../node-dht-sensor.cpp:267:45: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:267:86: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:268:22: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:268:38: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:271:16: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:271:40: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:272:45: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:272:76: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:273:22: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:273:38: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:276:28: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:278:45: error: ‘New’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:278:99: error: ‘ThrowException’ was not declared in this scope
../node-dht-sensor.cpp:279:22: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:279:38: error: too few arguments to function ‘v8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:305:28: note: declared here
../node-dht-sensor.cpp:284:22: error: invalid types ‘const int[int]’ for array subscript
../node-dht-sensor.cpp:286:18: error: ‘class v8::HandleScope’ has no member named ‘Close’
../node-dht-sensor.cpp:286:58: error: no matching function for call to ‘v8::Boolean::New(bool)’
../node-dht-sensor.cpp:286:58: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(v8::Isolate*, bool)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:6194:17: note:   candidate expects 2 arguments, 1 provided
../node-dht-sensor.cpp: In function ‘void RegisterModule(v8::Handle<v8::Object>)’:
../node-dht-sensor.cpp:290:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:291:43: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
../node-dht-sensor.cpp:291:43: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note:   no known conversion for argument 1 from ‘v8::Handle<v8::Value>(const int&)’ to ‘v8::Isolate*’
../node-dht-sensor.cpp:292:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:293:47: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
../node-dht-sensor.cpp:293:47: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note:   no known conversion for argument 1 from ‘v8::Handle<v8::Value>(const int&)’ to ‘v8::Isolate*’
../node-dht-sensor.cpp:294:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:295:49: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
../node-dht-sensor.cpp:295:49: note: candidate is:
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
/home/pi/.node-gyp/0.12.0/deps/v8/include/v8.h:3455:34: note:   no known conversion for argument 1 from ‘v8::Handle<v8::Value>(const int&)’ to ‘v8::Isolate*’
../node-dht-sensor.cpp: In function ‘v8::Handle<v8::Value> Initialize(const int&)’:
../node-dht-sensor.cpp:287:1: warning: control reaches end of non-void function [-Wreturn-type]
../node-dht-sensor.cpp: In function ‘v8::Handle<v8::Value> ReadSpec(const int&)’:
../node-dht-sensor.cpp:261:1: warning: control reaches end of non-void function [-Wreturn-type]
../node-dht-sensor.cpp: In function ‘v8::Handle<v8::Value> Read(const int&)’:
../node-dht-sensor.cpp:222:1: warning: control reaches end of non-void function [-Wreturn-type]
node-dht-sensor.target.mk:81: recipe for target 'Release/obj.target/node-dht-sensor/node-dht-sensor.o' failed
make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1
make: Leaving directory '/home/pi/dht22/node_modules/node-dht-sensor/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.18.5+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/dht22/node_modules/node-dht-sensor
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
npm ERR! Linux 3.18.5+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "node-dht-sensor"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/dht22/npm-debug.log

Strange doubling of Temperature

Hey!

I've recently set up an application to read the temperature in my room and ocasionally it will double the temperature value. I would say this occurs about once every 12 hours or so.

I'm using the DHT22 sensor with a status LED. Here's an image of the issue I'm facing, notice the temperature.

snap-2016-08-14_01-10-42

The code I'm using to read out the data appears to be inline with the example. It polls the sensor every 30 seconds.

const sensorLib = require('node-dht-sensor');
const config = require('../config.json').sensor;
const LED = require('./LED');

sensorLib.initialize(22, config.gpio);

module.exports =  {
    read() {
        LED.enable();
        var readout = sensorLib.read();
        LED.disable();
        return readout;
    }
};

Any ideas as to why this might be occurring?

Install Problem

I have a problem with the install.
Here is the list of the errors I get:

pi@raspberrypi:~ $ sudo npm install node-dht-sensor
npm WARN lifecycle [email protected]~preinstall: cannot run in wd %s %s (wd=%s) [email protected] ./check-lib.sh /home/pi/node_modules/.staging/node-dht-sensor-cfd4dcc2

[email protected] install /home/pi/node_modules/node-dht-sensor
node-gyp configure

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.7.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/pi/node_modules/node-dht-sensor/.node-gyp"

[email protected] postinstall /home/pi/node_modules/node-dht-sensor
node-gyp build

make: Entering directory '/home/pi/node_modules/node-dht-sensor/build'
make: *** No rule to make target '../.node-gyp/6.7.0/include/node/common.gypi', needed by 'Makefile'. Stop.
make: Leaving directory '/home/pi/node_modules/node-dht-sensor/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.13+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build"
gyp ERR! cwd /home/pi/node_modules/node-dht-sensor
gyp ERR! node -v v6.7.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.
npm ERR! Linux 4.4.13+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! node v6.7.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: node-gyp build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node-gyp build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-dht-sensor
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/npm-debug.log

BCM2385 is already installed.

Could not install module

Hi,

Forgive me for my bad english. I have an issue while trying to install the module. This module wasn't installed before.

make: Entering directory '/home/spraybot/sprayBot/node_modules/.staging/node-dht-sensor-57b2f592/build'
CXX(target) Release/obj.target/node_dht_sensor/node-dht-sensor.o
SOLINK_MODULE(target) Release/obj.target/node_dht_sensor.node
COPY Release/node_dht_sensor.node
make: Leaving directory '/home/spraybot/sprayBot/node_modules/.staging/node-dht-sensor-57b2f592/build'
npm ERR! Linux 4.1.20-v7+
npm ERR! argv "/opt/node-v5.9.1-linux-armv7l/bin/node" "/usr/bin/npm" "install" "node-dht-sensor" "--save"
npm ERR! node v5.9.1
npm ERR! npm v3.7.3
npm ERR! path /home/spraybot/sprayBot/node_modules/node-dht-sensor
npm ERR! code ENOTEMPTY
npm ERR! errno -39
npm ERR! syscall rename

npm ERR! ENOTEMPTY: directory not empty, rename '/home/spraybot/sprayBot/node_modules/node-dht-sensor' -> '/home/spraybot/sprayBot/node_modules/.node-dht-sensor.DELETE'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/spraybot/sprayBot/npm-debug.log

Is there a way to setup the module ?

Thanks.

Issue when i try "sudo npm install node-dht-sensor" (after install BCM2835 library)

When i try to install this error:

sudo npm install node-dht-sensor

[email protected] install /home/pi/node_modules/node-dht-sensor
node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.12.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/pi/node_modules/node-dht-sensor/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: node-v0.12.0.tar.gz local checksum b73cf11c8e1df999f2fea8ce59dd1ecd25df699c2fd352610cc3ba05c915857b not match remote 9700e23af4e9b3643af48cef5f2ad20a1331ff531a12154eef2bfb0bb1682e32
gyp ERR! stack at deref (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:299:20)
gyp ERR! stack at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:340:13)
gyp ERR! stack at IncomingMessage.emit (events.js:129:20)
gyp ERR! stack at _stream_readable.js:908:16
gyp ERR! stack at process._tickCallback (node.js:355:11)
gyp ERR! System Linux 3.18.5+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/node_modules/node-dht-sensor
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Linux 3.18.5+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/node-v0.12.0/npm-debug.log

Can someone help me?

swapped values

I don't know if it depends on the sensor, but I use a DHT 11 and readout.temperature returns the humidity while readout.humidity returns the temperature

rpi 3 return values always returning 0.0

I am using dht11 with rpi3.

var sensorLib = require('node-dht-sensor');

var sensor = {
initialize: function () {
return sensorLib.initialize(11, 4);
},
read: function () {
var readout = sensorLib.read();
console.log('Temperature: ' + readout.temperature.toFixed(2) + 'C, ' +
'humidity: ' + readout.humidity.toFixed(2) + '%');
setTimeout(function () {
sensor.read();
}, 2000);
}
};

if (sensor.initialize()) {
sensor.read();
} else {
console.warn('Failed to initialize sensor');
}

I am using this example code. Dht11's data pin connected to gpio4. bcm2835 library also installed. But return values always 0.0. I am sure that connection is true, because i can get temperature with c code.

correct output format

I am using DHT11 and trying to run your second code example, currently I am getting this output

Outdoor: 896.0C, 896.0%

please explain how to understand or convert these values into simple understandable values

screen shot 2015-05-12 at 9 35 03 pm

Can't run - node-dht-sensor.node: undefined symbol: init

I'm having trouble with running this package. When I run the example code for a single DTH11 sensor, I get the following:

module.js:485                                                                                                                                                     
  process.dlopen(filename, module.exports);                                                                                                                       
          ^                                                                                                                                                       
Error: /usr/share/adafruit/webide/node_modules/node-dht-sensor/build/Release/node-dht-sensor.node: undefined symbol: init                                         
    at Object.Module._extensions..node (module.js:485:11)                                                                                                         
    at Module.load (module.js:356:32)                                                                                                                             
    at Function.Module._load (module.js:312:12)                                                                                                                   
    at Module.require (module.js:362:17)                                                                                                                          
    at require (module.js:378:17)                                                                                                                                 
    at Object.<anonymous> (/usr/share/adafruit/webide/repositories/my-pi-projects/DHT11.js:1:79)                                                                  
    at Module._compile (module.js:449:26)                                                                                                                         
    at Object.Module._extensions..js (module.js:467:10)                                                                                                           
    at Module.load (module.js:356:32)                                                                                                                             
    at Function.Module._load (module.js:312:12)

I haven't been able to figure this out. Can anyone help please?

TypeError: sensorLib.readSpec is not a function

Trying to use DHT22 in Node Red. Everything seems to have installed fine but keep getting the error in the title.
Node Red version 14.6
Node version 4.6.0
npm version 2.15.9
bcm library 1.50

Flow:
[{"id":"40588b83.b5ccb4","type":"rpi-dht22","z":"ec482b12.18a198","name":"","topic":"rpi-dht22","dht":22,"pintype":"0","pin":"14","x":695,"y":237,"wires":[["cd8fe79f.9e7c78"]]},{"id":"5b0e8fec.3b0c6","type":"inject","z":"ec482b12.18a198","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":384,"y":236,"wires":[["40588b83.b5ccb4"]]},{"id":"cd8fe79f.9e7c78","type":"debug","z":"ec482b12.18a198","name":"","active":true,"console":"false","complete":"false","x":969,"y":237,"wires":[]}]

Can't install the repo

Hi there!

I'm trying to install your repo to my raspberry pi and that's what it's sending to me =/

npm http GET https://registry.npmjs.org/node-dht-sensor
npm http 304 https://registry.npmjs.org/node-dht-sensor

[email protected] install /home/pi/node_modules/node-dht-sensor
node-gyp rebuild

make: Entering directory /home/pi/node_modules/node-dht-sensor/build' CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o ../node-dht-sensor.cpp: In function ‘long int readDHT(int, int, float&, float&)’: ../node-dht-sensor.cpp:75:22: error: ‘bcm2835_delay’ was not declared in this scope ../node-dht-sensor.cpp:92:36: error: ‘bcm2835_delayMicroseconds’ was not declared in this scope make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1 make: Leaving directory/home/pi/node_modules/node-dht-sensor/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/opt/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:784:12)
gyp ERR! System Linux 3.10.25+
gyp ERR! command "node" "/opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/node_modules/node-dht-sensor
gyp ERR! node -v v0.10.4
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! sh "-c" "node-gyp rebuild" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.10.25+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0


How can this be fixed? Waiting for response 👍

Sometimes script gives double value of temperature and humidity.

Sensor AM2301 (DHT21).
Began to see that sometimes temperature and humidity have the doubled value in comparison with last reading.
Example: temp 25 С, hm 40%. Next reading i get 50 С and 80 %. It is similar to left bit shift.
This bug happens quite seldom and I can't catch it by means of the logic analyzer, but it is visible on the diagram which is built of the written data file.

Memory problem

I have encountered a problem when running this node

After a while I get the following:

bcm2835_init: gpio mmap failed: Cannot allocate memory

Has this happened to you? I have the newest bcm library 1.39.
Any sugestions?
Thank you

Failed to install module.

Getting an error during the installation of this module. I have installed BCM2835 library though module is giving an error during installation. I have executed ./check-bcm2835 script, it gives me a following output,

Library bcm2835 found.
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp http GET https://nodejs.org/dist/v0.12.6/node-v0.12.6.tar.gz
gyp http 200 https://nodejs.org/dist/v0.12.6/node-v0.12.6.tar.gz
gyp http GET https://nodejs.org/dist/v0.12.6/SHASUMS256.txt
gyp http 200 https://nodejs.org/dist/v0.12.6/SHASUMS256.txt
gyp info spawn python2
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.npm/node-dht-sensor/0.0.8/package/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.node-gyp/0.12.6/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/pi/.node-gyp/0.12.6',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args '-Dmodule_root_dir=/home/pi/.npm/node-dht-sensor/0.0.8/package',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory /home/pi/.npm/node-dht-sensor/0.0.8/package/build' CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o ../node-dht-sensor.cpp: In function ‘long int readDHT(int, int, float&, float&)’: ../node-dht-sensor.cpp:75:22: error: ‘bcm2835_delay’ was not declared in this scope ../node-dht-sensor.cpp:92:36: error: ‘bcm2835_delayMicroseconds’ was not declared in this scope make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1 make: Leaving directory/home/pi/.npm/node-dht-sensor/0.0.8/package/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.10.25+
gyp ERR! command "node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/.npm/node-dht-sensor/0.0.8/package
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

sensorLib.read() is blocking

Hi folks,

while playing around with my raspberry pi and some sensors/actors (dht11 / button / led) i observed, that the read() method seems to block the application in a synchronous manner (executing the read() method on my rpi b+ takes something from a few milliseconds up to 3 seconds).

My simple application reads the sensor data every 5 seconds, besides a led lights up if i press the button (using https://github.com/fivdi/pigpio#buttons-and-interrupt-handling). The problem is, if i press the button while the read() method gets executed nothing happens until the read operation is finished. Then the interrupt handler for the button gets called only once no matter how often i pressed the button in the meanwhile.

I'm not sure if an asynchronous/callback approach would solve this problem, but missing sensor inputs might become a problem in some scenarios.

Thanks in advance!

Refusing to install node-dht-sensor as a dependency of itself

I've followed all of your suggestions with the following two exceptions that errored out:

  1. Errors on running this: sudo dpkg -i node_latest_armhf.deb
    dpkg: regarding node_latest_armhf.deb containing node:
    nodejs-legacy conflicts with node
    node (version 4.2.1-1) is to be installed.
    node provides node and is to be installed.

dpkg: error processing archive node_latest_armhf.deb (--install):
conflicting packages - not installing node
Errors were encountered while processing:
node_latest_armhf.deb

Here is my overall error:
/usr/share/adafruit/webide/repositories/my-pi-projects/picamera_temp_humidity $ sudo npm install raspicam cloudinary node-dht-sensor node dweetio
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN install Refusing to install node-dht-sensor as a dependency of itself
npm WARN deprecated [email protected]: To update or install node, go to http://nodejs.org/
npm WARN engine [email protected]: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
[email protected] node_modules/node

[email protected] node_modules/cloudinary
├── [email protected]
└── [email protected]

[email protected] node_modules/raspicam
└── [email protected]

[email protected] node_modules/dweetio
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

Seems I'm getting close. Is this related the node.js error earlier? Any ideas?

Module always returns 0 with DHT11 and rPi 3

I've got a DHT11 connected to GPIO26 on my Raspberry Pi 3.
When I read this DHT11 with a simple python script it returns the correct temp and hum. So the DHT functions and is giving good values.

But when using nodejs v6.7.0 and the 'first example' script both values are 0.

Any idea why?

Error: Attempt to unlock nan, which hasn't been locked

pi@raspberrypi:~ $ sudo npm install -g node-dht-sensor
/
> [email protected] preinstall /usr/local/lib/node_modules/node-dht-sensor
> ./preinst

Library bcm2835 found.
Installing Native Abstractions for Node.js (NAN)...
npm ERR! Error: Attempt to unlock nan, which hasn't been locked
npm ERR!     at unlock (/usr/share/npm/lib/utils/locker.js:44:11)
npm ERR!     at cb (/usr/share/npm/lib/cache/add-local.js:30:5)
npm ERR!     at /usr/share/npm/lib/cache/add-local.js:47:20
npm ERR!     at /usr/share/npm/lib/utils/locker.js:22:20
npm ERR!     at /usr/share/npm/node_modules/inflight/inflight.js:22:7
npm ERR!     at Array.forEach (native)
npm ERR!     at res (/usr/share/npm/node_modules/inflight/inflight.js:21:9)
npm ERR!     at /usr/lib/nodejs/once.js:17:15
npm ERR!     at afterMkdir (/usr/share/npm/lib/cache/get-stat.js:53:14)
npm ERR!     at /usr/lib/nodejs/mkdirp/index.js:46:53
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 4.1.19-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "nan"
npm ERR! cwd /usr/local/lib/node_modules/node-dht-sensor
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/local/lib/node_modules/node-dht-sensor/npm-debug.log
npm ERR! not ok code 0
Rebuiling addon...
make: Entering directory '/usr/local/lib/node_modules/node-dht-sensor/build'
  CXX(target) Release/obj.target/node_dht_sensor/node-dht-sensor.o
  SOLINK_MODULE(target) Release/obj.target/node_dht_sensor.node
  SOLINK_MODULE(target) Release/obj.target/node_dht_sensor.node: Finished
  COPY Release/node_dht_sensor.node
make: Leaving directory '/usr/local/lib/node_modules/node-dht-sensor/build'
[email protected] /usr/local/lib/node_modules/node-dht-sensor
└── [email protected]

Cannot find module Error

I've every combination that I can think of to install node-dht-sensor but every time I run the test.js it fails with the following error. I little help would be most appreciated!

Thanks.

pi@raspberrypi:~/node_modules/node-dht-sensor $ sudo node test.js
module.js:440
throw err;
^

Error: Cannot find module './build/Release/node_dht_sensor'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (/home/pi/node_modules/node-dht-sensor/test.js:5:17)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)

not able to install node-dht-sensor

Hi everybody,
I'm pretty new and not very experienced in module installation. But I could install each module so far except the node-dht-sensor.
node -v --> v0.10.4
npm -v --> 1.2.18

I recieved following error:

pi@raspberrypi ~ $ npm install node-dht-sensor
npm http GET https://registry.npmjs.org/node-dht-sensor
npm http 200 https://registry.npmjs.org/node-dht-sensor
npm http GET https://registry.npmjs.org/node-dht-sensor/-/node-dht-sensor-0.0.2.tgz
npm http 200 https://registry.npmjs.org/node-dht-sensor/-/node-dht-sensor-0.0.2.tgz
npm ERR! Error: EACCES, mkdir '/home/pi/node_modules/node-dht-sensor'
npm ERR! { [Error: EACCES, mkdir '/home/pi/node_modules/node-dht-sensor']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/pi/node_modules/node-dht-sensor',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/pi/node_modules/node-dht-sensor',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/opt/node/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/opt/node/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.12.20+
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "node-dht-sensor"
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! path /home/pi/node_modules/node-dht-sensor
npm ERR! fstream_path /home/pi/node_modules/node-dht-sensor
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/pi/node_modules/node-dht-sensor'
npm ERR! fstream_stack /opt/node/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /opt/node/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR! { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path: 'npm-debug.log' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.12.20+
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "node-dht-sensor"
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open 'npm-debug.log'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0

DHT22 doesn't always return values...

Hi,

I've tried your node.js module and the example application on my Raspberry Pi.
It works so far, except the sensor won't return a value sometimes.

Sometimes it will work 9 out of 10 times, then it will work only once for the next 10 tries...

I already tried it with 2 different RPis, I have also tried to increase the polling time to 3000ms.

So I just wanted to ask if this is normal, or if maybe my sensor is broken.

Thanks and BR
Daniel

e.g.:

Temperature: 24.70C, humidity: 62.00%
Temperature: 24.70C, humidity: 62.10%
Temperature: 0.00C, humidity: 0.00%
Temperature: 0.00C, humidity: 0.00%
Temperature: 24.70C, humidity: 62.10%
Temperature: 24.70C, humidity: 62.10%
Temperature: 24.70C, humidity: 62.10%
Temperature: 24.70C, humidity: 62.10%
Temperature: 24.70C, humidity: 62.10%
Temperature: 24.70C, humidity: 62.20%
Temperature: 0.00C, humidity: 0.00%
Temperature: 0.00C, humidity: 0.00%
Temperature: 24.70C, humidity: 61.80%
Temperature: 24.70C, humidity: 61.70%
Temperature: 24.70C, humidity: 61.70%
Temperature: 24.80C, humidity: 61.60%
Temperature: 0.00C, humidity: 0.00%
Temperature: 24.70C, humidity: 61.50%
Temperature: 24.70C, humidity: 61.60%
Temperature: 0.00C, humidity: 0.00%
Temperature: 24.70C, humidity: 61.70%
Temperature: 24.80C, humidity: 61.80%
Temperature: 24.70C, humidity: 61.70%

Install Errors - gpy ERR!

Linux 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux
$ node --version
v5.7.0
$ npm --version
3.6.0

Output

node_dht_sensor.target.mk:88: recipe for target 'Release/obj.target/node_dht_sensor/node-dht-sensor.o' failed
make: *** [Release/obj.target/node_dht_sensor/node-dht-sensor.o] Error 1
make: Leaving directory '/home/pi/node-temperature-logger/node_modules/.staging/node-dht-sensor-07ec9ac4/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/pi/.nvm/versions/node/v5.7.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.13+
gyp ERR! command "/home/pi/.nvm/versions/node/v5.7.0/bin/node" "/home/pi/.nvm/versions/node/v5.7.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/node-temperature-logger/node_modules/.staging/node-dht-sensor-07ec9ac4
gyp ERR! node -v v5.7.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok 
[email protected] /home/pi/node-temperature-logger
└─┬ [email protected] 
  ├── [email protected] 
  └─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └── [email protected] 

npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Linux 4.1.13+
npm ERR! argv "/home/pi/.nvm/versions/node/v5.7.0/bin/node" "/home/pi/.nvm/versions/node/v5.7.0/bin/npm" "install"
npm ERR! node v5.7.0
npm ERR! npm  v3.6.0
npm ERR! code ELIFECYCLE

npm ERR! [email protected] preinstall: `./preinst`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script './preinst'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./preinst
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-dht-sensor
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/node-temperature-logger/npm-debug.log

not installing node module

reply@raspberry:~/node_modules$ sudo npm install node-dht-sensor
/

[email protected] preinstall /home/reply/node_modules/node-dht-sensor
./preinst

Library bcm2835 found.
Installing Native Abstractions for Node.js (NAN)...
npm WARN package.json [email protected] license should be a valid SPDX license expression
[email protected] node_modules/nan
Rebuiling addon...
make: Entering directory '/home/reply/node_modules/node-dht-sensor/build'
CXX(target) Release/obj.target/node_dht_sensor/node-dht-sensor.o
SOLINK_MODULE(target) Release/obj.target/node_dht_sensor.node
/usr/bin/ld: /usr/local/lib/libbcm2835.a(bcm2835.o): relocation R_ARM_THM_MOVW_ABS_NC against a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libbcm2835.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status node_dht_sensor.target.mk:115: recipe for target 'Release/obj.target/node_dht_sensor.node' failed make: *** [Release/obj.target/node_dht_sensor.node] Error 1 make: Leaving directory '/home/reply/node_modules/node-dht-sensor/build' gyp ERR! build error gyp ERR! stack Error:make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.18.7-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/reply/node_modules/node-dht-sensor
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Linux 3.18.7-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE

npm ERR! [email protected] preinstall: ./preinst
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script './preinst'.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./preinst
npm ERR! You can get their info via:
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/reply/node_modules/npm-debug.log

Raspberry Pi 2

Does this library work with the RPi2 now? The library seems to work fine on a Raspberry Pi B+, but not with the RPi 2 due to issues with the BCM library.

Thanks...

Install fails with undeclared identifier sched_setscheduler

I installed the BCM2385 library, but on npm install I get the following error

> npm install node-dht-sensor --save
> [email protected] install /Users/joscha/Development/rpi-dht22-logger/node_modules/node-dht-sensor
> node-gyp rebuild

  CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
../node-dht-sensor.cpp:180:5: error: use of undeclared identifier 'sched_setscheduler'
    sched_setscheduler(0, SCHED_FIFO, &schedp);
    ^
1 error generated.
make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1

any idea what I might be doing wrong?

install error

`root@raspberrypi:/chenney/bcm2835-1.46# sudo npm install -g node-dht-sensor
|

[email protected] preinstall /usr/local/lib/node_modules/node-dht-sensor
./preinst

Library bcm2835 found.
Installing Native Abstractions for Node.js (NAN)...
npm ERR! Linux 4.1.13-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "nan"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! path /root/.npm/nan/2.2.1/package
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/root/.npm/nan/2.2.1/package'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/root/.npm/nan/2.2.1/package']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/root/.npm/nan/2.2.1/package' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.1.13-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "nan"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ENOSPC
npm ERR! errno -28
npm ERR! syscall write

npm ERR! nospc ENOSPC: no space left on device, write
npm ERR! nospc This is most likely not a problem with npm itself
npm ERR! nospc and is related to insufficient space on your system.
npm ERR! Linux 4.1.13-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "nan"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! path npm-debug.log.4101297415
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename 'npm-debug.log.4101297415' -> 'npm-debug.log'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/lib/node_modules/node-dht-sensor/npm-debug.log
Rebuiling addon...
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.4.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/node-dht-sensor/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: ENOSPC: no space left on device, mkdir '/usr/local/lib/node_modules/node-dht-sensor/.node-gyp'
gyp ERR! stack at Error (native)
gyp ERR! System Linux 4.1.13-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/node-dht-sensor
gyp ERR! node -v v4.4.3
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 4.1.13-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "node-dht-sensor"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] preinstall: ./preinst
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script './preinst'.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./preinst
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-dht-sensor
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /chenney/bcm2835-1.46/npm-debug.log`

Script output 0 temp 0 hum

Sensor AM2301 (DHT21). By datasheet - timings identical to dht22 sensor, packet structure too.
Raspberry Pi with 26 pin header. OS raspbian.

With logic analyzer i get this signal. Its ok, but after CRC byte - there are three more bytes with zero.
aaazzz

Init OK.
But script shows temperature 0 and pressure 0.

Improve documentation

While trying this package, I struggled with two things:

  • The documentation states that the package works with "DHT11, DHT22 and AM2302 sensors". However, it is not completely clear that for the AM2302 sensor also 22 should be used;
  • The pin number is not the physical pin but the BCM pin. While writing this it makes a bit more sense as the BCM2835 library is used. However, I was unable to get readings while I thought I was sure about the pin number provided. Clearly I was not.

Would be good if these things are described in a better way. Other than that, perfect!

Can't install

/
> [email protected] install /home/fiws/test/node_modules/node-dht-sensor
> ./check-bcm2835

Library bcm2835 found.
make: Entering directory '/home/fiws/test/node_modules/node-dht-sensor/build'
  CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
  SOLINK_MODULE(target) Release/obj.target/node-dht-sensor.node
/usr/bin/ld: /usr/local/lib/libbcm2835.a(bcm2835.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libbcm2835.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
node-dht-sensor.target.mk:110: recipe for target 'Release/obj.target/node-dht-sensor.node' failed
make: *** [Release/obj.target/node-dht-sensor.node] Error 1
make: Leaving directory '/home/fiws/test/node_modules/node-dht-sensor/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/fiws/npm/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 4.1.6-1-ARCH
gyp ERR! command "node" "/home/fiws/npm/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/fiws/test/node_modules/node-dht-sensor
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Linux 4.1.6-1-ARCH
npm ERR! argv "node" "/home/fiws/npm/bin/npm" "install" "node-dht-sensor"
npm ERR! node v0.12.7
npm ERR! npm  v2.13.0
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `./check-bcm2835`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script './check-bcm2835'.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./check-bcm2835
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/fiws/test/npm-debug.log

I've tested with bcm2835 version 1.45, 1.44 and 1.5. All fail, but 1.5 has a different error.

Install on BBB: No such file on install

I'm running the latest debian image for the BeagleBoneBlack.

nodejs version: 0.10.25
user: root

When I attempt to install, there's an issue with bcm2835.h not being found.

Am I missing a step or anything obvious here?

# npm install node-dht-sensor
npm http GET https://registry.npmjs.org/node-dht-sensor
npm http 304 https://registry.npmjs.org/node-dht-sensor

> [email protected] install /var/lib/cloud9/extras/ttest/node_modules/node-dht-sensor
> node-gyp rebuild

make: Entering directory `/var/lib/cloud9/extras/ttest/node_modules/node-dht-sensor/build'
  CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
../node-dht-sensor.cpp:21:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.

make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1
make: Leaving directory `/var/lib/cloud9/extras/ttest/node_modules/node-dht-sensor/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.8.13-bone50
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /var/lib/cloud9/extras/ttest/node_modules/node-dht-sensor
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! not ok code 0

Cannot install version 0.0.25 or 0.0.26 on jessie 4.4.22 - needs c++ 2011 support ?

I am able to install version 0.0.24 OK, but not 0.0.25 or 0.0.26 - I get the following fatal error when using npm install [email protected]

CXX(target) Release/obj.target/node_dht_sensor/node-dht-sensor.o
In file included from /usr/include/c++/4.9/mutex:35:0,
from ../node-dht sensor.cpp:4:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

I am attempting this on a Pi3 with Raspbian Jessie 4.4.22

Failed to initialize sensor

Hi folks,
I use that module but unfortunately after a couple of hours I get following error:
bcm2835_init: st mmap failed: Cannot allocate memory
Failed to initialize sensor

The module is used as in your example:

var sensorLib = require('node-dht-sensor');
var wpi = require('wiring-pi');

var sensor = {
initialize: function (pin) {
if (!global.SensorInitialize) {
return sensorLib.initialize(22, pin);
global.SensorInitialize = true;
}
},
read: function (pin, result) {
var readout = sensorLib.read();
//console.log("Pin = " + pin)
var Temp = readout.temperature * 0.972;
var loTemp = Temp.toFixed(2);
var loHumi = readout.humidity.toFixed(2);
//console.log("loTemp: " + loTemp + " loHumi: " + loHumi)
console.log("Pin = " + pin + " Temp: " + loTemp + " Humi: " + loHumi);
return { "Pin": pin,
"temp": loTemp,
"humi": loHumi
};
}
};
exports.sensor = sensor;


And it is called in an endless interval loop:

setInterval(function () {
var sql = "SELECT * FROM DeviceList WHERE DeviceType LIKE 'Sensor'"
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'database'
});
connection.query(sql, function (err, rows, fields) {
if (err) throw err;
var loGPIO;
var currVal
for (var i in rows) {
loGPIO = rows[i]["GPIO"];
if (readSensor.sensor.initialize(loGPIO)) {
currSensor[i] = new readSensor.sensor.read(loGPIO);
} else {
console.warn('Failed to initialize sensor');
}
}
for (var i in rows) {
currVal = currSensor[i];
if ((currVal.temp < 20 || currVal.temp > 40) && (currVal.humi < 20 || currVal.humi > 100)) {
var d = new Date();
console.log("Fehler beim Lesen des Sensors " + loGPIO + " " + d)
} else {
updateDeviceStatus(rows[i]["DeviceID"], currVal.temp, currVal.humi);
}
}
});
connection.end();
}, 5000);


Is there a possibility do execute something to delete the allocated memory via node.js?

Incorrect Temp and Humidity values

Hi thanks for this module!

However I do get strange temp and humidity values:

info  DH11        →  Temperature: 588.80C, humidity: 870.40% 

When I breath very close to the sensor the humidity increases to over 1400% and temp around 716.80C.
Do you know what went wrong?

Some images on google showed a resistor had to be placed in between pin 1 and 2 (4k7). I did this and also removed it but the values seemed to stay the same so it didn't appear to have any effect.

Do you know what's wrong?

Thanks in advance!

Ohh and also I had to sudo apt-get install automake on my RaspberryPiB+ and mkdir m4 inside the bcm2835-1.42 folder to get the make command working. It's a clean install of raspbian 2015-02-16 so maybe add it to the readme? Some users might benifit from it :)

Compatibility with RasPi 2?

Hi,

did anyone try this on the RasPi 2 already?

I've setup a fresh system, but it will just freeze/hang when running the sample app.
Only connectin via putty will make it respond again, ctrl+c won't do anything, ctrl-alt-del will restart.
When I put the SD card in my RasPi B+ model it will work normally.

BR
Daniel

Not getting readings

Having read previous issues (most helpful was AuspXeu's post about node-gyp required to be installed) and spending a lot of time on this, I seem to have hit a brick wall!

Output of ./check-bcm2835:
gyp info ok response.

However, sudo node test.js:
Temperature: 0.0C, humidity: 0.0%, valid: true, errors: 1
Temperature: 0.0C, humidity: 0.0%, valid: true, errors: 0
Temperature: 0.0C, humidity: 0.0%, valid: true, errors: 0
Temperature: 0.0C, humidity: 0.0%, valid: true, errors: 0
etc

I know the Sensor is working (AM2302) as running a Python script gives me:

$ sudo ./AdafruitDHT.py 2302 4
Temp=22.8* Humidity=57.6%

Node.js version: v0.12.6
NPM version: 2.11.2
bcm2835 Library version is 1.46
Pi Version: 2
Raspian: (Jessie)
node-dat-sensor: 0.0.8

I'm not a noob to Linux, but I am not that much of a whizz either, so could be missing something obvious here, but what?

TIA,

Julian

Cannot install

Hi There

I'm having troubles installing your package. See code below. I have installed the required library, but not sure if it's in the correct directory. Does this matter? Any other hints?

Raphael

\

[email protected] install /home/pi/www/node_modules/node-dht-sensor
node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.33"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/pi/www/node_modules/node-dht-sensor/.node-gyp"
make: Entering directory '/home/pi/www/node_modules/node-dht-sensor/build'
CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
../node-dht-sensor.cpp: In function 'long int readDHT(int, int, float&, float&)':
../node-dht-sensor.cpp:75:22: error: 'bcm2835_delay' was not declared in this scope
../node-dht-sensor.cpp:92:36: error: 'bcm2835_delayMicroseconds' was not declared in this scope
node-dht-sensor.target.mk:80: recipe for target 'Release/obj.target/node-dht-sensor/node-dht-sensor.o' failed
make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1
make: Leaving directory '/home/pi/www/node_modules/node-dht-sensor/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.12.28+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/www/node_modules/node-dht-sensor
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.12.28+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! cwd /home/pi/www
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

Cannot install

I have installed libcm 1.39
Am i Installing it wrong? Please Help

npm WARN engine [email protected]: wanted: {"node":">=0.12 <0.13"} (current:{"node":"0.10.36","npm":"1.4.28"}

 >[email protected] install /home/pi/Desktop/node-red-0.10.1/node_modules/node-dht-sensor
 >node-gyp rebuild

make: Entering directory '/home/pi/Desktop/node-red-0.10.1/node_modules/node-dht-sensor/build'
  CXX(target) Release/obj.target/node-dht-sensor/node-dht-sensor.o
../node-dht-sensor.cpp:205:17: error: ‘FunctionCallbackInfo’ does not name a type
../node-dht-sensor.cpp:205:17: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
../node-dht-sensor.cpp:205:37: error: expected ‘,’ or ‘...’ before ‘<’ token
../node-dht-sensor.cpp: In function ‘void Read(int)’:
../node-dht-sensor.cpp:207:30: error: no matching function for call to ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
../node-dht-sensor.cpp:207:30: note: candidates are:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note: v8::HandleScope::HandleScope(const v8::HandleScope&)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note:   no known conversion for argument 1 from ‘v8::Isolate*’ to ‘const v8::HandleScope&’
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note: v8::HandleScope::HandleScope()
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note:   candidate expects 0 arguments, 1 provided
../node-dht-sensor.cpp:217:48: error: no matching function for call to ‘v8::Object::New(v8::Isolate*&)’
../node-dht-sensor.cpp:217:48: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1728:33: note: static v8::Local<v8::Object> v8::Object::New()
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1728:33: note:   candidate expects 0 arguments, 1 provided
../node-dht-sensor.cpp:218:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:218:89: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, float&)’
../node-dht-sensor.cpp:218:89: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:219:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:219:95: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, float&)’
../node-dht-sensor.cpp:219:95: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:220:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:220:92: error: no matching function for call to ‘v8::Boolean::New(v8::Isolate*&, bool)’
../node-dht-sensor.cpp:220:92: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(bool)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:221:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:221:88: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, int)’
../node-dht-sensor.cpp:221:88: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:223:5: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp: At global scope:
../node-dht-sensor.cpp:226:21: error: ‘FunctionCallbackInfo’ does not name a type
../node-dht-sensor.cpp:226:21: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
../node-dht-sensor.cpp:226:41: error: expected ‘,’ or ‘...’ before ‘<’ token
../node-dht-sensor.cpp: In function ‘void ReadSpec(int)’:
../node-dht-sensor.cpp:228:30: error: no matching function for call to ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
../node-dht-sensor.cpp:228:30: note: candidates are:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note: v8::HandleScope::HandleScope(const v8::HandleScope&)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note:   no known conversion for argument 1 from ‘v8::Isolate*’ to ‘const v8::HandleScope&’
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note: v8::HandleScope::HandleScope()
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note:   candidate expects 0 arguments, 1 provided
../node-dht-sensor.cpp:230:9: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp:231:15: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:232:10: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:236:22: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp:238:18: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:239:10: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:246:19: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:247:11: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:261:48: error: no matching function for call to ‘v8::Object::New(v8::Isolate*&)’
../node-dht-sensor.cpp:261:48: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1728:33: note: static v8::Local<v8::Object> v8::Object::New()
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1728:33: note:   candidate expects 0 arguments, 1 provided
../node-dht-sensor.cpp:262:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:262:89: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, float&)’
../node-dht-sensor.cpp:262:89: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:263:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:263:95: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, float&)’
../node-dht-sensor.cpp:263:95: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:264:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:264:92: error: no matching function for call to ‘v8::Boolean::New(v8::Isolate*&, bool)’
../node-dht-sensor.cpp:264:92: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(bool)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp:265:18: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:265:88: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, int)’
../node-dht-sensor.cpp:265:88: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp: At global scope:
../node-dht-sensor.cpp:270:23: error: ‘FunctionCallbackInfo’ does not name a type
../node-dht-sensor.cpp:270:23: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
../node-dht-sensor.cpp:270:43: error: expected ‘,’ or ‘...’ before ‘<’ token
../node-dht-sensor.cpp: In function ‘void Initialize(int)’:
../node-dht-sensor.cpp:272:30: error: no matching function for call to ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
../node-dht-sensor.cpp:272:30: note: candidates are:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note: v8::HandleScope::HandleScope(const v8::HandleScope&)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note:   no known conversion for argument 1 from ‘v8::Isolate*’ to ‘const v8::HandleScope&’
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note: v8::HandleScope::HandleScope()
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note:   candidate expects 0 arguments, 1 provided
../node-dht-sensor.cpp:274:9: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp:275:18: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:276:10: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:280:10: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp:281:18: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:282:10: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:286:22: error: ‘args’ was not declared in this scope
../node-dht-sensor.cpp:288:15: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
../node-dht-sensor.cpp:289:10: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
../node-dht-sensor.cpp:298:70: error: no matching function for call to ‘v8::Boolean::New(v8::Isolate*&, bool)’
../node-dht-sensor.cpp:298:70: note: candidate is:
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note: static v8::Handle<v8::Boolean> v8::Boolean::New(bool)
/home/pi/.node-gyp/0.10.36/deps/v8/include/v8.h:4364:17: note:   candidate expects 1 argument, 2 provided
../node-dht-sensor.cpp: In function ‘void Init(v8::Handle<v8::Object>)’:
../node-dht-sensor.cpp:314:40: error: no matching function for call to ‘SetMethod(v8::Handle<v8::Object>&, const char [5], void (&)(int))’
../node-dht-sensor.cpp:314:40: note: candidate is:
/home/pi/.node-gyp/0.10.36/src/node.h:112:6: note: template<class target_t> void node::SetMethod(target_t, const char*, v8::InvocationCallback)
../node-dht-sensor.cpp:315:48: error: no matching function for call to ‘SetMethod(v8::Handle<v8::Object>&, const char [9], void (&)(int))’
../node-dht-sensor.cpp:315:48: note: candidate is:
/home/pi/.node-gyp/0.10.36/src/node.h:112:6: note: template<class target_t> void node::SetMethod(target_t, const char*, v8::InvocationCallback)
../node-dht-sensor.cpp:316:52: error: no matching function for call to ‘SetMethod(v8::Handle<v8::Object>&, const char [11], void (&)(int))’
../node-dht-sensor.cpp:316:52: note: candidate is:
/home/pi/.node-gyp/0.10.36/src/node.h:112:6: note: template<class target_t> void node::SetMethod(target_t, const char*, v8::InvocationCallback)
node-dht-sensor.target.mk:80: recipe for target 'Release/obj.target/node-dht-sensor/node-dht-sensor.o' failed
make: *** [Release/obj.target/node-dht-sensor/node-dht-sensor.o] Error 1
make: Leaving directory '/home/pi/Desktop/node-red-0.10.1/node_modules/node-dht-sensor/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Linux 3.18.7+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/Desktop/node-red-0.10.1/node_modules/node-dht-sensor
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-dht-sensor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-dht-sensor
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.18.7+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-dht-sensor"
npm ERR! cwd /home/pi/Desktop/node-red-0.10.1
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0)```

Read once, then stop

David,
Sorry, one more question, but is there a way you can show me of stopping the test.js or test-spec.js from running after providing the readings? I just want to take a reading, and then the script to stop running (either on success or error)...

TIA,

Jamms

node-gyp required

I had to manually install node-gyp via npm install node-gyp -g in order to make it install this module on my raspberry pi. Maybe you should include this in your installation instructions.

Cheers

Raspberry Pi 1 Model B

I have a number of pis all over, and I found the following so I wanted it to be documented somewhere. The following worked for me.

Raspberry Pi 1 Model B
Raspbian "Wheezy"
bcm2835-1.42
Node v0.10.17
[email protected]

I found I had to downgrade bcm2835 (latest was 1.48, downgraded to 1.42), and node (latest was 4.3.7, downgraded to apt packaged v0.10.17), and consequently node-dht-sensor (0.0.6 works with node < v0.12).

Raspberry Pi 2 Model B
Raspbian "Jessie"
bcm2835-1.48
Node v4.3.7
[email protected]

One caveat not mentioned in most install guides, is that I did a modprobe w1-gpio and modprobe w1-therm on both systems.

issue : ACTION Regenerating Makefile

make: Warning: File '../binding.gyp' has modification time 6157163 s in the future
ACTION Regenerating Makefile
make: Warning: File '../binding.gyp' has modification time 6157163 s in the future
ACTION Regenerating Makefile

This is happening When I do "npm install node-dht-sensor",
This is not stoping at any point,It's infinite loop.

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.