Announcement: New Raspberry Pi interface - RpiGpio

3 views
Skip to first unread message

George Farris

unread,
Feb 12, 2018, 5:08:35 PM2/12/18
to pytomation
Greetings all,

Note this pertains to the Python3 branch at this point.

I am announcing a new Raspberry Pi interface today. It's called
RpiGpio. The interface supports both INPUTS and OUTPUTS with various
options. I've tried to cover all the types of I/O options that will
make this useful and easy to use.

There are two ways of numbering the IO pins on a Raspberry Pi. The
first is using the BOARD numbering system which equates to the physical
pin numbers on the P1 header of the Raspberry Pi.

The second is using the BCM numbering systems which equates to the
Broadcom chip GPIO numbering scheme.

The advantage of using the BOARD numbering system is that your hardware
will always work, regardless of the board revision of the RPi. You will
not need to rewire your connector or change your code. I have, however,
noticed that many projects seem to use the BCM scheme.

You may choose either one.

GPIO pins on the 40 pin header are as follows:
3V3 (1) (2) 5V
GPIO2 (3) (4) 5V
GPIO3 (5) (6) GND
GPIO4 (7) (8) GPIO14
GND (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND
GPIO22 (15) (16) GPIO23
3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND
GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8
GND (25) (26) GPIO7
GPIO0 (27) (28) GPIO1
GPIO5 (29) (30) GND
GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
GND (39) (40) GPIO21


In your instance file you can setup the interface and pins as follows:


# Pytomation running on this raspberry pi with pin layout of type BCM
rpi = RpiGpio(pin_layout='BCM', address=None, port=None, poll=None)
# pin_layout can be BCM or BOARD

# Address , port and poll time are not used yet, this interface only
# supports Pytomation running locally on the RPi.

# Set the I/O points as INPUTS or OUTPUTS with optional debounce in
# milliseconds, invert for INPUTS and initial state for OUTPUTS
#
# These examples use type BOARD pins

# Set pin 3, GPIO-2 as INPUT with pullup resister, inverted state and
# 100ms debounce.
rpi.setPin(3, 'IN', 'PULL_UP', invert=True ,debounce=100)

# Set pin 5, GPIO-3 as INPUT with pulldown resister and 200ms debounce
rpi.setPin(5, 'IN', 'PULL_DOWN', debounce=200)

# Set pin 7, GPIO-4 as OUTPUT, with initial value set to LOW state
rpi.setPin(7, 'OUT') or rpi.setPin(7, 'OUT', init='LOW')

# Set pin 7, GPIO-4 as OUTPUT, with initial value set to HIGH state
rpi.setPin(7, 'OUT', init='HIGH')

Please note that INVERT on an input is particularly useful when an
input is pulled high and the pin must be grounded to operate. INVERT
does not change the value of the pin, just the ON state within
Pytomation.


Using the pins in the instance file:

This is used just like any other Pytomation interface. Example:

#Inputs
m_room_motion = Motion(address=17,
devices=rpi,
name="Room motion detectormytest")
# Outputs
l_room_lamp = Light(address=26,
devices=(rpi),
name='Room Lamp')

Enjoy, please submit bugs and or requests here.

Cheers
George

David

unread,
Feb 18, 2018, 6:24:32 PM2/18/18
to pytomation
This is awesome!
Are you planning on adding a remote option. I was never really clear on how that worked in the first place. I assume a separate script was run on the pi, but I never saw that script.

George Farris

unread,
Feb 18, 2018, 10:27:13 PM2/18/18
to pytom...@googlegroups.com
Thanks David,

I do have a remote option almost complete.

It is a server process that runs in Pytomation and each remote Pi will
be a client that will connect. In fact the client side could be
something other than a Pi by modifying the client python file which is
small and easy to understand with almost no configuration options on
the client side.

Running things this way makes it so one can just power up a client at
any time and not have to restart Pytomation. The link works either
plain or encrypted with a cert/key pair and a shared secret. Most of
the documentation for it is also written.

Cheers
George
Reply all
Reply to author
Forward
0 new messages