Show:
Extends webduino.Module

The Dht Class.

DHT is sensor for measuring temperature and humidity.

Constructor

webduino.module.Dht
(
  • board
  • pin
)

Parameters:

  • board webduino.Board

    The board that the DHT is attached to.

  • pin Integer

    The pin that the DHT is connected to.

Methods

addListener
(
  • type
  • listener
)

Add a listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

emit
(
  • type
  • object,...
)

Emit an event of certain type.

Parameters:

  • type String

    Event type.

  • [object,...] Object optional

    Event object(s).

listeners
(
  • type
)

Return the listener list bound to certain type of event.

Parameters:

  • type String

    Evnet type.

on
(
  • type
  • listener
)

Alias for EventEmitter.addListener(type, listener)

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

once
(
  • type
  • listener
)

Add a one-time listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

read
(
  • callback
  • interval
)

Start reading data from sensor.

Parameters:

  • [callback] Function optional

    reading callback.

    • data Object

      returned data from sensor, humidity and temperature will be passed into callback function as parameters.

      callback()
      

      will be transformed to

       callback({humidity: humidity, temperature: temperature})
      

      automatically.

  • interval Integer

    reading interval.

removeAllListeners
(
  • type
)

Remove all listeners of certain type.

Parameters:

  • type String

    Event type.

removeListener
(
  • type
  • listener
)

Remove a listener for certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

setMaxListeners
(
  • n
)

Set maximum number of listeners that is allow to bind on an emitter.

Parameters:

  • n Number

    Number of listeners.

stopRead ()

Stop reading value from sensor.

Attributes

humidity

Number humidity readonly

Return the humidity.

temperature

Number temperature readonly

Return the temperature.

type

String readonly

Type of the module.

Events

DhtEvent.READ

Fires when reading value.

DhtEvent.READ_ERROR

Fires when error occured while reading value.