NAME

RPi::DHT11 - Fetch the temperature/humidity from the DHT11 hygrometer sensor on Raspberry Pi

SYNOPSIS

use RPi::DHT11;

my $pin = 26;

my $env = RPi::DHT11->new($pin);

my $temp     = $env->temp;
my $humidity = $env->humidity;

DESCRIPTION

This module is an interface to the DHT11 temperature/humidity sensor when connected to a Raspberry Pi's GPIO pins.

Due to the near-realtime access requirements of reading the input pin of the sensor, the core of this module is written in XS (C).

This module requires the wiringPi library to be installed, and uses WiringPi's GPIO pin numbering scheme (see gpio readall at the command line).

METHODS

new($pin)

Parameters:

$pin

Mandatory. Pin number for the DHT11 sensor's DATA pin (values are 0-40).

temp($f)

Fetches the current temperature (in Celcius).

Returns an integer of the temperature, in celcius by default.

Parameters:

$f

Send in the string char 'f' to receive the temp in Farenheit.

humidity

Fetches the current humidity.

Returns the humidity as either an integer of the current humidity level.

cleanup

Returns the pin back to default state if it's not already. Called automatically by DESTROY().

ENVIRONMENT VARIABLES

There are a couple of env vars to help prototype and run unit tests when not on a RPi board.

RDE_HAS_BOARD

Set to 1 to tell the unit test runner that we're on a Pi.

RDE_NOBOARD_TEST

Set to 1 to tell the system we're not on a Pi. Most methods/functions will return default (ie. non-live) data when in this mode.

SEE ALSO

- wiringPi

AUTHOR

Steve Bertrand, <steveb@cpan.org<gt>

LICENSE AND COPYRIGHT

Copyright 2016 Steve Bertrand.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.