-
-
25 May 2021 07:34:19 UTC
- Distribution: RPi-PIGPIO
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (70 / 0 / 2)
- Kwalitee
Bus factor: 1- 24.01% Coverage
- License: unknown
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (23.24KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Exporter
- Module::Find
- Package::Constants
- Test::More
- Time::HiRes
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
RPi::PIGPIO::Device::DHT22 - Read temperature and humidity from a DHT22 sensor
DESCRIPTION
Uses the pigpiod to read temperature and humidity from a local or remote DHT22 sensor
SYNOPSIS
use RPi::PIGPIO; use RPi::PIGPIO::Device::DHT22; my $pi = RPi::PIGPIO->connect('192.168.1.10'); my $dht22 = RPi::PIGPIO::Device::DHT22->new($pi,4); $dht22->trigger(); #trigger a read print "Temperature : ".$dht22->temperature."\n"; print "Humidity : ".$dht22->humidity."\n";
METHODS
new
Create a new object
Usage:
my $dht22 = RPi::PIGPIO::Device::DHT22->new($pi,$gpio);
Arguments:
$pi - an instance of RPi::PIGPIO
$gpio - GPIO number to which the sensor is connected
temperature
Return the last read temperature
humidity
Return the last read humidity
last_read
When was the last read done (unix timestamp)
trigger
Trigger a new read from the sensor.
Note: The read is not imediate, it's done asyncronyous. After calling trigger you shoud sleep for a second and than you should get the values received by calling temperature() and humidity() .
You should always chek the timestamp of the last read to make sure we were actually able to read the data after you called trigger()
DHT22 can freeze if you call trigger too often. Don't call it more than every 3 seconds and you should be fine
PRIVATE METHODS
receive_data
Callback method used to read and put together the data received from the sensor
reset_readings
Reset internal counters that help us put together data received from the sensor
Module Install Instructions
To install RPi::PIGPIO, copy and paste the appropriate command in to your terminal.
cpanm RPi::PIGPIO
perl -MCPAN -e shell install RPi::PIGPIO
For more information on module installation, please visit the detailed CPAN module installation guide.