esphome-docs/esphomeyaml/components/i2c.rst

40 lines
1.4 KiB
ReStructuredText
Raw Normal View History

2018-06-01 18:10:00 +02:00
.. _i2c:
2018-05-13 11:37:02 +02:00
I²C Bus
=======
2018-06-01 18:10:00 +02:00
This component sets up the i²c bus for your ESP32 or ESP8266. In order for those components
to work correctly, you need to define the i²c bus in your configuration.
2018-05-13 11:37:02 +02:00
.. code:: yaml
# Example configuration entry
i2c:
sda: 21
scl: 22
scan: False
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
- **sda** (*Optional*, :ref:`config-pin`): The pin for the data line of the i²c bus.
Defaults to the default of your board (usually GPIO21 for ESP32 and GPIO4 for ESP8266).
2018-06-06 08:11:30 +02:00
- **scl** (*Optional*, :ref:`config-pin`): The pin for the clock line of the i²c bus.
2018-06-01 18:10:00 +02:00
Defaults to the default of your board (usually GPIO22 for ESP32 and
GPIO5 for ESP8266).
- **scan** (*Optional*, boolean): If esphomelib should do a search of the i2c address space on startup.
Note that this can slow down startup and is only recommended for when setting up new sensors. Defaults to
``False``.
- **frequency** (*Optional*, float): Set the frequency the i²c bus should operate on. Defaults to “100kHz”.
2018-05-14 21:15:49 +02:00
.. note::
If you're using the ESP32 and i2c frequently is showing errors in the logs, try with the latest
2018-09-23 19:00:31 +02:00
version of the Arduino framework. See :ref:`esphomeyaml-arduino_version` for information on how to do this.
2018-06-01 18:10:00 +02:00
See Also
--------
- :doc:`API Reference </api/core/i2c>`
2018-06-04 08:17:22 +02:00
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/i2c.rst>`__