I2c configuration or integration

A few weeks ago I started with Home Assistant installed on a Raspberry pi 3 and one of the problems I ran into was configuring or installing “i2c” to be able to use certain sensors that require it.
In particular, I am using ESPhome to take data from a WEMOS D1 Mini with a BMP180 sensor that measures temperature and atmospheric pressure.

Mainly use this guide to install i2c for Home Assistant Enable i2c on the Home Assistant Operating System

But then I did not know how to add it to the code to be able to use it for ESP and I searched the blogs a lot without positive results until luckily I found a single example of the code and it worked perfectly.

You only need to add this to your ESP code (ESPHome), change PINs if its necessary.

i2c:
sda: D2
scl: D1
scan: false

I leave you the example of how it is used by me sensorxxx.yalm:

esphome:
  name: temp_exterior
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "yourssid"
  password: "password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Temp Exterior Fallback Hotspot"
    password: "password"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

i2c:
  sda: D2
  scl: D1
  scan: false

sensor:
  - platform: bmp085
    temperature:
      name: "Temp Exterior"
    pressure:
      name: "Presion Exterior"
    update_interval: 60s

I hope it works for you
And thanks to @exxamalte for corrections

2 Likes

That guide explains how to enable I2C on a Raspberry Pi, not an ESP.

Those are the default pins for I2C on a Wemos D1 Mini, so it’s not necessary to define them here.

1 Like

Yes you are right! Thanks

1 Like