No change. The Out signal cable is still disconnected from the GPIO on the ESP, and the PIR is powered from 5V, measuring 4.9V on the PIR pins. The out signal is still at 0
You need a pullup resistor, connect it back to the ESP and try measuring the output pin voltages again.
Then it’s 3.3V
you mean a physical pullup resistor?
No, software should do.
Didn´t I just add one?
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: true
Yes which was why I told you to:
It’s looking like a dead sensor to me.
I swapped the PIR sensor. Now it’s at 3.3V before motion, and got 1.2V when motion
I can also see the sensor switching from OFF to ON in the States view
Turn off the input pullup and see if it still works. I’ve seen some conflicting evidence for whether it is required or not.
There are also a chance that the level is floating still, not providing either 0V or 3.3V. I put a napkin on top of the PIR, and the Out signal is still at 1,27V
Yeah ok. It is needed then. Thanks.
For the record, and history for others who might have the same issue, I post the final yaml below.
My initial problem was solved after swapping the PIR component, as my first PIR appeared broken.
substitutions:
devicename: cam_garasje
friendly_name: CAM Garasje
esphome:
name: ${devicename}
platform: ESP32
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pw
logger:
api:
reboot_timeout: 0s
ota:
web_server:
port: 80
esp32_camera:
name: ${friendly_name}
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
# resolution: 800x600
resolution: 1024x768
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Oslo
# esp32_ble_tracker:
sensor:
- platform: wifi_signal
name: ${friendly_name} WiFi signal
update_interval: 30s
- platform: uptime
name: ${friendly_name} Uptime
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
# inverted: true
name: ${friendly_name} PIR Sensor
device_class: motion
id: cam_garasje_pir
on_state:
- switch.turn_on: cam_garasje_red_led
- platform: template
name: temp_motion
internal: true
lambda: 'return id(cam_garasje_pir).state;'
on_release:
- switch.turn_off: cam_garasje_red_led
switch:
- platform: restart
name: ${friendly_name} restart
id: restart_switch
- platform: gpio
pin: GPIO33
name: ${friendly_name} rød LED
id: cam_garasje_red_led
inverted: true
- platform: gpio
pin: GPIO4
name: ${friendly_name} innebygd lys
id: cam_garasje_lys
The PIR will run OK on 3.3v
I have that exact same PIR working on the Esp32 cam. Some people were having issues because of the pin number. After doing some research, I used gpio13 and has been working since.
#PIR
- platform: gpio
pin: GPIO13
name: ${devicename} PIR Sensor
device_class: motion
GPIO12 has been working in my testlab for several days now, too
I just wanted to add my findings. Have tried GPIO12 & GPIO13. Didn’t work for me. GPIO14 did. This is how my esp32 cam looks like.
binary_sensor:
- platform: gpio
pin: GPIO14
name: motion $name occupancy
device_class: motion
I’ve noticed the last two post have their substitution like this.
name: ${devicename} PIR Sensor
Any different or beneficial compared to what I use?
Also, do we need a sd card with this cam? When I got mine, I just bought a 4GB and slap it on. I am saving imgs and video to HA folder. Wondering do we really need the card? Got another esp32 cam coming and I didn’t order one this time.
Got the same issue, tried various GPIOs and 14 worked Im not sure if the others are reserved for some camera operations but 14 worked for me.
For anybody else having issues with this, I recently set one up and working just fine so thought I’d share my experience!
I followed these instructions for the hardware setup, but using ESPHome.
Hardware:
ESP 32 CAM
AM312 Motion Sensor
Resistor pack (although you only need a 1k & 10k resistor)
Transistor Pack (although you only need an 2N3904)
Single LED (if required)
“Project Box” - Optional
(connector wires & soldering iron)
From the link above, I used these schematics for the PIR and created a little ‘wiring harness’.
- GPIO4 = ESP32 Cam built in flash light
- GPIO33 = ESP32 Cam built in red LED status light
- GPIO12 = Optional LED (also connected to GND)
- GPIO13 = Motion Sensor (also connected to GND & 5v)
substitutions:
hostname: Bird Cam
esphome:
name: bird-cam
platform: ESP32
board: esp32dev
# Enable logging
logger:
# level: VERY_VERBOSE
# Enable Home Assistant API
api:
web_server:
port: 443
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: !secret fallback_wifi_ssid
password: !secret fallback_wifi_pass
captive_portal:
#Configuration
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
# Image settings
name: stream
max_framerate: 24 fps
idle_framerate: 0.2 fps
resolution: SVGA
vertical_flip: false
horizontal_mirror: false
jpeg_quality: 30
contrast: 1
brightness: 0.
saturation: 0.
esp32_camera_web_server:
- port: 8080
mode: stream
- port: 8081
mode: snapshot
output:
# Built In flashlight
- platform: gpio
pin: GPIO4
id: gpio_4
# Built in statuslight
- platform: gpio
pin:
number: GPIO33
inverted: True
id: gpio_33
## Single LED connected to GPIO12 & Ground
- platform: gpio
pin:
number: GPIO12
inverted: False
id: gpio_12
light:
# Built In flashlight
- platform: binary
output: gpio_4
name: $hostname Flash
id: flash
# Built in statuslight
- platform: binary
output: gpio_33
name: $hostname Status LED
## Single LED connected to GPIO12 & Ground
- platform: binary
output: gpio_12
id: pin12led
name: $hostname pin12 LED
sensor:
- platform: uptime
name: $hostname Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
text_sensor:
- platform: wifi_info
ip_address:
name: $hostname IP Address
icon: mdi:ip
ssid:
name: $hostname Connected SSID
icon: mdi:wifi
bssid:
name: $hostname Connected BSSID
icon: mdi:wifi
mac_address:
name: $hostname Mac Wifi Address
icon: mdi:wifi-settings
- platform: template
name: $hostname Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
- platform: version
name: $hostname ESPHome Version
binary_sensor:
- platform: status
name: $hostname Status
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLDOWN
inverted: true
name: $hostname Motion
device_class: motion
# on_press:
# then:
# - light.turn_on: pin12led
# - delay: 1s
# - light.turn_off: pin12led
button:
- platform: restart
name: RESTART $hostname
Not pretty - but does the job!
Another note to add to the above…
This only works WITH an SD card inserted (although it doesn’t do anything!)
Thank you for sharing your solution, it helped me a lot. My setup worked right away.
And sharing your YAML config has rounded out my confiuration. Thank you