Raspberry Pi GPIO pir not showing up

Hi All,

I’m new to HA and the first thing i’m trying to do is to get my PIR showing up as a sensor in HA.

I’ve added the following to configuration.yaml:

binary_sensor:
  - platform: rpi_gpio
    ports:
      17: Lounge5
    pull_mode: "UP"
    bouncetime: 50
    invert_logic: true

I’ve also confirmed the pin is correct and the PIR is working by using a separate python script but i cannot see the state of the sensor showing up on the HA GUI.

Any help detecting the state of this motion sensor would be appreciated!

HI,port-GPIO

Hey,

Sorry - not sure where to put that? I can’t see it in other examples but tried the below:

binary_sensor:
   platform: rpi_gpio
   ports-GPIO:
     17: Lounge
   pull_mode: "UP"
   bouncetime: 50
   invert_logic: true

That brings up an error on the dashboard saying the config is wrong. Could you post an example of the code you think i should be using?

Can you post your yaml in code tags < / > so we can see your format?

Are you using Pin# or GPIO# for your port?

Does it show up in dev tools under the entities list?

You also don’t need pull mode or bounce time unless you are changing them. (However keeping them should not hurt). I don’t think there are quotes around the UP in pull_mode.

Are you getting errors in the dev tool logs?

Hi PtP,

Here is the code:

binary_sensor:
   platform: rpi_gpio
   ports:
     17: Lounge
   invert_logic: true

I’m using the GPIO number and no errors in the logs. Nothing showing up in the entities list either.

Here is mine…

binary_sensor:
  - platform: rpi_gpio
    ports:
      24: Garage Status
    invert_logic: True

What HA installation method did you use AIO, Hassbian, Manual?

did you add user to GPIO group?

https://home-assistant.io/getting-started/hassbian-integrations/

I add below just in case

Command below will printout GPIO pin states and pinout for you to reference.
HASS uses “BCM” for port number. so Port 17 = GPIO 0 = Physical pin 11 in example below

sudo gpio readall

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

Verify correct pin being used
you can use 3.3VDC pin to pull high or 0V pin to pull low for testing (opposite if invert_loging = true)
It may be easier to test with wire (known condition) before adding PIR

Did you verify PIR operating as expecting?

Added the user to the gpio and we have lift off!

Thank you all for your help with this!

Love the gpio readall command too.

Now to make the TV turn off when I trigger the sensor, for no other reason than I can :slight_smile: