2

i just knew how to control gpio from my laptop to desire raspberry pi using gpiozero. so, i following this docs on how to configure the raspberry pi and my laptop to performing remote gpio control. i started the pigpiod daemon on my raspberry pi using pigpiod -n <laptop_ip_address>, then i try to run a simple code to blink the led in pin 17 with PIGPIO_ADDR=192.168.100.2 python3 testraspi.py. nothing happen at my raspberry pi, and i get this warning in my laptop terminal

/home/farhan/.local/lib/python3.8/site-packages/gpiozero/devices.py:277: PinFactoryFallback: Falling back from rpigpio: This module can only be run on a Raspberry Pi!

does anyone has a solution ? thank you !

EDIT the ls -l result

-rw-rw-r--  1 farhan farhan   160124 Mei  3 15:23 pigpio.py
1

If you don't specify a pin factory, gpiozero will attempt to import each library it supports in turn, until it finds one that works. It attempts in this order:

  1. RPi.GPIO
  2. pigpio
  3. RPIO
  4. Native

For each failure, you'll see a PinFactoryFallback warning. So if the first 3 failed and the 4th one succeeded, you'd see 3 PinFactoryFallback warnings and then it would proceed to run your code using the 4th (native).

This is what you got:

PinFactoryFallback: Falling back from rpigpio: This module can only be run on a Raspberry Pi!

This means that it attempted to import RPi.GPIO. The import succeeded but you got RPi.GPIO's error message This module can only be run on a Raspberry Pi! This means that you have RPI.GPIO installed on your PC, which will never work. You can uninstall it. Next, gpiozero will have attempted to use pigpio, which didn't error meaning it's in use - it's presumably running your code now.

You can safely ignore the PinFactoryFallback warning but you probably want to get rid of it. You can do this by setting the GPIOZERO_PIN_FACTORY environment variable:

GPIOZERO_PIN_FACTORY=pigpio PIGPIO_ADDR=192.168.100.2 python3 testraspi.py

You ought to verify that this is working and selecting the pigpio pin factory by running the following script with the above environment variables:

from gpiozero import Device

print(Device._default_pin_factory())

If that shows something like:

<gpiozero.pins.pigpio.PiGPIOFactory object at 0x762c26b0>

Then you're good.

I'm a bit concerned about what you posted as your ls -l result. You shouldn't have pigpio.py in your local directory. Make sure you delete it and install pigpio with pip:

pip install pigpio
| improve this answer | |

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.