DHT11 sensor reading on BeagleBone with node.js

In the previous article we read the temperature and humidity from DHT11 sensor in python

Temperature and humidity reading on Beaglebone in python

We perform now the same operation in javascript. We download the  dht module for node.js. The module is available on the website

beaglebone dht

Log on BeagleBone in ssh as debian (temppwd as password) and run

to install the module globally.

For the sensor reading create a file test.js  with the following code inside

Reading is performed running

The result in our case is the following

temperature reading node.jsThe same code can be run from Cloud9 IDE. Access the IDE on BeagleBone with the link http: //beaglebone.local:3000 and create a file named dht.js with the following code inside

The script execution gives the following result

DHT11 cloud9Here is the link to download the two sample files

Node.js sample

Cloud9 sample