DID YOU understand THAT THE RASPBERRY PI 4 has much more SPI, I2C, UART PORTS?

We’ve gotten utilized to the GPIO-available functions of Raspberry Pi computers staying mostly the exact same over the years, which is why it may have flown a bit bit under the radar: the Raspberry Pi 4 has six SPI controllers, six I2C controllers, as well as six UARTs – all on its 40-pin header. You can’t make utilize of all of these at once, however with as much as four different connections wired to a single pin you can carve out a quite powerful combination of peripherals for your next robotics, automation or feline herding project.

The datasheet for these peripherals is enjoyable to go through, with all the register maps well laid out – even if you don’t plan to work with the register mappings yourself, the maintainers of your favored hardware enablement libraries will have an simpler time! And, of course, these peripherals are present on the Compute Module 4, too. It may feel like such a deluge of interfaces is excessive, however, it lets you accomplish some quite awesome stuff that wouldn’t be possible otherwise.

Having several I2C interfaces assists offer with different I2C-specific problems, such as address conflicts, throughput issues, as well as mixing gadgets that support different maximum speeds, which implies you no longer requirement elegant mux chips to run five low-resolution Melexis thermal video camera sensors at once. (Oh, as well as the I2C clock stretching bug has been fixed!) SPI interfaces are utilized for gadgets with high bandwidth, as well as with a few separate SPI ports, you might run several fairly high-resolution screens at once, No-Nixie Nixie clock style.

As for UARTs, the Raspberry Pi’s one-and-a-half UART interface has long been an problem in robotics as well as house automation applications. With a slew of gadgets like radio receivers/transmitters, LIDARs as well as durable RS485 multi-drop interfaces offered in UART form, it’s good that you no longer have to sacrifice Bluetooth or a debug console to get some elegant sensors wired as much as your robot’s brain. You can allow as much as six UARTs.

How To utilize These Interfaces?

Enabling these interfaces seems to be straightforward, as well as people on Raspberry Pi forums as well as other locations have been test-driving them for their own endeavors. All three type of interfaces can be enabled utilizing dtoverlay lines in config.txt. For SPI, the [MaSt] blog helpfully offers some examples:

# enabling SPI6 with two CS pins – one on GPIO16 as well as other on GPIO26
dtoverlay=spi6-2cs,cs0_pin=16,cs1_pin=26

For I2C as well as UART, Raspberry Pi forum threads offered a few examples. I2C example:

# enabling I2C3, with SDA on GPIO4 as well as SCL on GPIO5
dtoverlay=i2c3,pins_4_5

UART example:

# enabling UART, with RTS as well as CTS pins (omit the ‘ctsrts’ part to disable them)
dtoverlay=uart3,ctsrts

From here, these interfaces will appear as you’d expect them, as /dev/spi6, /dev/i2c-3 as well as /dev/ttyAMA* respectively. (The serial ports don’t have aliases yet, so you’ll get one much more /dev/ttyAMA port added to existing ones.)

We were amazed to discover about these new peripherals, as well as perhaps you were too? We can’t wait to see what you’ll finish with them.

Main picture remixed from Raspberry Pi 4 GPIO pinout diagram by [Les Pounder].

Leave a Reply

Your email address will not be published. Required fields are marked *