ESP8266 gets reconised in HA but not the PIR, need some HELP!

Hi This is my first post on the site, I searched/looked/tried a bunch of things but none worked for me.

So… here I go.
I have the Node MCU ESP8266 (esp-12e model) and a generic PIR motion sensor with 3 pins.
I tried connecting the “data/yellow” wire to a bunch of different pins (2, 3, 13, 17) are the ones I was told to use by different posts and comments and from the ESPHome how to. nothing works…
heres the wiring:

  • red: on the 3v3
  • black: on the ground
  • yellow: on the “out” pin from the PIR and pin D7 or D3 or D4 etc…

also tried spelling in the .yaml
this is the last one i tried:
binary_sensor:

  • platform: gpio
    name: "Pin D7”
    pin: D7
    device_class: motion

I tried a bunch of variants that were all recommended by one or the other tutorials that i tried
pin: 13
pin: GPIO03
etc…

I really don’t know why its not recognizing it it’s so simple i just dont get it. please help.

Please post your code in blocks: see rule 11.

Those PIR sensors are marginal on 3.3V according to the ESPHome documentation. If you have 5V also, might be worth trying that.

When you say “not working”, do you mean the binary sensor isn’t created in HA, or that motion detection isn’t happening? You are putting the code you wrote into the ESPHome configuration YAML, and not HA’s YAML, correct?

This is my working code on a D1 Mini for two PIR sensors:

esphome:
  name: utility_motion
  platform: ESP8266
  board: d1_mini

# wifi and api sections removed

binary_sensor:
  - platform: gpio
    pin: D2
    name: "Utility room motion"
    device_class: motion

  - platform: gpio
    pin: D1
    name: "Garage motion"
    device_class: motion

On the D1 Mini, D1 is GPIO5 and D2 is GPIO4, chosen with reference to this guide: looks like they’re the same on your board.

the binary sensor isn’t created in HA… yeah!

I’ll try this later when i have two minutes.

Would be easier to diagnose if you posted your code for the device

Post the complete code from ESPHome (the *.yaml) for this node (yep, rule 11 :wink: ).

Afterwards tell us exactly how and what you wired from and to your NodeMCU. How do you power it, how do you power the PIR and so on. The more detailed the information, the faster this get’s solved. :slight_smile:

There’s nothing else on the node, only that sensor, and the only bit of code I’ve added to the yaml is the binary sensor bit:

esphome:
  name: mtn_snsr_01
  platform: ESP8266
  board: esp12e

wifi:
  ssid: "Netgear_dd"
  password: "ohnoohnoohno"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Mtn Snsr 01 Fallback Hotspot"
    password: "ohnoohnoohno"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "ohnoohnoohno"

ota:
  password: "ohnoohnoohno"

  binary_sensor:
  - platform: gpio
    name: "Pin D7”
    pin: D7
    device_class: motion

As i said in my first post:

esp8266:
red: on the 3.3v
black: on the ground
yellow: on D7

PIR:
red:on vcc
yellow: on out
black: on grnd
plugged directly in the rasbperry pi with the os on it.

esp powered by usb from the raspberry pi, so is the PIR…
(only the esp is plugged by usb to the power source)

hope you guys can help me!

thank you

no 5v on it, only 3.3v
my node MCU ESP8266 esp-12e looks different that the reference you’ve sent me heres a picture:

Your binary_sensor line should not be indented, and you have a “smart quote” in your name line, after the D7.

Vin (top left pin in pic) provides 5V from the USB (ref).

Looks pretty similar to the Joy-it ESP32 Wroom.
I wouldn’t be surprised at all if the VN in the top left provides 5V.
Not to mention that most NodeMCU board provide both on the opposite of each row of connectors. Means if one side offers 3.3V the other offers 5V

this looks odd

name: "Pin D7”
is the quotes correct

1 Like

I fixed the quotes, I am actually getting errors on =validation now, which i wasnt before… weeeeird!

see anything else?

indentation?

what is the error

I tried the VN and there was no difference at all

you mean even if its printed 3.3v it might be 5v?

anyways i tried from both sides with no difference.

I think its something else.
ill still re-try

the issue is with your code

what error do you get when validating

this:

Failed config

ota: [source /config/esphome/mtn_snsr_01.yaml:25]
  password: xxxxxxxxxx
  
  [binary_sensor] is an invalid option for [ota]. Please check the indentation.
  binary_sensor:  [source /config/esphome/mtn_snsr_01.yaml:28]
    - platform: gpio
      name: pin D7
      pin: D7
      device_class: motion

the line binary_sensor is indented wrongly, its telling u

look at the example code from @troon

Ok ill try that again once i can validate my yaml…

thank you

https://joy-it.net/de/products/SBC-NodeMCU
Sorry the pin is exactly named Vin = Voltage in
Means if you connect using the USB this serves the device with 5V.
And you’ll find this voltage on the first pin on th left side holding it upwards with the USB on the bottom.

Despite the code issues you suffer, I would wonder if you get it to work with 3.3V. Google is your friend and there’s several hints to try with 5V.

EDIT: you’ll find the pinout on the link given if you scroll down the page.

i have been googlin’ all day, tried all sides but i think the problem was actually residing in my .yaml maybe…

its weird that it was validating before…

after fixing the indentation i get those now:

INFO Reading configuration /config/esphome/mtn_snsr_01.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
  in "/config/esphome/mtn_snsr_01.yaml", line 1, column 1:
    esphome:
    ^
expected <block end>, but found '-'
  in "/config/esphome/mtn_snsr_01.yaml", line 28, column 1:
    - platform: gpio
    ^

here’s the config now:

esphome:
  name: mtn_snsr_01
  platform: ESP8266
  board: esp12e

wifi:
  ssid: "Netgear_dd"
  password: "XXXXXXXXX"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Mtn Snsr 01 Fallback Hotspot"
    password: "XXXXXXX"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "XXXXXX"

ota:
  password: "XXXXXX"

  binary_sensor:
- platform: gpio
  name: "pin D7"
  pin: D7
  device_class: motion