0

I am using the gpiozero and pigpio libraries to create a remote gpio control application in python. The pigpio documentation advertises this as a feature, so I know it's possible. Here is the problem with this example code:

import gpiozero as zero
import pigpio as io
testrun = io.pi("greenhousedatalogger")
led = zero.LED(26)
led.blink()

Yes, I have made sure the pigpio daemon is started on the pi. here are the error codes. I'm not sure if I need to provide them all, but I dont know what is necessarily critical to solve this problem.:


Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)

venv\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi' warnings.warn(

venv\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio' warnings.warn(

\venv\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from rpio: No module named 'RPIO' warnings.warn(

\venv\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from pigpio: failed to connect to localhost:8888 warnings.warn(

\venv\lib\site-packages\gpiozero\devices.py:288: PinFactoryFallback: Falling back from native [Errno 2] No such file or directory: '/proc/cpuinfo' warnings.warn(

Traceback (most recent call last):
\PycharmProjects\pigpio test\main.py", line 5, in <module> led = zero.LED(26)

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\devices.py", line 108, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\output_devices.py", line 200, in __init__ super(DigitalOutputDevice, self).__init__(

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\output_devices.py", line 83, in __init__ super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\mixins.py", line 85, in __init__ 
super(SourceMixin, self).__init__(*args, **kwargs)

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\devices.py", line 540, in __init__
    super(GPIODevice, self).__init__(**kwargs)

\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\devices.py", line 250, in __init__
    Device.pin_factory = Device._default_pin_factory()
\PycharmProjects\pigpio test\venv\lib\site-packages\gpiozero\devices.py", line 291, in _default_pin_factory raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!

Can't connect to pigpio at localhost(8888)

Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)

Process finished with exit code 1

I've read that this has to do with some environment variables somewhere, but I've found no good sources for how to change them and get it to work. How do I change the right system variables and get my raspberry pi's hostname to be usable to other devices on a network?

  • Please click `edit` under your question and format code and error messages correctly by selecting it with the mouse and clicking `{}` in the Formatting Toolbar beside **Bold** and *Italics*. Thank you. – Mark Setchell Jan 06 '22 at 08:42
  • Ok. this is my first post. i'll get on that. – RandomLonelyDev Jan 06 '22 at 14:07
  • Are you running this on a RasPi and connecting to another RasPi? Or running on a Linux PC and connecting to a RasPi? – Mark Setchell Jan 06 '22 at 15:46
  • You can set the hostname of the remote RasPi by logging into it and running `sudo raspi-config`. If it is set to `greenhousedatalogger`, then you should be able to go to your local machine where Python is running and do `ping greenhousedatalogger.local` and if that works, use `testrun = io.pi("greenhousedatalogger.local")` in your Python. – Mark Setchell Jan 06 '22 at 15:49
  • Did you run `sudo raspi-config` and goto `3) Interface Options` and then run `P8 Remote GPIO` ? – Mark Setchell Jan 11 '22 at 17:04
  • Yea. Thanks, I got it working. – RandomLonelyDev Jan 14 '22 at 21:27

0 Answers0