NAME
RPi::PIGPIO - remotely control the GPIO on a RaspberryPi using the pigpiod daemon
DESCRIPTION
This module impements a client for the pigpiod daemon, and can be used to control the GPIO on a local or remote RaspberryPi
On every RapberryPi that you want to use you must have pigpiod daemon running!
You can download pigpiod from here http://abyz.co.uk/rpi/pigpio/download.html
METHODS
connect
Connects to the pigpiod running on the given IP address/port and returns an object that will allow us to manipulate the GPIO on that Raspberry Pi
Usage:
my $pi = RPi::PIGPIO->connect('127.0.0.1');
Params:
Note: The pigiod daemon must be running on the raspi that you want to use
disconnect
Disconnect from the gpiod daemon.
The current object is no longer usable once we disconnect.
get_mode
Returns the mode of a given GPIO pin
Return values (constant exported by this module):
- 0 => PI_INPUT
- 1 => PI_OUTPUT
- 4 => PI_ALT0
- 5 => PI_ALT1
- 6 => PI_ALT2
- 7 => PI_ALT3
- 3 => PI_ALT4
- 2 => PI_ALT5
set_mode
Sets the GPIO mode
Usage:
$pi->set_mode(17, PI_OUTPUT);
Params : =over 4
- 1. gpio - GPIO for which you want to change the mode
- 2. mode - the mode that you want to set. Valid values for mode are exported as constants and are : PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, or PI_NOT_PERMITTED.
write
Sets the voltage level on a GPIO pin to HI or LOW
Note: You first must set the pin mode to PI_OUTPUT
Usage :
$pi->write(17, HI);
or
$pi->write(17, LOW);
Params:
- 1. gpio - GPIO to witch you want to write
- 2. level - The voltage level that you want to write (one of HI or LOW)
Note: This method will set the GPIO mode to "OUTPUT" and leave it like this
read
Gets the voltage level on a GPIO
Note: You first must set the pin mode to PI_INPUT
Usage :
$pi->read(17);
or
$pi->read(17);
Params:
Note: This method will set the GPIO mode to "INPUT" and leave it like this
gpio_trigger
This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
Params (in this order):
- 1. gpio - number of the GPIO pin we want to monitor
- 2. length - pulse length in microseconds
- 3. level - level to use for the trigger (HI or LOW)
Usage:
$pi->gpio_trigger(4,17,LOW);
Note: After running you call this method the GPIO is left in "INPUT" mode
Sends a command to the pigiod daemon and waits for a response
- 1. command - code of the command you want to send (see package constants)
- 2. param1 - first parameter (usualy the GPIO)
- 3. param2 - second parameter - optional - usualy the level to which to set the GPIO (HI/LOW)
send_command_on_socket
Same as send_command
but allows you to specify the socket you want to use
The pourpose of this is to allow you to use the send_command functionality on secondary connections used to monitor changes on GPIO
Params:
- 1. socket - Instance of IO::Socket::INET
- 2. command - code of the command you want to send (see package constants)
- 3. param1 - first parameter (usualy the GPIO)
- 4. param2 - second parameter - optional - usualy the level to which to set the GPIO (HI/LOW)
send_command_ext
Sends an extended command to the pigpiod daemon
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 303:
'=item' outside of any '=over'
- Around line 414:
Unknown directive: =h1
- Around line 418:
Unknown directive: =h2