Coding – Raspberry Pi

One of the first issues when using the Pi, which  I intend to use with Python for projects using the GPIO pins, is to decide whether to use the standard RPi.GPIO library or the newer, more user friendly GPIO Zero, which has been written as a “language wrapper” and removes some of the complexity. Both control how the Pi’s GPIO pins are designated and used in various circuits. Having recently gotten a Freenove starter kit for Pi, the documentation comes with code examples written in both C, which I’m not interested in learning right now, and two versions of Python, one of them focusing on Zero, and the other in regular GPIO, the circuitry and components being identical in both cases.

I notice immediately that the Zero code tends to be more concise and easier to follow. The Zero libraries force the use of the Broadcom numbering system (BCM) for the IO pins, and makes the assigning of pins and designating them as input or output simpler. It allows you to import specific libraries for all common components you’d normally use, so for example you don’t need to manually designate the pin connecting to a LED as an output like you would in GPIO, since it will always be an output. Also you don’t need to manually tell the Pi to set the pin on a button to use a pull up mode, Zero’s designated button library takes care of it automatically. So Zero takes away some of the repetitive busy work you need to do in GPIO. I do wonder though if there might be more value in sticking with he standard GPIO, as it might give a slightly deeper understanding of what is happening with the board and its pins. Also, what if at some point I decide to use some component for which a specific Zero library hasn’t yet been written, and have become too used to the training wheels always being there?

I think for now I will stick with learning using the Zero Library, and when i get more familiar with the various circuits can always go back and dig deeper into the GPIO coding.

Artist, exhibition maker and educator based in Cork, Ireland