I use the gpiozero.MotionSensor to detect motion and upon motion to change the state of GPIO pin 17 using RPi.GPIO.
This works well.
At the end of the script I clean up using RPi.GPIO.cleanup(), but then receive an error from gpiozero (see below) when it wants to shut down MotionSensor at the end of the script.
Can I avoid this error? Or can I omit the RPi.GPIO.clean() since it is called from gpiozero?
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 595, in _shutdown
_devices_shutdown()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 588, in _devices_shutdown
dev.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 299, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 540, in close
self._pin.close()
File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 137, in close
GPIO.cleanup(self.number)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Exception ignored in: <function GPIOBase.__del__ at 0xb618fbb8>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 151, in __del__
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 299, in close
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 540, in close
File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 137, in close
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)