Connecting two xiaomi BLE sensor over esphome

Hello everyone :vulcan_salute:

I am using home assistant with Rasberry pi 4 with few xiaomi ble sensor with original and ATC firmware over Bluetooth Low Energy Monitor (Passive BLE monitor) integration service. It was good upto i need to move my greenhouse too far away from home assistant server.

I follow suggestions and got one esp32 board. first i connect Xiaomi MiFlora soil sensor and setup my esp32. its work perfectly. after i add ATC firmware Xiaomi LYWSD03MMC thermometer but unfortunatly i coudlnt get any data.

when i check ESP32 logs its looking it’s see devices but don’t get any data. During these tests sensors broadcast value and i can see these values over HA server bluetooth (it’s mean device working well ) but i dont get why esp can not catch data?

i check mac adresses, its looking ok. i wish somebody can catch where i made mistake.

best regards

Esp32 configuration : I try mac adress without quote, with ’ or with " . it didnt change situation.

captive_portal:

esp32_ble_tracker:

xiaomi_ble:

sensor:
  - platform: xiaomi_hhccjcy01
    mac_address: 'C4:7C:8D:6C:EB:F1'
    temperature:
      name: "Xiaomi HHCCJCY01 Temperature"
    moisture:
      name: "Xiaomi HHCCJCY01 Moisture"
    illuminance:
      name: "Xiaomi HHCCJCY01 Illuminance"
    conductivity:
      name: "Xiaomi HHCCJCY01 Soil Conductivity"
    battery_level:
      name: "Xiaomi HHCCJCY01 Battery Level"
  - platform: atc_mithermometer
    mac_address: A4:C1:38:A4:0C:A5
    temperature:
      name: "Greenhouse Temperature"
    humidity:
      name: "Greenhouse Humidity"
    battery_level:
      name: "Greenhouse Battery-Level"

this is the log screen of ESP interface. I made bold Mac adress of temperature sensor. system can see broadcasting but can not catch any value. other sensor working well.

thank you for your help :innocent:

