Ben Nuttall over at Raspberry Pi has announced the release of GPIO Zero 1.5. This is a significant release and includes several enhancements.
- Improvements to the
DistanceSensor
class giving more accurate and reliable readings. - Improvements to the source/value functionality meaning you could just do:
led.source = button
to have a button activate an LED. - Improvements to the pinout command so you can pass the -x or –xyz argument to show the pinout.xyz website in your browser.
- Support for more boards, including Jam HAT, PumpkinPi, PiHutXmasTree and TonalBuzzer classes.
- Better handling of accidents.
- Support for physical pins. This is something several of us have championed for a while. It’s not perfect but it does solve the problem in terms of specifying pins for inputs and outputs. To use physical pin numbering, just use the
BOARD
prefix when defining pin usage. For example, instead ofled = LED(17)
, you would doled = LED('BOARD11')
. Note the quotes round the BOARD declaration – they’re important! There is also support for the WiringPi way of numbering – use the prefix WP.
This is very welcome, so thanks Ben and Dave for listening to the community! 🙂
You can upgrade to the latest version by putting the following commands into a Terminal on your Raspberry Pi:
sudo apt update sudo apt install python3-gpiozero python-gpiozero
If you still haven’t started to use GPIO Zero and want to see what the differences are between RPi.GPIO and this newer, easier-to-use library, take a look here.
Read the official announcement over at Raspberry Pi or delve into the ChangeLog to see all the enhancements.
Can I assume this would function on a RPi3B+? I never use the Zero at all.