esphome-docs/cookbook/pir.rst

67 lines
2.3 KiB
ReStructuredText
Raw Normal View History

2018-06-01 18:10:00 +02:00
Passive Infrared Sensor
=======================
2018-11-14 22:12:27 +01:00
.. seo::
2019-02-16 23:25:23 +01:00
:description: Instructions for setting up PIR (passive infrared) motion detection sensors in ESPHome
2018-11-14 22:12:27 +01:00
:image: pir.jpg
:keywords: PIR
2018-06-01 18:10:00 +02:00
.. figure:: images/pir-header.jpg
:align: center
:width: 75.0%
Passive Infrared Sensors (or PIR sensors for short) are completely supported by
2019-02-16 23:25:23 +01:00
ESPHome. These sensors measure the infrared light emitted from objects in its
2018-06-01 18:10:00 +02:00
field of view, and if it detects a sudden change between different parts of the
sensing area, the signal is pulled high.
.. figure:: images/pir-inside.jpg
:align: center
:width: 60.0%
Connecting the PIR sensor is also quite simple. You need to connect ``GND`` to a GND pin
on your board and ``VCC`` to a ``5V`` or ``12V`` pin. Technically you can also connect
``VCC`` to ``3.3V``, but the sensor measurements won't be as stable.
Next you need to connect the signal pin (``OUT``). Fortunately, the sensor signal has
a voltage of ``3.3V`` max, so we can directly connect it to a free GPIO pin on the ESP board.
Otherwise, we would need to step down the voltage in order to not damage the ESP.
.. figure:: images/pir-pins.jpg
:align: center
:width: 75.0%
.. warning::
Some PIR sensors have the GND and power supply pins swapped, please open the front
cover to see which pin mapping your PIR sensor is using to make sure.
On the back side you will additionally find two knobs that you can turn to change the sensor
sensitivity and time the signal will stay active for once motion has been detected. Turning
these clockwise will increase sensitivity/re-trigger time.
2019-02-16 23:25:23 +01:00
To configure ESPHome for use with the PIR sensor, use a
:doc:`GPIO Binary Sensor </components/binary_sensor/gpio>`. It can detect
2018-06-01 18:10:00 +02:00
if a pin is pulled HIGH/LOW and reports those values to Home Assistant. Optionally also
set a ``device_class`` so that Home Assistant uses a nice icon for the binary sensor.
.. code-block:: yaml
2018-06-01 18:10:00 +02:00
binary_sensor:
- platform: gpio
pin: <PIN_PIR_SENSOR_IS_CONNECTED_TO>
name: "PIR Sensor"
device_class: motion
.. figure:: images/pir-ui.png
:align: center
:width: 60.0%
See Also
2018-08-24 22:44:01 +02:00
--------
2018-06-01 18:10:00 +02:00
- `Awesome article explaining how PIR Sensors work <https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work>`__.
- :doc:`/components/binary_sensor/gpio`
2018-06-01 18:10:00 +02:00
- :doc:`bruh`
- :ghedit:`Edit`