4

I recently started using rasperry pi. I am trying to do some home automation and controlling toy car motors. I am able to control the motors and 2 plug points.

I wanted to control more servo motors. I see, I am going to run out of GPIO pins available on raspberry pi and not sure about the load on the raspberry pi if I use all GPIO pins.

What is the better way to extend the GPIO pins?

I see some I2C extension boards, but raspberry pi has only 1 I2C port. Is it possible connect multiple boards?

Chetan Bhargava
  • 1,252
  • 3
  • 15
  • 29
venu
  • 61
  • 3

2 Answers2

2

Recent Raspberry Pi's have 21 accessible gpios, 17 on the P1 connector and 4 on the P5 connector.

As you say, you could use the I2C bus to expand the number of gpios. You can have multiple port expanders on the bus, each must have a unique address. Common I2C port expanders provide 16 additional gpios each. This example allows for eight devices to be used on the bus for a total of 128 additional gpios.

joan
  • 71,852
  • 5
  • 76
  • 108
2

You have quite a few options to expand your GPIO pins.

  1. As Joan mentioned that you can use newer version of Raspberry Pi (Model B+ or Model A+)
  2. You can definitely use I2C to expand your GPIO limit.
  3. In addition to I2C bus you can also use SPI bus (available on GPIO) port

I2C:

I2C is not limited by number of ports. I2C bus is only limited by "Bus Capacitance", max SCL frequency and a few other factors. You can connect multiple "IO Expanders" to single I2C bus. "IO Expanders" are available with different slave addresses so you can mix various types. For example TCA6424A can support 24 IOs per device and two devices can be connected on the same I2C bus to provide 48 IO lines. In addition you can use other IO expanders parts to expand your IO capability further

SPI:

In addition to I2C IO expansion, you can use simple shift registers to expand your IO capabilities. You can connect multiple shift registers (as many as your software can allow) and drive them via the SPI bus. You will only limited by your software and refresh latency. IO Expansion using SPI

Conclusion:

Finally you are only limited to the GPIOs that you can think of and the number that Pi can drive (IO latency). I believe if you exceed that number, you have better options than the Pi itself.

Chetan Bhargava
  • 1,252
  • 3
  • 15
  • 29