ryck / MMM-DHT-Sensor

Magic Mirror 2 module to get data form DHT11, DHT22 and AM2302 sensors
MIT License
17 stars 8 forks source link

MMM-DHT-Sensor

This a module for the MagicMirror.

This module gets data form DHT11, DHT22 and AM2302 sensors.

bcm2835

This module uses node-dht-sensor to get the sensor data, and this module depends on bcm2835 to do so, therefore you need to install it in your Pi in order to use this module.

cd ~
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.52.tar.gz
tar zxvf bcm2835-1.52.tar.gz
cd bcm2835-1.52
./configure
make
sudo make check
sudo make install

Installation

git clone https://github.com/ryck/MMM-DHT-Sensor.git
cd MMM-DHT-Sensor
npm install

Config

The entry in config.js can include the following options:

Option Description
sensorPin Required This is the GPIO pin the sensor is connected to. Note: This is not the hardware pin number.

Type: integer
sensorType Required This is the the sensor type. It should work for DHT11, DHT22 and AM2302 sensors

Type: integer
Possible values: 11 for DHT11 or 22 for DHT22 / AM2302
units What units to use. Specified by config.js

Type: string
Possible values: config.units = Specified by config.js, metric = Celsius, imperial =Fahrenheit
Default value: config.units
updateInterval How often the sendor data is updated.

Type: integer
Default value: 1 hour
relativeScale Relative scale to choose the temparature icon.

Type: integer
Default value: 30
initialLoadDelay The initial delay before loading. If you have multiple modules that use the same API key, you might want to delay one of the requests. (Milliseconds)

Type: integer
Possible values: 1000 - 5000
Default value: 0
animationSpeed Speed of the update animation. (Milliseconds)

Type: integer
Possible values:0 - 5000
Default value: 1000 (1 second)
debug Show debug information.

Possible values: true or false
Default value: false

Here is an example of an entry in config.js

{
    module: "MMM-DHT-Sensor",
    position: "top_right",
    header: "Upstairs",
    config: {
        sensorPin: 2,
        sensorType: 22,
        updateInterval: 60 * 60 * 1000,
        initialLoadDelay: 0,
        animationSpeed: 1000,
        units: "metric",
        relativeScale: 35,
        debug: false
    }
},

Notes

Notifications

This module implements the following notifications:

Dependencies

Issues

WARNING! Could not load config file. Starting with default configuration. Error found: Error: The module '/home/pi/MagicMirror/modules/MMM-DHT-Sensor/node_modules/node-dht-sensor/build/Release/node_dht_sensor.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 53. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).

If you get this error after installing the module (or your MagicMirror is just a black screen) try this:

cd MMM-DHT-Sensor
npm run rebuild

Thanks To...