ESP32 - dallas_temp and bme280_i2c can't work together

I want to have 2x DS18B20 (the waterproof version) and one BME280 (via i2c) sensors connected.

When I have only the DS18B20 connected they work fine. They are recognized and they report temperature as expected.
But whenever I add config section for i2c and bme280, the one_wire starts complaining “Found no devices!”.

The config sections which I have added for BME280 are:

  • i2c
  • platform: bme280_i2c

Does i2c uses some IO pins causing dallas_temp/one_wire to stop working? How can I avoid it? I tried to use one_wire pin GPIO04 as well as GPIO18 and it behaves the same. As long as I add i2c, the dallas sensor is not found and reports 0C.

esphome:
  name: esp32-pool-temp
  friendly_name: esp32-pool-temp

esp32:
  board: esp32dev
  framework:
    type: arduino

one_wire:
  - platform: gpio
    pin: GPIO04

i2c:
  sda: GPIO21
  scl: GPIO22

sensor:
  - platform: dallas_temp
    address: 0x39f3be771f64ff28
    name: "Temp pool surface"
    unit_of_measurement: °C
    icon: "mdi:thermometer"
    accuracy_decimals: 1
    update_interval: 60s
  - platform: dallas_temp
    address: 0x1701707e1f64ff28
    name: "Temp pool depth"
    unit_of_measurement: °C
    icon: "mdi:thermometer"
    accuracy_decimals: 1
    update_interval: 60s
  - platform: bme280_i2c
    temperature:
      name: "BME280 Temperature"
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"

# Enable logging
logger:
  level: VERY_VERBOSE
  
# Enable Home Assistant API
api:
  encryption:
    key: "..."

ota:
  - platform: esphome
    password: "..."

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Bazen-Teplota"
    password: "..."

captive_portal:
    

The log says:

