# Raspberry PI 4 GPIO

**URL:** https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904
**Category:** General
**Created:** [1 August 2019 18:09 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904 "2019-08-01T18:09:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [1 August 2019 18:09 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/1 "2019-08-01T18:09:49Z")

</div>

Hi is there a way to access the extra GPIO 0 and 1 on the PI 4 as in the list pin 27 and 28 are not configurable as outputs?

Thanks

Rich

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [1 August 2019 18:32 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/2 "2019-08-01T18:32:20Z")

</div>

I always thought that those pins were basically not for us users as they were dedicated to talking to HATs thru i2c.

Has this changed on the Pi4?

Are you really short of two pins for your project?

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [2 August 2019 08:07 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/3 "2019-08-02T08:07:42Z")

</div>

If you really need more gpio:

> **[IO Pi Plus - 32 Channel Port Expander for the Raspberry Pi](https://www.abelectronics.co.uk/p/54/io-pi-plus)**
>
> 32 channel IO expander for the Raspberry Pi B+ computer boards

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 09:02 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/4 "2019-08-02T09:02:23Z")

</div>

Hi,  
Thanks for the replies, the reason I need 27 and 28 is I designed a PCB around the PI 4 and stupidly didn't realise that they just added those as general IO so my new board is specific to the new PI 4 and GPIO 0 and 1.

Thanks  
Rich

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 11:11 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/5 "2019-08-02T11:11:36Z")

</div>

Tried modifying the node but it doesn't work.

Even using RPi.GPIO in a simple python prog, I can't control those pins on my Pi4

Googling is getting me nowhere

Does something need configuring to enabling those pins for general use?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [2 August 2019 12:29 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/6 "2019-08-02T12:29:42Z")

</div>

The Raspberry Pi has two I2C connections at GPIO 2 and 3 (SDA and SCL) are for I2C0 (master) and physical pins 27 and 28 are I2C pins that enable the Pi to talk to compatible HAT (Hardware Attached on Top) add on boards. - [https://www.tomshardware.com/reviews/raspberry-pi-gpio-pinout,6122.html](https://www.tomshardware.com/reviews/raspberry-pi-gpio-pinout,6122.html)

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 13:24 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/7 "2019-08-02T13:24:18Z")

</div>

> [@rjandsam](#):
>
> Thanks for the replies, the reason I need 27 and 28 is I designed a PCB around the PI 4 and stupidly didn't realise that they just added those as general IO so my new board is specific to the new PI 4 and GPIO 0 and 1.

I've had a look at the RPi.GPIO source code (which is ultimately the library used by the Pi nodes) and it doesn't allow pins 27 and 28 to be used (the -1 indicates not to be used) so in-built Node-RED Pi node isn't going to work at the moment ☹

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9130071dfae5c3b2a6689b4c86f2a4e6f57eb410.png)

I'm going to see if node-red-node-pi-gpiod will work

@rjandsam Where did you see that these pins can be used for gpio purposes?

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 13:42 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/8 "2019-08-02T13:42:10Z")

</div>

Hi,  
Thanks for looking into it for me, I have found that some people have successfully used IO0 and IO1 as outputs on the PI 3 but not node-red and the IO information I referred to was from the following link.

> **[Raspberry Pi GPIO Pinout: What Each Pin Does on Pi 4, Earlier Models](https://www.tomshardware.com/reviews/raspberry-pi-gpio-pinout,6122.html)**
>
> The Raspberry Pi has 40 GPIO pins that connect to sensors, lights, motors and other devices. Here's a map and detailed explanation of what each does, including on the Pi 4.

Thanks

Rich

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 13:48 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/9 "2019-08-02T13:48:30Z")

</div>

even typing pinout in terminal shows them as GPIO.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 14:01 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/10 "2019-08-02T14:01:09Z")

</div>

That article pic is the ONLY thing I've found that shows GPIO0 and GPIO1 on those pins.

Nothing I've found in pigpio suggests that it allows them

Unfortunately I think you've jumped the gun with this one ☹

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 14:02 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/11 "2019-08-02T14:02:25Z")

</div>

> [@rjandsam](#):
>
> even typing pinout in terminal shows them as GPIO.

mm - so it does!

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 14:24 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/12 "2019-08-02T14:24:22Z")

</div>

They are available 🙂  
At least by using shell commands

`sudo echo 0 > /sys/class/gpio/export`  
followed by  
`sudo echo out > /sys/class/gpio/gpio0/direction`

sets it up to be used as an output  
then

`sudo echo 1 > /sys/class/gpio/gpio0/value`  
and  
`sudo echo 0 > /sys/class/gpio/gpio0/value`

will switch it high or low 🙂  
So, you could be able to control it using exec nodes 🙂  
(obviously not easily but at least possible)

 ![26](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/272df317682824a93c64929c183f43fc9bf34941.jpeg)

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 August 2019 14:27 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/13 "2019-08-02T14:27:49Z")

</div>

Presumably there must be a way to turn off “hat detection” otherwise that could kick in and re-take over the pins. This must be in the Raspbian OS somewhere so may not be available to beginners in an easy to use way.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 14:32 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/14 "2019-08-02T14:32:23Z")

</div>

You'd thought so - but I can't find ANYTHING, ANYWHERE about it ☹

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 14:47 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/15 "2019-08-02T14:47:47Z")

</div>

Hi,

well done I have just had a similar result as follows.

I firstly turned off i2c in raspberry pi configuration.  
then in python I did the following.

from gpiozero import LED

led=LED(0)  
led2=LED(1)  
led.on()  
led2.on()

I just don't know how to implement this in node-red.

Thanks for the great advice and pointers guys.

Rich

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 14:58 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/16 "2019-08-02T14:58:59Z")

</div>

mmm - that's interesting that it worked because I thought that gpiozero used the RPi.GPIO library to be its default pin engine

Investigating further....

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 14:59 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/17 "2019-08-02T14:59:51Z")

</div>

also works with RPi.GPIO in python.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 15:06 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/18 "2019-08-02T15:06:18Z")

</div>

Rebooting my Pi to see what is going on - I tried using it in python and it didn't work

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [2 August 2019 15:16 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/19 "2019-08-02T15:16:33Z")

</div>

OK - starting to square the circle off a little bit 🙂

If we use BOARD mode (e.g use 27) it doesn't work but BCM (eg use 0) it does

Can you confirm that this doesn't work for you?

```auto
import RPi.GPIO as GPIO
import time as time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(27, GPIO.OUT)
while True:
    GPIO.output(27, 1)
    time.sleep(1)
    GPIO.output(27,0)
    time.sleep(1)

```

If this is true, then it explains why my mod of the Pi node fails as it uses physical pin numbering

---

<div class="post-metadata">

### Author: ![rjandsam](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@rjandsam](https://discourse.nodered.org/u/rjandsam)
#### Post date: [2 August 2019 15:23 UTC](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904/20 "2019-08-02T15:23:58Z")

</div>

Yes I used the following;  
import RPi.GPIO as GPIO  
LedPin=0  
GPIO.setmode(GPIO.BCM)  
GPIO.setup(LedPin, GPIO.OUT)  
GPIO.output(LedPin, GPIO.HIGH)

Rich

[Next page](https://discourse.nodered.org/t/raspberry-pi-4-gpio/13904.md?page=2)
