This document outlines the C functionality within the XS file that the Perl module uses as its backend. It is a reference only, and none of the information included here is required for non-developmental use/work.
Stores the temperature and humidity float values.
typedef struct env_data { int temp; int humidity; } EnvData;
pin arguments must always be in their BCM GPIO number scheme format.
pin
BCM GPIO
int c_temp(int pin);
Called by the temp() method. Returns the temperature in Celcius.
temp()
int c_humidity(int pin);
Called by the humidity() method. Returns the humidity as an integer.
humidity()
int c_cleanup(int pin);
Called by the cleanup() method, and is always called upon DESTROY().
cleanup()
DESTROY()
EnvData read_env(int pin);
Not available to Perl.
Polls the pin in a loop until valid data is fetched, then returns an EnvData struct containing the temp and humidity float values.
EnvData
If for any reason the poll of the DHT11 sensor fails (eg: the CRC is incorrect for either temp or humidity), we will loop and block until valid data is retrieved.
bool noboard_test();
Checks whether the RDE_NOBOARD_TEST environment variable is set to a true value. Returns true if so, and false if not. This bool is used for testing purposes only.
RDE_NOBOARD_TEST
void setup();
If we're on a system that isn't a Raspberry Pi, things break. We call this in new(), and if setup checks fail, we exit (unless in RDE_NOBOARD_TEST environment variable is set to true).
new()
This function has been configured to call wiringPi's wiringPiSetupGpio() function.
wiringPi
wiringPiSetupGpio()
Called only from the new() method.
Steve Bertrand, <steveb@cpan.org<gt>
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.
To install RPi::DHT11, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPi::DHT11
CPAN shell
perl -MCPAN -e shell install RPi::DHT11
For more information on module installation, please visit the detailed CPAN module installation guide.