INFO Reading configuration /config/esphome/kb.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing kb (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
Dependency Graph
|-- 1.2.2
|-- 1.0
|-- 1.0
|-- 1.0
|-- 2.1.0
| |-- 1.2.2
|-- 1.1.0
|-- 1.0
RAM: [== ] 16.4% (used 53628 bytes from 327680 bytes)
Flash: [======== ] 83.0% (used 1522178 bytes from 1835008 bytes)
========================= [SUCCESS] Took 8.79 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of kb.local
INFO → 192.168.1.21
INFO Uploading /data/kb/.pioenvs/kb/firmware.bin (1522288 bytes)
Uploading: [============================================================] 100% Done…

INFO Waiting for result…
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from kb.local using esphome API
WARNING Can’t connect to ESPHome API for kb.local: Error resolving IP address: [Errno -2] Name or service not known
INFO Trying to reconnect to kb.local in the background
INFO Successfully connected to kb.local
[17:52:53][I][app:102]: ESPHome version 2022.3.0 compiled on Mar 16 2022, 17:43:35
[17:52:53][C][wifi:491]: WiFi:
[17:52:53][C][wifi:353]: Local MAC: XXXXXXXXXXXXXXXXXXXXXXXXX
[17:52:53][C][wifi:354]: SSID: [redacted]
[17:52:53][C][wifi:355]: IP Address: 192.168.1.21
[17:52:53][C][wifi:357]: BSSID: [redacted]
[17:52:53][C][wifi:358]: Hostname: ‘kb’
[17:52:53][C][wifi:360]: Signal strength: -79 dB ▂▄▆█
[17:52:53][C][wifi:364]: Channel: 2
[17:52:53][C][wifi:367]: DNS1: 192.168.1.1
[17:52:53][C][wifi:368]: DNS2: 192.168.1.1
[17:52:53][C][logger:233]: Logger:
[17:52:53][C][logger:234]: Level: DEBUG
[17:52:53][C][logger:235]: Log Baud Rate: 115200
[17:52:53][C][logger:236]: Hardware UART: UART0
[17:52:53][C][xiaomi_hhccjcy01:012]: Xiaomi HHCCJCY01
[17:52:53][C][xiaomi_hhccjcy01:013]: Temperature ‘Xiaomi HHCCJCY01 Temperature’
[17:52:53][C][xiaomi_hhccjcy01:013]: Device Class: ‘temperature’
[17:52:53][C][xiaomi_hhccjcy01:013]: State Class: ‘measurement’
[17:52:53][C][xiaomi_hhccjcy01:013]: Unit of Measurement: ‘°C’
[17:52:53][C][xiaomi_hhccjcy01:013]: Accuracy Decimals: 1
[17:52:53][C][xiaomi_hhccjcy01:014]: Accuracy Decimals: 0
[17:52:53][C][xiaomi_hhccjcy01:014]: Icon: ‘mdi:water-percent’
[17:52:53][C][xiaomi_hhccjcy01:015]: Conductivity ‘Xiaomi HHCCJCY01 Soil Conductivity’
[17:52:53][C][xiaomi_hhccjcy01:015]: State Class: ‘measurement’
[17:52:53][C][xiaomi_hhccjcy01:015]: Unit of Measurement: ‘µS/cm’
[17:52:53][C][xiaomi_hhccjcy01:015]: Accuracy Decimals: 0
[17:52:53][C][xiaomi_hhccjcy01:015]: Icon: ‘mdi:flower’
[17:52:53][C][xiaomi_hhccjcy01:016]: Illuminance ‘Xiaomi HHCCJCY01 Illuminance’
[17:52:53][C][xiaomi_hhccjcy01:017]: Battery Level ‘Xiaomi HHCCJCY01 Battery Level’
[17:52:53][C][xiaomi_hhccjcy01:017]: Device Class: ‘battery’
[17:52:53][C][xiaomi_hhccjcy01:017]: State Class: ‘measurement’
[17:52:53][C][atc_mithermometer:012]: ATC MiThermometer
[17:52:53][C][atc_mithermometer:013]: Temperature ‘Greenhouse Temperature’
[17:52:53][C][atc_mithermometer:013]: Device Class: ‘temperature’
[17:52:53][C][atc_mithermometer:013]: State Class: ‘measurement’
[17:52:53][C][atc_mithermometer:013]: Unit of Measurement: ‘°C’
[17:52:53][C][atc_mithermometer:013]: Accuracy Decimals: 1
[17:52:53][C][atc_mithermometer:014]: Humidity ‘Greenhouse Humidity’
[17:52:53][C][atc_mithermometer:014]: Device Class: ‘humidity’
[17:52:53][C][atc_mithermometer:015]: Battery Level ‘Greenhouse Battery-Level’
[17:52:53][C][atc_mithermometer:015]: Device Class: ‘battery’
[17:52:53][C][atc_mithermometer:015]: State Class: ‘measurement’
[17:52:53][C][atc_mithermometer:015]: Unit of Measurement: ‘%’
[17:52:53][C][atc_mithermometer:015]: Accuracy Decimals: 0
[17:52:53][D][esp32_ble_tracker:723]: Found device E3:47:1E:B2:D5:A1 RSSI=-68
[17:52:53][D][esp32_ble_tracker:744]: Address Type: RANDOM
[17:52:53][C][esp32_ble_tracker:709]: BLE Tracker:
[17:52:53][C][esp32_ble_tracker:710]: Scan Duration: 300 s
[17:52:53][C][esp32_ble_tracker:711]: Scan Interval: 320.0 ms
[17:52:53][C][esp32_ble_tracker:712]: Scan Window: 30.0 ms
[17:52:53][C][esp32_ble_tracker:713]: Scan Type: ACTIVE
[17:52:53][C][captive_portal:088]: Captive Portal:
[17:52:54][C][mdns:084]: mDNS:
[17:52:54][C][mdns:085]: Hostname: kb
[17:52:54][C][ota:085]: Over-The-Air Updates:
[17:52:54][C][ota:086]: Address: kb.local:3232
[17:52:54][C][ota:089]: Using Password.
[17:52:54][C][api:138]: API Server:
[17:52:54][C][api:139]: Address: kb.local:6053
[17:52:54][C][api:143]: Using noise encryption: NO
[17:53:14][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:53:14][D][xiaomi_ble:317]: Temperature: 24.4°C
[17:53:14][D][sensor:125]: ‘Xiaomi HHCCJCY01 Temperature’: Sending state 24.40000 °C with 1 decimals of accuracy
[17:53:37][D][esp32_ble_tracker:723]: Found device A4:C1:38:A4:0C:A5 RSSI=-71
[17:53:37][D][esp32_ble_tracker:744]: Address Type: PUBLIC
[17:53:37][D][esp32_ble_tracker:746]: Name: ‘ATC_A40CA5’
[17:53:40][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:53:40][D][xiaomi_ble:326]: Conductivity: 59µS/cm
[17:53:40][D][sensor:125]: ‘Xiaomi HHCCJCY01 Soil Conductivity’: Sending state 59.00000 µS/cm with 0 decimals of accuracy
[17:53:54][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:53:54][D][xiaomi_ble:317]: Temperature: 24.4°C
[17:53:54][D][sensor:125]: ‘Xiaomi HHCCJCY01 Temperature’: Sending state 24.40000 °C with 1 decimals of accuracy
[17:54:03][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:54:03][D][xiaomi_ble:329]: Illuminance: 1985lx
[17:54:03][D][xiaomi_ble:344]: Light: off
[17:54:03][D][sensor:125]: ‘Xiaomi HHCCJCY01 Illuminance’: Sending state 1985.00000 lx with 0 decimals of accuracy
[17:54:18][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:54:18][D][xiaomi_ble:332]: Moisture: 1%
[17:54:18][D][sensor:125]: ‘Xiaomi HHCCJCY01 Moisture’: Sending state 1.00000 % with 0 decimals of accuracy
[17:54:34][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:54:34][D][xiaomi_ble:317]: Temperature: 24.6°C
[17:54:34][D][sensor:125]: ‘Xiaomi HHCCJCY01 Temperature’: Sending state 24.60000 °C with 1 decimals of accuracy
[17:54:43][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:54:43][D][xiaomi_ble:329]: Illuminance: 1985lx
[17:54:43][D][xiaomi_ble:344]: Light: off
[17:54:43][D][sensor:125]: ‘Xiaomi HHCCJCY01 Illuminance’: Sending state 1985.00000 lx with 0 decimals of accuracy
[17:55:07][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:55:07][D][xiaomi_ble:326]: Conductivity: 60µS/cm
[17:55:07][D][sensor:125]: ‘Xiaomi HHCCJCY01 Soil Conductivity’: Sending state 60.00000 µS/cm with 0 decimals of accuracy
[17:55:47][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:55:47][D][xiaomi_ble:326]: Conductivity: 59µS/cm
[17:55:47][D][sensor:125]: ‘Xiaomi HHCCJCY01 Soil Conductivity’: Sending state 59.00000 µS/cm with 0 decimals of accuracy
[17:55:54][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:55:54][D][xiaomi_ble:317]: Temperature: 24.6°C
[17:55:54][D][sensor:125]: ‘Xiaomi HHCCJCY01 Temperature’: Sending state 24.60000 °C with 1 decimals of accuracy
[17:56:20][D][xiaomi_ble:314]: Got Xiaomi HHCCJCY01 (C4:7C:8D:6C:EB:F1):
[17:56:20][D][xiaomi_ble:326]: Conductivity: 60µS/cm
[17:56:20][D][sensor:125]: ‘Xiaomi HHCCJCY01 Soil Conductivity’: Sending state 60.00000 µS/cm with 0 decimals of accuracy

.

What advertising type you have set in thermometer? I use atc type and it worked well on esphome. But these things work way better with tasmota fw on esp32. No setup in esp32 needed, just make mqtt sensors in HA, so i switched to tasmota.

broadcast type is ATC, i flash them in first date, also today i re-flash with latest version of ATC firmware. no change after.

Note that it can take up to 5 minutes for thermometer data to show in HA. Supposely because of buggy BLE drivers in esphome. That’s why tasmota is better in this regard (better drivers, data shows a few seconds after restart).

it’s still open without any data. if i can’t figure out i will try tasmota also. thank you for your advice :v:

with your suggestion i try tasmoto and get values from bluetooth device. But now have a problem to get values on home assistant :sweat_smile:

Tasmota variables couldn’t visible on home assistant - Configuration - Home Assistant Community (home-assistant.io)

i open new topic to solve this problem. thank you for your suggetion

1 Like

for checking with tasmoto i re-flash esp home to understand what is wrong.

I add ble_presence for temperature sensor and system show me its available but still no value :scream:

any suggestion to check for esphome?

esp32_ble_tracker:

xiaomi_ble:

binary_sensor:
  - platform: ble_presence
    mac_address: "A4:C1:38:A4:0C:A5"
    name: "Greenhouse thermometer available"
    
sensor:
      
  - platform: atc_mithermometer 
    mac_address: "A4:C1:38:A4:0C:A5"
    temperature:
      name: "Xiaomi MiJia Temperature"
    humidity:
      name: "Xiaomi MiJia Humidity"
    battery_level:
      name: "Xiaomi MiJia Battery Level"
      
  - platform: xiaomi_hhccjcy01
    mac_address: "C4:7C:8D:6C:EB:F1"
    temperature:
      name: "Xiaomi MiFlora Temperature"
    moisture:
      name: "Xiaomi MiFlora Moisture"
    illuminance:
      name: "Xiaomi MiFlora Illuminance"
    conductivity:
      name: "Xiaomi MiFlora Soil Conductivity"
    battery_level:
      name: "Xiaomi MiFlora Battery Level"

after read that message i reflash with pvvx firmware and now connection is ok. atc firmware should have some problem. problem solved now. thank you

[09:11:45][D][pvvx_mithermometer:118]: Got PVVX MiThermometer (A4:C1:38:A4:0C:A5):
[09:11:45][D][pvvx_mithermometer:121]:   Temperature: 26.27 °C
[09:11:45][D][pvvx_mithermometer:124]:   Humidity: 45.01 %
[09:11:45][D][pvvx_mithermometer:127]:   Battery Level: 87 %
[09:11:45][D][pvvx_mithermometer:130]:   Battery Voltage: 2.985 V