diff --git a/components/binary_sensor/rc522.rst b/components/binary_sensor/rc522.rst index 0fb6438af..5c4602887 100644 --- a/components/binary_sensor/rc522.rst +++ b/components/binary_sensor/rc522.rst @@ -13,8 +13,8 @@ Component/Hub The ``rc522`` component allows you to use RC522 RFID controllers (`datasheet `__, `Ali Express `__) -with ESPHome. This component is a global hub that establishes the connection to the RC522 via :ref:`SPI ` and -outputs its data. Using the :ref:`RC522 binary sensors ` you can then +with ESPHome. This component is a global hub that establishes the connection to the RC522 via either :ref:`SPI ` or +:ref:`I²C ` and outputs its data. Using the :ref:`RC522 binary sensors ` you can then create individual binary sensors that track if an RFID tag is currently detected by the RC522. .. 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. -As the communication with the RC522 is done using SPI you need to have an :ref:`SPI bus ` in your configuration with both -the **miso_pin** and **mosi_pin** set. +The RC522 supports SPI, I²C and UART communication protocols, ESPHome can use either SPI or I²C. + +* If you have a module like the image above, it can only be used in SPI mode (`unless hacked `__) + and you need to have an :ref:`SPI bus ` 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 ` bus configured. + +SPI Option +********** .. code-block:: yaml - # Example configuration entry spi: - clk_pin: D0 - miso_pin: D1 - mosi_pin: D2 rc522_spi: - cs_pin: D3 - update_interval: 1s + cs_pin: GPIO15 + + 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: - platform: rc522 @@ -46,18 +63,31 @@ the **miso_pin** and **mosi_pin** set. Configuration variables: ************************ -- **cs_pin** (**Required**, :ref:`Pin Schema `): The pin on the ESP that the chip select line - is connected to. - **reset_pin** (*Optional*, :ref:`Pin Schema `): The pin connected to the RST line. Some tests shows the RC522 working okay without this. - **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. - 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 `): An automation to perform - when a tag is read. See :ref:`rc522-on_tag`. + 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 `): An automation to perform when a tag is read. See + :ref:`rc522-on_tag`. +- **id** (*Optional*, :ref:`config-id`): Manually specify the ID for this component. + +SPI Only: +^^^^^^^^^ + +- **cs_pin** (**Required**, :ref:`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 ` if you want 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 ` if you want + to use multiple I²C buses. + .. _rc522-on_tag: @@ -73,7 +103,7 @@ The parameter ``x`` this trigger provides is of type ``std::string`` and is the .. code-block:: yaml - rc522: + rc522_spi: # or rc522_i2c # ... on_tag: then: @@ -86,7 +116,7 @@ using :ref:`api-homeassistant_tag_scanned_action`. .. code-block:: yaml - rc522: + rc522_spi: # or rc522_i2c # ... on_tag: then: @@ -108,7 +138,7 @@ unique id (``uid``) is currently being detected by the RC522 or not. miso_pin: D1 mosi_pin: D2 - rc522_spi: + rc522_spi: # or rc522_i2c cs_pin: D3 update_interval: 1s @@ -149,5 +179,5 @@ See Also - :doc:`index` - :doc:`rdm6300` - :doc:`pn532` -- :apiref:`rc522_spi/rc522_spi.h` +- :apiref:`rc522/rc522.h` - :ghedit:`Edit`