esphome-docs/esphomeyaml/components/sensor/pulse_counter.rst

75 lines
2.7 KiB
ReStructuredText
Raw Normal View History

2018-06-13 22:38:49 +02:00
Pulse Counter Sensor
====================
2018-05-13 11:37:02 +02:00
2018-06-13 22:38:49 +02:00
The pulse counter sensor allows you to count the number of pulses and the frequency of a signal
on any pin.
On the ESP32, this sensor is even highly accurate because it's using the hardware `pulse counter
2018-05-13 11:37:02 +02:00
peripheral <https://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/pcnt.html>`__
on the ESP32.
2018-06-01 18:10:00 +02:00
.. figure:: images/pulse-counter.png
:align: center
:width: 80.0%
2018-05-13 11:37:02 +02:00
.. code:: yaml
# Example configuration entry
sensor:
- platform: pulse_counter
pin: 12
name: "Pulse Counter"
Configuration variables:
2018-08-24 22:44:01 +02:00
------------------------
2018-05-13 11:37:02 +02:00
2018-06-01 18:10:00 +02:00
- **pin** (**Required**, :ref:`config-pin`): The pin to count pulses on.
- **name** (**Required**, string): The name of the sensor.
- **count_mode** (*Optional*): Configure how the counter should behave
on a detected rising edge/falling edge.
2018-05-13 11:37:02 +02:00
2018-06-01 18:10:00 +02:00
- **rising_edge** (*Optional*): What to do when a rising edge is
detected. One of ``DISABLE``, ``INCREMENT`` and ``DECREMENT``.
Defaults to ``INCREMENT``.
- **falling_edge** (*Optional*): What to do when a falling edge is
detected. One of ``DISABLE``, ``INCREMENT`` and ``DECREMENT``.
Defaults to ``DISABLE``.
2018-05-13 11:37:02 +02:00
2018-10-13 21:21:33 +02:00
- **internal_filter** (*Optional*, :ref:`config-time`): If a pulse shorter than this
time is detected, its discarded and no pulse is counted. Defaults to ``13us``. On the ESP32,
this value can not be higher than ``13us``, for the ESP8266 you can use larger intervals too.
2018-06-01 18:10:00 +02:00
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``15s``.
2018-06-01 18:44:15 +02:00
See :ref:`sensor-default_filter`.
2018-06-01 18:10:00 +02:00
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>` and :ref:`MQTT Component <config-mqtt-component>`.
2018-05-13 11:37:02 +02:00
Converting units
2018-08-24 22:44:01 +02:00
----------------
2018-05-13 11:37:02 +02:00
The sensor defaults to measuring its values using a unit of measurement
2018-06-01 18:10:00 +02:00
of “pulses/min”. You can change this by using :ref:`sensor-filters`.
2018-05-13 11:37:02 +02:00
For example, if youre using the pulse counter with a photodiode to
count the light pulses on a power meter, you can do the following:
.. code:: yaml
# Example configuration entry
sensor:
- platform: pulse_counter
pin: 12
unit_of_measurement: 'kW'
name: 'Power Meter House'
filters:
- multiply: 0.06
2018-06-01 18:10:00 +02:00
See Also
2018-08-24 22:44:01 +02:00
--------
2018-06-01 18:10:00 +02:00
- :ref:`sensor-filters`
- :doc:`rotary_encoder`
- `esp-idf Pulse Counter API <https://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/pcnt.html>`__.
- :doc:`API Reference </api/sensor/pulse_counter>`
2018-06-04 08:17:22 +02:00
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/sensor/pulse_counter.rst>`__
2018-10-12 16:33:22 +02:00
.. disqus::