# Can I still use the GPIO pins when using a HAT?

**URL:** <https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761>\
**Category:** Uncategorized\
**Created:** [27 November 2022 20:36 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761 "2022-11-27T20:36:02Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin217242](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@Justin217242](https://forum.core-electronics.com.au/u/Justin217242)\
**Post date:** [27 November 2022 20:36 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/1 "2022-11-27T20:36:02Z")

</div>

Hi,

I have a project where I intend to use a [stepper motor](https://www.adafruit.com/product/324) and a [servo motor](https://www.adafruit.com/product/2307?gclid=Cj0KCQiAsoycBhC6ARIsAPPbeLvgef5F1XDzkHKGCXKxJsBWBeMJiFAl-26-WuoIT-2Wwmk63ol_Wr8aAmLLEALw_wcB). The stepper motor will be connected to the RPi using [this HAT](https://www.adafruit.com/product/2348) as shown in [this video](https://www.youtube.com/watch?v=ea6tSppgZlY&ab_channel=CoreElectronics) made by Core Electronics.

Since I’m using a HAT, will I still be able to connect the servo motor to the RPi’s GPIO pins? Or will the HAT make them inaccessible? I believe I need these [GPIO headers](https://www.adafruit.com/product/1658) (or do I need the 2x20 version?), but even with these, I want to be sure I can connect a servo to the GPIO pins while the hat is connected.

Bonus question: Will the servo motor I linked be powerful enough to pull a toilet’s lever to flush it?

If it matters: I have a RPi 3 Model B V1.2

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [27 November 2022 20:55 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/2 "2022-11-27T20:55:31Z")

</div>

Hi Justin,  
The most important factor in knowing what you can re-use pin wise while using a hat is what pins the hat uses. Once you have determined that, you can choose to use pins that the hat does not.  
That is except if the hat uses I2C, then you can use them as well as they are a bus.

If you read the description of that hat you will see that this is the case, it uses I2C so you can even use multiple hats stacked.

Yes that pin header with the long legs will let you stack the hats.

The servo linked has a torque of 3.1kg at 1cm arm length, this is a best case figure.  
It depends on you mechanism and what force the flush lever requires, I dont think that anyone can answer that question for you, you will probably have to do some testing.

---

<div class="post-metadata">

**Author:** ![Justin217242](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@Justin217242](https://forum.core-electronics.com.au/u/Justin217242)\
**Post date:** [27 November 2022 20:57 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/3 "2022-11-27T20:57:57Z")

</div>

I don’t want to stack hats. I want to use the one hat I linked and also the GPIO pins on the RPi itself. It seems possible that the hat will make the pins inaccessible. Is this true?

---

<div class="post-metadata">

**Author:** ![Jeff105671](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jeff105671/32/3729_2.png) [@Jeff105671](https://forum.core-electronics.com.au/u/Jeff105671)\
**Post date:** [27 November 2022 21:23 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/4 "2022-11-27T21:23:40Z")

</div>

> [@Justin217242](#):
>
> I don’t want to stack hats

Whether you are stacking hats or stacking individual pin connectors, the solution is the same: get the [extra long stacking headers](https://core-electronics.com.au/gpio-header-for-raspberry-pi-b-extra-long-2x20-female-header.html) when you get the hat, and use them instead of the included headers. Then plug whatever you want to use into the stacking headers in the same you would plug directly into the Pi.

---

<div class="post-metadata">

**Author:** ![Justin217242](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@Justin217242](https://forum.core-electronics.com.au/u/Justin217242)\
**Post date:** [27 November 2022 21:30 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/5 "2022-11-27T21:30:34Z")

</div>

Got it, thanks @Jeff105671. So it sounds like I can connect the stepper to the hat’s screw-down headers and the servo to the regular RPi GPIO pins, right? Thanks a ton for the help, clearly I’m very new to this.

---

<div class="post-metadata">

**Author:** ![Justin217242](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@Justin217242](https://forum.core-electronics.com.au/u/Justin217242)\
**Post date:** [27 November 2022 21:32 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/6 "2022-11-27T21:32:36Z")

</div>

I also notice that you linked the 2x20 headers, where Adafruit’s listing for the [hat](https://www.adafruit.com/product/324) says to purchase the 2x13 configuration for the RPi B (although this doesn’t make much sense to me since it has 20 pins…)

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [27 November 2022 21:40 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/7 "2022-11-27T21:40:39Z")

</div>

> [@Justin217242](#):
>
> I don’t want to stack hats. I want to use the one hat I linked and also the GPIO pins on the RPi itself. It seems possible that the hat will make the pins inaccessible. Is this true?

It’s difficult to know exactly what the ‘prototyping area’ contains, but t looks like they are all non-connected pads.  
It also looks like ALL the RPi GPIO pins are in use, making none available to use.

It also looks like that board is overkill for what you want to do, have you considered using just an individual stepper driver and interfacing directly with it and the servo?

---

<div class="post-metadata">

**Author:** ![Justin217242](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@Justin217242](https://forum.core-electronics.com.au/u/Justin217242)\
**Post date:** [27 November 2022 21:56 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/8 "2022-11-27T21:56:52Z")

</div>

Ah, if none of the GPIO pins are available after connecting the HAT, this won’t work for me. Thanks a ton for pointing that out.

Perhaps an individual driver would be better. I just need to be sure, with whatever solution I use, that I can use both a servo and stepper.

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [27 November 2022 22:03 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/9 "2022-11-27T22:03:11Z")

</div>

As I said, I am not 100% sure, the info isnt forthcoming, maybe someone from Core can validate my statement, however, if ALL you want is stepper and servo then you can easily drive the stepper from a stepper driver, it only needs a few GPIO pins (enable, direction and step) and a servo is pretty much the same, although you can drive a servo direct from the RPi using only a single pin…

---

<div class="post-metadata">

**Author:** ![Jeff105671](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jeff105671/32/3729_2.png) [@Jeff105671](https://forum.core-electronics.com.au/u/Jeff105671)\
**Post date:** [27 November 2022 22:21 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/10 "2022-11-27T22:21:15Z")

</div>

Choose 20 or 13 according to which model of Pi you have.

You can get an idea of the torque required to push the button by measuring the distance it needs to move and the weight you have to stack on it (or hang from it) in order to make it move. Torque is [force by distance](https://blog.orientalmotor.com/motor-sizing-basics-part-1-load-torque#:~:text=To%20calculate%20load%20torque%2C%20multiply,x%200.05%20m%20%3D%201%20Nm.). Using a stepper instead of a servo might be a more complex setup, but it gives you access to as much torque as needed, because you can choose a gearing arrangement that uses any amount of rotation rather than the maximum 90 degrees of a servo (and you already have a second stepper driver in that hat).

---

<div class="post-metadata">

**Author:** ![Jeff105671](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jeff105671/32/3729_2.png) [@Jeff105671](https://forum.core-electronics.com.au/u/Jeff105671)\
**Post date:** [27 November 2022 22:28 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/11 "2022-11-27T22:28:17Z")

</div>

> [@AndrewBG](#):
>
> It also looks like ALL the RPi GPIO pins are in use, making none available to use.

[According to Ada](https://pinout.xyz/pinout/dc_stepper_motor_hat) only SCL and SDA are used, plus power.

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [27 November 2022 22:45 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/12 "2022-11-27T22:45:02Z")

</div>

> [@Jeff105671](#):
>
> [According to Ada](https://pinout.xyz/pinout/dc_stepper_motor_hat) only SCL and SDA are used, plus power.

I did see that, but look at the board layout and schematic, https://learn.adafruit.com/assets/22656  
Looks pretty well loaded to me.

---

<div class="post-metadata">

**Author:** ![Jeff105671](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jeff105671/32/3729_2.png) [@Jeff105671](https://forum.core-electronics.com.au/u/Jeff105671)\
**Post date:** [27 November 2022 23:11 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/13 "2022-11-27T23:11:36Z")

</div>

> [@AndrewBG](#):
>
> Looks pretty well loaded to me

It’s fully loaded, but the only pins used for the motor driver are SCL and SDA. Everything else goes to the prototyping area.

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [27 November 2022 23:25 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/15 "2022-11-27T23:25:19Z")

</div>

> [@Jeff105671](#):
>
> Everything else goes to the prototyping area

Deleted inaccurate post, here’s the proper one 🙂

[![](https://cdn-learn.adafruit.com/assets/assets/000/022/656/original/raspberry_pi_fabprint.png?1422045810) ](https://cdn-learn.adafruit.com/assets/assets/000/022/656/original/raspberry_pi_fabprint.png?1422045810)

I see what are saying, the small proto area, I was looking at the large one.  
Interesting, maybe it would be OK in that sense, however it is still overkill for @Justin217242 as all he wants to use on it is Stepper control.  
I’d still go with a dedicated stepper board.

---

<div class="post-metadata">

**Author:** ![Jeff105671](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jeff105671/32/3729_2.png) [@Jeff105671](https://forum.core-electronics.com.au/u/Jeff105671)\
**Post date:** [28 November 2022 00:00 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/16 "2022-11-28T00:00:40Z")

</div>

> [@AndrewBG](#):
>
> I’d still go with a dedicated stepper board.

Like the [bonnet](https://core-electronics.com.au/adafruit-dc-stepper-motor-bonnet-for-raspberry-pi.html)?

That could be used with a [single-row female header](https://core-electronics.com.au/break-away-female-headers-swiss-machine-pin.html) for expansion.

---

<div class="post-metadata">

**Author:** ![AndrewBG](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrewbg/32/6326_2.png) [@AndrewBG](https://forum.core-electronics.com.au/u/AndrewBG)\
**Post date:** [28 November 2022 00:02 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/17 "2022-11-28T00:02:03Z")

</div>

> [@Jeff105671](#):
>
> Like the [bonnet](https://core-electronics.com.au/adafruit-dc-stepper-motor-bonnet-for-raspberry-pi.html)?

Nah, something dead simple like a A4988 or similar like this:

> **[DRV8834 Low-Voltage Stepper Motor Driver Carrier](https://core-electronics.com.au/drv8834-low-voltage-stepper-motor-driver-carrier.html)**
>
> This is a breakout board for TI’s DRV8834 microstepping bipolar stepper motor driver. It has a pinout and interface that are nearly identical to those of Pololu's A4988 carriers, so it can be used as a drop-in replacement for those boards in many...

---

<div class="post-metadata">

**Author:** ![Doug27394](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/doug27394/32/7961_2.png) [@Doug27394](https://forum.core-electronics.com.au/u/Doug27394)\
**Post date:** [28 November 2022 01:13 UTC](https://forum.core-electronics.com.au/t/can-i-still-use-the-gpio-pins-when-using-a-hat/15761/18 "2022-11-28T01:13:47Z")

</div>

If you want to see what pins are free I’d recommend [https://pinout.xyz/](https://pinout.xyz/) it’s a great resource.

If you want an easy way to add an extra row of pins then have a look at [Pimoroni Pico HAT Hacker | PIM300 | Core Electronics Australia](https://core-electronics.com.au/pimoroni-pico-hat-hacker.html) it’s pretty cheap and easy way
