This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

dht-sensor-domapic-module

1.1.1 • Public • Published

DHT Sensor Domapic Module

Domapic module for handling a DHT sensor in a Raspberry Pi

Build status Coverage Status Quality Gate js-standard-style

NPM dependencies Last commit Last release

NPM downloads License


Intro

This package starts a Domapic Module that handles a DHT sensor, providing information about current temperature and relative humidity.

DHT sensor connection schema

It can be used alone, but also can be connected to a Domapic Controller to get the most out of it.

Installation

This module depends on the BCM2835 library that must be installed on your board before you can actually use this module. It should work for DHT11, DHT22 and AM2302 sensors.

npm i dht-sensor-domapic-module -g

This module uses the node-dht-sensor package to handle sensors, please refer to its documentation if you have any problem during installation.

Usage

dht-sensor start --gpio=2

The module will be started in background using pm2.

To display logs, type:

dht-sensor logs #--lines=300 

Options

The module, apart of all common domapic services options, provides custom options for configuring the sensor:

  • sensorType - <number> Define the type of connected sensor. Valid values are 11 (DHT11 sensor), and 22 (DHT22 or AM2302 sensors). Default is 11
  • interval - <number> Interval in miliseconds for refreshing sensor values. Default is 30000.
  • eventsStep - <number> Minimum values variation for triggering an event. When variation relative to last sensor value is upper than this, the module will trigger an event notifying about the temperature or humidity change to Domapic Controller.
  • gpio - <number> Gpio number where the sensor is connected.

Connection with Domapic Controller

Connect the module with a Domapic Controller providing the Controller url and connection token (you'll find it the Controller logs when it is started):

dht-sensor start --controller=http://192.168.1.110:3000 --controllerApiKey=fo--controller-api-key  --save

Now, the module can be controlled through the Controller interface, or installed plugins.

Stand alone usage

Domapic modules are intended to be used through Domapic Controller, but can be used as an stand-alone service as well. Follow next instructions to use the built-in api by your own:

Rest API

When the server is started, you can browse to the provided Swagger interface to get all the info about the api resources. Apart of all api methods common to all Domapic Services the module provides two Domapic Abilities for getting the current status of temperature and humidity, which generates two extra API resources:

  • /api/abilities/temperature/state - Returns the current temperature.
  • /api/abilities/humidity/state - Returns the current relative humidity.

Authentication

The server includes the Domapic Services authentication method, which is disabled by default for 127.0.0.1. You can disable the authentication using the --authDisabled option (not recommended if your server is being exposed to the Internet). Read more about available options in the domapic services documentation.

If you want to authenticate when requesting from another IPs, look for the api key automatically generated and intended to be used by Domapic Controller when the server is started. You'll find it in the server logs:

-----------------------------------------------------------------
Try adding connection from Controller, using the next service Api Key: HMl6GHWr7foowxM40CB6tQPuXt3zc7zE
-----------------------------------------------------------------

To make your own requests to the api, provide this token using the X-Api-Key header.

Use the mentioned api key also for authenticating when using the Swagger interface.

Alternative command line methods

Not global installation

If the package is not installed globally, you can replace the dht-sensor command in examples above by npm run dht-sensor -- (commands must be executed inside the package folder in that case)

Not background mode

If you don't want to use the built-in background runner, you can start the server directly, attaching logs to current stdout. Move to the package folder and replace the dht-sensor command of examples above by node server.js. Press CTRL+C to stop the server.

Package Sidebar

Install

npm i dht-sensor-domapic-module

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

16.8 kB

Total Files

12

Last publish

Collaborators

  • javierbrea