esphome-docs/esphomeyaml/components/i2c.rst
2018-05-14 21:15:49 +02:00

104 lines
4.1 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

I²C Bus
=======
This component sets up the i²c bus for your ESP32 or ESP8266. Its used
for several other components:
======================= ======================= =======================
|PCA9685 PWM|_ |ADS1115|_ |BMP085|_
----------------------- ----------------------- -----------------------
`PCA9685 PWM`_ `ADS1115`_ `BMP085`_
----------------------- ----------------------- -----------------------
|HDC1080|_ |HTU21D|_ |MPU6050|_
----------------------- ----------------------- -----------------------
`HDC1080`_ `HTU21D`_ `MPU6050`_
----------------------- ----------------------- -----------------------
|BH1750|_ |BME280|_ |BME680|_
----------------------- ----------------------- -----------------------
`BH1750`_ `BME280`_ `BME680`_
----------------------- ----------------------- -----------------------
|TSL2561|_ |SHT3X-D|_
----------------------- ----------------------- -----------------------
`TSL2561`_ `SHT3X-D`_
======================= ======================= =======================
.. |PCA9685 PWM| image:: /esphomeyaml/pca9685.jpg
:class: component-image
.. _PCA9685 PWM: /esphomeyaml/components/output/pca9685.html
.. |ADS1115| image:: /esphomeyaml/ads1115.jpg
:class: component-image
.. _ADS1115: /esphomeyaml/components/sensor/ads1115.html
.. |BMP085| image:: /esphomeyaml/bmp180.jpg
:class: component-image
.. _BMP085: /esphomeyaml/components/sensor/bmp085.html
.. |HDC1080| image:: /esphomeyaml/HDC1080.jpg
:class: component-image
.. _HDC1080: /esphomeyaml/components/sensor/hdc1080.html
.. |HTU21D| image:: /esphomeyaml/htu21d.jpg
:class: component-image
.. _HTU21D: /esphomeyaml/components/sensor/htu21d.html
.. |MPU6050| image:: /esphomeyaml/mpu6050.jpg
:class: component-image
.. _MPU6050: /esphomeyaml/components/sensor/mpu6050.html
.. |BH1750| image:: /esphomeyaml/bh1750.jpg
:class: component-image
.. _BH1750: /esphomeyaml/components/sensor/bh1750.html
.. |BME280| image:: /esphomeyaml/bme280.jpg
:class: component-image
.. _BME280: /esphomeyaml/components/sensor/bme280.html
.. |BME680| image:: /esphomeyaml/bme680.jpg
:class: component-image
.. _BME680: /esphomeyaml/components/sensor/bme680.html
.. |TSL2561| image:: /esphomeyaml/tsl2561.jpg
:class: component-image
.. _TSL2561: /esphomeyaml/components/sensor/tsl2561.html
.. |SHT3X-D| image:: /esphomeyaml/sht3xd.jpg
:class: component-image
.. _SHT3X-D: /esphomeyaml/components/sensor/sht3xd.html
In order for those components to work correctly, you need to define the
i²c bus in your configuration.
.. code:: yaml
# Example configuration entry
i2c:
sda: 21
scl: 22
scan: False
Configuration variables:
~~~~~~~~~~~~~~~~~~~~~~~~
- **sda** (*Optional*, `pin </esphomeyaml/configuration-types.html#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).
- **sdc** (*Optional*, `pin </esphomeyaml/configuration-types.html#pin>`__): The pin for the clock line of the i²c bus.
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”.
- **receive_timeout** (*Optional*, `time </esphomeyaml/configuration-types.html#time>`__): Advanced: Set a timeout
for operations on the i2c bus. Defaults to 100ms.
.. note::
If you're using the ESP32 and i2c frequently is showing errors in the logs, try with the latest
version of the Arduino framework. See
`using the latest arduino framework version </esphomeyaml/components/esphomeyaml.html#using-the-latest-arduino-framework-version>`__
for information on how to do this.