[14:41:55][I][app:100]: ESPHome version 2024.10.0 compiled on Oct 17 2024, 14:38:49
[14:41:55][C][wifi:600]: WiFi:
[14:41:55][C][wifi:428]:   Local MAC: CC:DB:A7:31:97:88
[14:41:55][C][wifi:433]:   SSID: [redacted]
[14:41:55][C][wifi:436]:   IP Address: 192.168.1.188
[14:41:55][C][wifi:440]:   BSSID: [redacted]
[14:41:55][C][wifi:441]:   Hostname: 'esp32-pool-temp'
[14:41:55][C][wifi:443]:   Signal strength: -63 dB ▂▄▆█
[14:41:55][V][wifi:445]:   Priority: 0.0
[14:41:55][C][wifi:447]:   Channel: 11
[14:41:55][C][wifi:448]:   Subnet: 255.255.255.0
[14:41:55][C][wifi:449]:   Gateway: 192.168.1.1
[14:41:55][C][wifi:450]:   DNS1: 192.168.1.1
[14:41:55][C][wifi:451]:   DNS2: 81.90.240.1
[14:41:55][C][logger:185]: Logger:
[14:41:55][C][logger:186]:   Level: VERY_VERBOSE
[14:41:55][C][logger:188]:   Log Baud Rate: 115200
[14:41:55][C][logger:189]:   Hardware UART: UART0
[14:41:55][C][i2c.arduino:071]: I2C Bus:
[14:41:55][C][i2c.arduino:072]:   SDA Pin: GPIO21
[14:41:55][C][i2c.arduino:073]:   SCL Pin: GPIO22
[14:41:55][C][i2c.arduino:074]:   Frequency: 50000 Hz
[14:41:55][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[14:41:55][I][i2c.arduino:096]: Results from i2c bus scan:
[14:41:55][I][i2c.arduino:102]: Found i2c device at address 0x77
[14:41:55][C][gpio.one_wire:020]: GPIO 1-wire bus:
[14:41:55][C][gpio.one_wire:021]:   Pin: GPIO4
[14:41:55][W][gpio.one_wire:078]:   Found no devices!
[14:41:55][C][dallas.temp.sensor:029]: Dallas Temperature Sensor:
[14:41:55][C][dallas.temp.sensor:034]:   Address: 0x39f3be771f64ff28 (DS18B20)
[14:41:55][C][dallas.temp.sensor:035]:   Resolution: 12 bits
[14:41:55][C][dallas.temp.sensor:036]:   Update Interval: 60.0s
[14:41:55][C][dallas.temp.sensor:029]: Dallas Temperature Sensor:
[14:41:55][C][dallas.temp.sensor:034]:   Address: 0x1701707e1f64ff28 (DS18B20)
[14:41:55][C][dallas.temp.sensor:035]:   Resolution: 12 bits
[14:41:55][C][dallas.temp.sensor:036]:   Update Interval: 60.0s
[14:41:55][C][bme280_i2c.sensor:025]:   Address: 0x77
[14:41:55][C][bme280.sensor:182]: BME280:
[14:41:55][C][bme280.sensor:194]:   IIR Filter: OFF
[14:41:55][C][bme280.sensor:195]:   Update Interval: 60.0s
[14:41:55][C][bme280.sensor:197]:   Temperature 'BME280 Temperature'
[14:41:55][C][bme280.sensor:197]:     Device Class: 'temperature'
[14:41:55][C][bme280.sensor:197]:     State Class: 'measurement'
[14:41:55][C][bme280.sensor:197]:     Unit of Measurement: '°C'
[14:41:55][C][bme280.sensor:197]:     Accuracy Decimals: 1
[14:41:55][C][bme280.sensor:198]:     Oversampling: 16x
[14:41:55][C][bme280.sensor:199]:   Pressure 'BME280 Pressure'
[14:41:55][C][bme280.sensor:199]:     Device Class: 'pressure'
[14:41:55][C][bme280.sensor:199]:     State Class: 'measurement'
[14:41:55][C][bme280.sensor:199]:     Unit of Measurement: 'hPa'
[14:41:55][C][bme280.sensor:199]:     Accuracy Decimals: 1
[14:41:55][C][bme280.sensor:200]:     Oversampling: 16x
[14:41:55][C][bme280.sensor:201]:   Humidity 'BME280 Humidity'
[14:41:55][C][bme280.sensor:201]:     Device Class: 'humidity'
[14:41:55][C][bme280.sensor:201]:     State Class: 'measurement'
[14:41:55][C][bme280.sensor:201]:     Unit of Measurement: '%'
[14:41:55][C][bme280.sensor:201]:     Accuracy Decimals: 1
[14:41:55][C][bme280.sensor:202]:     Oversampling: 16x
[14:41:55][C][captive_portal:089]: Captive Portal:
[14:41:55][C][mdns:116]: mDNS:
[14:41:55][C][mdns:117]:   Hostname: esp32-bazen-teplota
[14:41:55][V][mdns:118]:   Services:
[14:41:55][V][mdns:120]:   - _esphomelib, _tcp, 6053
[14:41:55][V][mdns:122]:     TXT: friendly_name = esp32-pool-temp
[14:41:55][V][mdns:122]:     TXT: version = 2024.10.0
[14:41:55][V][mdns:122]:     TXT: mac = ccdba7319788
[14:41:55][V][mdns:122]:     TXT: platform = ESP32
[14:41:55][V][mdns:122]:     TXT: board = esp32dev
[14:41:55][V][mdns:122]:     TXT: network = wifi
[14:41:55][V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[14:41:55][C][esphome.ota:073]: Over-The-Air updates:
[14:41:55][C][esphome.ota:074]:   Address: esp32-pool-temp.local:3232
[14:41:55][C][esphome.ota:075]:   Version: 2
[14:41:55][C][esphome.ota:078]:   Password configured
[14:41:55][C][safe_mode:018]: Safe Mode:
[14:41:55][C][safe_mode:020]:   Boot considered successful after 60 seconds
[14:41:55][C][safe_mode:021]:   Invoke after 10 boot attempts
[14:41:55][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[14:41:55][C][api:140]: API Server:
[14:41:55][C][api:141]:   Address: esp32-pool-temp.local:6053
[14:41:55][C][api:143]:   Using noise encryption: YES
[14:42:16][VV][scheduler:226]: Running interval 'update' with interval=60000 last_execution=44558 (now=104560)
[14:42:16][V][bme280.sensor:210]: Sending conversion request...
[14:42:16][VV][i2c.arduino:176]: 0x77 TX F4B5
[14:42:16][VV][scheduler:032]: set_timeout(name='data', timeout=114)
[14:42:16][VV][scheduler:226]: Running timeout 'data' with interval=114 last_execution=104583 (now=104699)
[14:42:16][VV][i2c.arduino:176]: 0x77 TX F7
[14:42:16][VV][i2c.arduino:148]: 0x77 RX 5636F083345071C2
[14:42:16][V][bme280.sensor:242]: Got temperature=27.9°C pressure=986.6hPa humidity=42.3%
[14:42:16][V][sensor:043]: 'BME280 Temperature': Received new state 27.907148
[14:42:16][D][sensor:094]: 'BME280 Temperature': Sending state 27.90715 °C with 1 decimals of accuracy
[14:42:16][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 1168764344
  state: 27.9071
  missing_state: NO
}
[14:42:17][V][sensor:043]: 'BME280 Pressure': Received new state 986.615601
[14:42:17][D][sensor:094]: 'BME280 Pressure': Sending state 986.61560 hPa with 1 decimals of accuracy
[14:42:17][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 849378863
  state: 986.616
  missing_state: NO
}
[14:42:17][V][sensor:043]: 'BME280 Humidity': Received new state 42.288086
[14:42:17][D][sensor:094]: 'BME280 Humidity': Sending state 42.28809 % with 1 decimals of accuracy
[14:42:17][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 4217600373
  state: 42.2881
  missing_state: NO
}
[14:42:17][W][component:237]: Component bme280_base took a long time for an operation (113 ms).
[14:42:17][W][component:238]: Components should block for at most 30 ms.
[14:42:21][VV][scheduler:226]: Running interval 'update' with interval=60000 last_execution=48877 (now=108878)
[14:42:21][VV][scheduler:032]: set_timeout(name='0x1701707e1f64ff28', timeout=750)
[14:42:21][VV][scheduler:226]: Running timeout '0x1701707e1f64ff28' with interval=750 last_execution=108890 (now=109641)
[14:42:21][VV][dallas.temp.sensor:136]: Scratch pad: 00.00.00.00.00.00.00.00.00 (00)
[14:42:21][D][dallas.temp.sensor:054]: 'Temp pool depth': Got Temperature=0.0°C
[14:42:21][V][sensor:043]: 'Temp pool depth': Received new state 0.000000
[14:42:21][D][sensor:094]: 'Temp pool depth': Sending state 0.00000 °C with 1 decimals of accuracy
[14:42:21][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 322618005
  state: 0
  missing_state: NO
}

2 posts were split to a new topic: DS18B20 random problem

You do have a pull up resistor connected? And the sensor is connected as a 2-wire (aka, you also supply Vcc to the sensor)?

Yes, the Dallas sensor does have pull up resistor connected (although smaller than recommended 4k7 - only something around 2k). The sensor has all 3 wires connected - Vcc (to 3.3V), GND and Data (with pull up resistor).
The bme280 I supposed does not need one.

Okay, that’s good :slight_smile:

By itself I2C does also require pull up resistors but most modules with an I2C chip already have them.

Although I would expect ESPHome to make a good distinction between I2C and 1-wire, what if you explicitly add id’s to the busses and add one_wire_id and i2c_id at the components.

Try adding an id to the bus and the dallas sensor configs. You might as well add an id to the i2c bus and sensor as well

one_wire:
  - platform: gpio
    pin: GPIO04
    one_wire_id: some_id_name

sensor:
  - platform: dallas_temp
    address: 0x39f3be771f64ff28
    name: "Temp pool surface"
    unit_of_measurement: °C
    icon: "mdi:thermometer"
    accuracy_decimals: 1
    update_interval: 60s
    one_wire_id: some_id_name