mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-26 17:27:47 +01:00
add rc522 i2c config variant (#933)
* add i2c config variant * add i2c address
This commit is contained in:
parent
fdb7c967aa
commit
e44eb01685
@ -13,8 +13,8 @@ Component/Hub
|
|||||||
|
|
||||||
The ``rc522`` component allows you to use RC522 RFID controllers
|
The ``rc522`` component allows you to use RC522 RFID controllers
|
||||||
(`datasheet <hthttps://www.nxp.com/docs/en/data-sheet/MFRC522.pdff>`__, `Ali Express <https://es.aliexpress.com/item/1260729519.html>`__)
|
(`datasheet <hthttps://www.nxp.com/docs/en/data-sheet/MFRC522.pdff>`__, `Ali Express <https://es.aliexpress.com/item/1260729519.html>`__)
|
||||||
with ESPHome. This component is a global hub that establishes the connection to the RC522 via :ref:`SPI <spi>` and
|
with ESPHome. This component is a global hub that establishes the connection to the RC522 via either :ref:`SPI <spi>` or
|
||||||
outputs its data. Using the :ref:`RC522 binary sensors <rc522-tag>` you can then
|
:ref:`I²C <i2c>` and outputs its data. Using the :ref:`RC522 binary sensors <rc522-tag>` you can then
|
||||||
create individual binary sensors that track if an RFID tag is currently detected by the RC522.
|
create individual binary sensors that track if an RFID tag is currently detected by the RC522.
|
||||||
|
|
||||||
.. figure:: images/rc522-full.jpg
|
.. figure:: images/rc522-full.jpg
|
||||||
@ -23,20 +23,37 @@ create individual binary sensors that track if an RFID tag is currently detected
|
|||||||
|
|
||||||
See :ref:`rc522-setting_up_tags` for information on how to setup individual binary sensors for this component.
|
See :ref:`rc522-setting_up_tags` for information on how to setup individual binary sensors for this component.
|
||||||
|
|
||||||
As the communication with the RC522 is done using SPI you need to have an :ref:`SPI bus <spi>` in your configuration with both
|
The RC522 supports SPI, I²C and UART communication protocols, ESPHome can use either SPI or I²C.
|
||||||
the **miso_pin** and **mosi_pin** set.
|
|
||||||
|
* If you have a module like the image above, it can only be used in SPI mode (`unless hacked <https://forum.arduino.cc/index.php?topic=442750.0>`__)
|
||||||
|
and you need to have an :ref:`SPI bus <spi>` in your configuration with both the **miso_pin** and **mosi_pin** set.
|
||||||
|
|
||||||
|
* If you have a RC522 which communicates via I²C like in the M5 Stack then you need to have an :ref:`I²C <i2c>` bus configured.
|
||||||
|
|
||||||
|
SPI Option
|
||||||
|
**********
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
# Example configuration entry
|
|
||||||
spi:
|
spi:
|
||||||
clk_pin: D0
|
|
||||||
miso_pin: D1
|
|
||||||
mosi_pin: D2
|
|
||||||
|
|
||||||
rc522_spi:
|
rc522_spi:
|
||||||
cs_pin: D3
|
cs_pin: GPIO15
|
||||||
update_interval: 1s
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: rc522
|
||||||
|
uid: 74-10-37-94
|
||||||
|
name: "RC522 RFID Tag"
|
||||||
|
|
||||||
|
I²C Option
|
||||||
|
**********
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
i2c:
|
||||||
|
|
||||||
|
rc522_i2c:
|
||||||
|
cs_pin: GPIO2
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: rc522
|
- platform: rc522
|
||||||
@ -46,18 +63,31 @@ the **miso_pin** and **mosi_pin** set.
|
|||||||
Configuration variables:
|
Configuration variables:
|
||||||
************************
|
************************
|
||||||
|
|
||||||
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin on the ESP that the chip select line
|
|
||||||
is connected to.
|
|
||||||
- **reset_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The pin connected to the RST line. Some tests
|
- **reset_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The pin connected to the RST line. Some tests
|
||||||
shows the RC522 working okay without this.
|
shows the RC522 working okay without this.
|
||||||
- **update_interval** (*Optional*, :ref:`config-time`): The duration of each scan on the RC522. This affects the
|
- **update_interval** (*Optional*, :ref:`config-time`): The duration of each scan on the RC522. This affects the
|
||||||
duration that the individual binary sensors stay active when they're found.
|
duration that the individual binary sensors stay active when they're found.
|
||||||
If a device is not found within this time window, it will be marked as not present. Defaults to 1s.
|
If a device is not found within this time window, it will be marked as not present. Defaults to ``1s``.
|
||||||
- **on_tag** (*Optional*, :ref:`Automation <automation>`): An automation to perform
|
- **on_tag** (*Optional*, :ref:`Automation <automation>`): An automation to perform when a tag is read. See
|
||||||
when a tag is read. See :ref:`rc522-on_tag`.
|
:ref:`rc522-on_tag`.
|
||||||
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID for this component.
|
||||||
|
|
||||||
|
SPI Only:
|
||||||
|
^^^^^^^^^
|
||||||
|
|
||||||
|
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin on the ESP that the chip select line
|
||||||
|
is connected to.
|
||||||
- **spi_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`SPI Component <spi>` if you want
|
- **spi_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`SPI Component <spi>` if you want
|
||||||
to use multiple SPI buses.
|
to use multiple SPI buses.
|
||||||
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID for this component.
|
|
||||||
|
|
||||||
|
I²C Only:
|
||||||
|
^^^^^^^^^
|
||||||
|
|
||||||
|
- **address** (*Optional*, int): Manually specify the I²C address of the sensor. Defaults to ``0x28``.
|
||||||
|
- **i2c_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`I²C Component <i2c>` if you want
|
||||||
|
to use multiple I²C buses.
|
||||||
|
|
||||||
|
|
||||||
.. _rc522-on_tag:
|
.. _rc522-on_tag:
|
||||||
|
|
||||||
@ -73,7 +103,7 @@ The parameter ``x`` this trigger provides is of type ``std::string`` and is the
|
|||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
rc522:
|
rc522_spi: # or rc522_i2c
|
||||||
# ...
|
# ...
|
||||||
on_tag:
|
on_tag:
|
||||||
then:
|
then:
|
||||||
@ -86,7 +116,7 @@ using :ref:`api-homeassistant_tag_scanned_action`.
|
|||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
rc522:
|
rc522_spi: # or rc522_i2c
|
||||||
# ...
|
# ...
|
||||||
on_tag:
|
on_tag:
|
||||||
then:
|
then:
|
||||||
@ -108,7 +138,7 @@ unique id (``uid``) is currently being detected by the RC522 or not.
|
|||||||
miso_pin: D1
|
miso_pin: D1
|
||||||
mosi_pin: D2
|
mosi_pin: D2
|
||||||
|
|
||||||
rc522_spi:
|
rc522_spi: # or rc522_i2c
|
||||||
cs_pin: D3
|
cs_pin: D3
|
||||||
update_interval: 1s
|
update_interval: 1s
|
||||||
|
|
||||||
@ -149,5 +179,5 @@ See Also
|
|||||||
- :doc:`index`
|
- :doc:`index`
|
||||||
- :doc:`rdm6300`
|
- :doc:`rdm6300`
|
||||||
- :doc:`pn532`
|
- :doc:`pn532`
|
||||||
- :apiref:`rc522_spi/rc522_spi.h`
|
- :apiref:`rc522/rc522.h`
|
||||||
- :ghedit:`Edit`
|
- :ghedit:`Edit`
|
||||||
|
Loading…
Reference in New Issue
Block a user