Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Last active June 20, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennuttall/28d7540f372d1eacf2c9671ed2131f11 to your computer and use it in GitHub Desktop.
Save bennuttall/28d7540f372d1eacf2c9671ed2131f11 to your computer and use it in GitHub Desktop.

We're looking for testers for some changes to the remote pins feature of gpiozero. If you can help, follow the following steps and let us know of any issues you have.

Installation

Install the latest unreleased version of gpiozero in a virtual environment on a PC or on a Pi:

sudo apt-get install build-essential python-dev python3-dev python-virtualenv python3-virtualenv -y
git clone https://github.com/rpi-distro/python-gpiozero
virtualenv -p python3 gpiozero-env
source gpiozero-env/bin/activate
cd python-gpiozero
python setup.py develop
pip install pigpio

Now whenever you're in this virtual environment, the gpiozero you're using is the latest from GitHub and you'll be using the pigpio library as the back-end.

If you're on a Pi, you can use it like normal (note that python is Python 3 inside the virtual environment):

$ python
>>> from gpiozero import LED
>>> led = LED(17)
>>> led.blink()

This simple example is just using an LED on pin 17 of your own Pi, but using the pigpio library to control it.

To use remote pins, for example from a PC controlling another Pi's GPIO pins, start the pigoio daemon on the Pi:

sudo pigpiod

(you don't need the latest gpiozero on the remote Pi - just a fairly recent Raspbian Jessie image <6 months old, with pigpio installed)

Also look up the Pi's IP address:

$ hostname -I
192.168.1.4

Then on the PC with the latest gpiozero, open the Python shell with an environment variable setting the IP address of the Pi:

$ PIGPIO_ADDR=192.168.1.4 python
>>> from gpiozero import LED
>>> led = LED(17)
>>> led.blink()

Now the LED connected to pin 17 of the remote Pi will blink.

What really needs testing is SPI devices using remote pins:

$ PIGPIO_ADDR=192.168.1.4 python
>>> from gpiozero import MCP3008, PWMLED
>>> pot = MCP3008(0)
>>> led = PWMLED(17)
>>> led.source = pot.values
>>> while True:
....    print(pot.value)

Now turn the dial and the LED brightness should change in real time. You should also see the pot's value 0-1 on the screen in real time. See how effective this is.

virtualenv

Your system installed pip packages will not be available in the virtualenv - you'll have to install anything you need with pip install - without sudo - within the virtual environment.

To exit the virtual environment, simply close the terminal window, or press Ctrl + D to drop out of the SSH session

To re-enter the virtual environment, simply re-enter source gpiozero-env/bin/activate from where you cloned the gpiozero repo.

Feedback

Please let us know any feedback on this GitHub issue: gpiozero/gpiozero#468

Alternatively email ben@raspberrypi.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment