Raspberry Pi GPIO Support for Automate¶
Introduction¶
This extension provides interface to Raspberry Pi GPIO via RPIO library. RPIO library.
Example application¶
This simple example application sets up simple relation between input pin button
in port 22 and
output pin light
in port 23. If for a button is attached in button
, pushing it down
will light the led, that is attached to light
.
from automate import *
from automate.extensions.rpio import RpioSensor, RpioActuator
class MySystem(System):
button = RpioSensor(port=22, button_type='down')
light = RpioActuator(port=23, change_delay=2)
myprog = Program(active_condition=Value('mysensor'),
on_activate=SetStatus('myactuator', True))
mysystem = MySystem()
Class definitions¶
Service¶
-
class
automate.extensions.rpio.
RpioService
[source]¶ Service that provides interface to Raspberry Pi GPIO via RPIO library.
-
gpio_cleanup
= None¶ Perform GPIO cleanup when exiting (default: False).
-
rpio
= None¶ Use RPIO instead of RPI.GPIO
-
Sensors¶
-
class
automate.extensions.rpio.
RpioSensor
(*args, **kwargs)[source]¶ Boolean-valued sensor object that reads Raspberry Pi GPIO input pins.
-
port
= None¶ GPIO port
-
inverted
= None¶ Set to True to have inversed status value
Button setup: “down”: pushdown resistor, “up”: pushup resistor, or “none”: no resistor set up.
-
-
class
automate.extensions.rpio.
RpioSensor
(*args, **kwargs)[source] Boolean-valued sensor object that reads Raspberry Pi GPIO input pins.
-
port
= None GPIO port
-
inverted
= None Set to True to have inversed status value
-
button_type
= None Button setup: “down”: pushdown resistor, “up”: pushup resistor, or “none”: no resistor set up.
-
Actuators¶
-
class
automate.extensions.rpio.
RpioActuator
(*args, **kwargs)[source]¶ Boolean-valued actuator for setting Raspberry Pi GPIO port statuses (on/off).
-
port
= None¶ GPIO port id
-
inverted
= None¶ Set to True to have inversed status value
-
-
class
automate.extensions.rpio.
TemperatureSensor
(*args, **kwargs)[source]¶ W1 interface (on Raspberry Pi board) that polls polling temperature. (kernel modules w1-gpio and w1-therm required). Not using RPIO, but placed this here, since this is also Raspberry Pi related sensor.
-
addr
= None¶ Address of W1 temperature sensor (something like
"28-00000558263c"
), see what you have in/sys/bus/w1/devices/
-
max_jump
= None¶ Maximum jump in temperature, between measurements. These temperature sensors tend to give sometimes erroneous results.
-
max_errors
= None¶ Maximum number of erroneous measurements, until value is really set
-
-
class
automate.extensions.rpio.
RpioPWMActuator
(*args, **kwargs)[source]¶ Actuator to control PWM (pulse-width-modulation) ports on Raspberry pi GPIO.
Status range 0...1
This is not recommended to be used because RPIO PWM implementation is not very well behaving. I recommend to use ArduinoPWMActuator with an Arduino loaded with StandardFirmata. It’s much more stable and robust solution.
-
port
= None¶ GPIO port number
-
dma_channel
= None¶ RPIO PWM DMA channel
-
frequency
= None¶ PWM frequency (Hz)
-