We'll get into the specific differences between I2C, SPI and UART below, but if you're wondering which one you need to use to connect to given device, the short answer is to check the spec sheet. To use these pins with these protocols we need to enable the interfaces using the Raspberry Pi Configuration application found in the Raspbian OS, Preferences menu.
For example GPIO3 and GPIO 4 are also SDA and SCL I2C pins used to connect devices using the I2C protocol. So for example GPIO17 is the same as BCM17.Ĭertain GPIO pins also have alternate functions that allow them to interface with different kinds of devices that use the I2C, SPI or UART protocols. Also note that BCM and GPIO pin numbering refer to the same scheme. So it is best practice to start using and learning the BCM pin numbering scheme as it will become second nature to you over time. You will see the majority of Raspberry Pi tutorials using this reference and that is because it is the officially supported pin numbering scheme from the Raspberry Pi Foundation. In essence we have direct links to the brain of our Pi to connect sensors and components for use in our projects. The BCM pin mapping refers to the GPIO pins that have been directly connected to the System on a Chip (SoC) of the Raspberry Pi. With GPIO17, 22 and 27 following on from each other with little thought to logical numbering. Physical pin numbering is the most basic way to locate a pin, but many of the tutorials written for the Raspberry Pi follow a different numbering sequence.īroadcom (BCM) pin numbering (aka GPIO pin numbering) seems to be chaotic to the average user. And for the column starting with pin 2 it will go 4,6,8 etc until it reaches 40. You will quickly see that each pin from 1 to 39 in this column follows an odd number sequence. The pin numbers then increase as we move down each column, with pin 1 going to pin 3, 5,7 etc until we reach pin 39. To the right of that pin is physical pin 2 which provides 5v power. Starting at the top left of the GPIO, and by that we mean the pin nearest to where the micro SD card is inserted, we have physical pin 1 which provides 3v3 power. GPIO pins have multiple names the first most obvious reference is their “physical” location on the GPIO. Both of these libraries come pre-installed with the Raspbian operating system.
In more recent times a new library called GPIO Zero ()has been introduced, offering an easier entry for those new to Python and basic electronics. The most common library is RPi.GPIO () and it has been used to create thousands of projects since the early days of the Raspberry Pi. Controlling a GPIO pin with Python is accomplished by first importing a library of pre-written code.