0

I'm tring to build Home automation app, and I try to find ( unsuccessfully ) any code/ documentation for controling GPIO's of other RPI's, using Python.

Any leads ?

| improve this question | | | | |
3

pigpio allows for the control of multiple Pi's GPIO from one or more Pis.

Your Python program must import pigpio and create one or more instances of the pigpio.pi class. This class gives access to a specified Pi's GPIO.

Example

pi1 = pigpio.pi()       # pi1 accesses the local Pi's GPIO
pi2 = pigpio.pi('tom')  # pi2 accesses tom's GPIO
pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO

pi1.write(4, 0) # set local Pi's GPIO 4 low
pi2.write(4, 1) # set tom's GPIO 4 to high
pi3.read(4)     # get level of dick's GPIO 4
| improve this answer | | | | |
  • is 'tom' and 'dick' RPI's hostnames ? can it be replaced with IP ? – Guy . D Jul 24 '17 at 9:04
  • 1
    Yes, 'tom' and 'dick' are host names and may be replaced by a dotted IP address, e.g. '192.168.1.24' (still need the quotes). – joan Jul 24 '17 at 10:33
  • i get an error "ImportError: No module named 'gpiozero.pins.pigpio'" what is needed to install this module ? – Guy . D Jul 24 '17 at 14:07
  • 1
    Try the command man pigpio. If that works it means pigpio is installed. If not, for Raspbian, use sudo apt-get install pigpio python-pigpio python3-pigpio. For other distributions use the instructions at abyz.co.uk/rpi/pigpio/download.html. – joan Jul 24 '17 at 15:10
  • correct me if i'm wrong- but your answer and steve's are different, since yours uses pigpio module and steve's answer uses from gpiozero.pins.pigpiod import PiGPIOPin and need to run a daemon pigpiod. if so - what is the difference ? – Guy . D Jul 26 '17 at 7:48
1

As @Steve Robillard commented- the answer is found in: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=160310

or more specific answer( from his link ) http://bennuttall.com/whats-new-gpio-zero-v1-3/

| improve this answer | | | | |
  • gpiozero implements the remote host as a wrapper around pigpio. gpiozero provides similar wrappers (without the remote host ability currently) around most of the Python GPIO libraries and offers an extensive suite of worked solutions. – joan Jul 24 '17 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.