HA integration – Xiaomi Mi Flora via WiFi by ESP32 microcontroller and ESPHome

HA integration – Xiaomi Mi Flora via WiFi by ESP32 microcontroller and ESPHome


How to integrate Xiaomi Mi Flora to HomeAssistant via WiFi bridge done by ESP32 and running ESPHome.

Today’s article will be about how to get data from the Xiaomi Mi Flora device into your central of home automation.

I’ll show you a way that is a little more complicated but has two major advantages:

  • a plant where you plan to put Xiaomi Mi Flora could be anywhere where you have WiFi – you won’t be limited by Bluetooth range.
  • ESPHome what we are planning to use as “bridge” using passive communication with Xiaomi Mi Flora so it has no impact on the batter life of the device.

Sounds good, isn’t it? Let’s start.

Solution overview

First let’s talk little about the solution itself – what we will need and how it will be connected together in general.

As you can see from the schema we will have three devices involved:

  • HomeAssistant as a home automation center representative – it theory it could be any other system, but because we will use ESPHome for the bridge, the HomeAssistent is the only one option.
  • ESPHome as a bridge between WiFi and Bluetooth world and running with ESPHome firmware
  • Xiaomi Mi Flora as a plant sensor using Bluetooth for communication with the rest of world.

Don’t you have all / any of these parts yet or need more details?

For HomeAssistant I recommend to check my article about overview how to install and what could be good for it.

For Xiaomi Mi Flora I recommend to check my article with detailed description about that device.

For ESP32 I would recommend the version named DoIt DevKit it contains WiFi and Bluetooth and has power by MicroUSB cable – you could be there:

ESPHome – firmware for ESP32

We will start in middle – with preparing ESP32 firmware. Because this article shouldn’t be about ESP32 I will start with the easiest solution – if anyone need help, let me know in comments.

Suppose we have a functional HomeAssistant instance running as Hass.io. Then we could install ESPHome as Hass.io addon from Add-on store.

ESPHome is not included inside default repositories so we have to add one new with the link https://github.com/esphome/hassio.

In the add-on settings section, I recommend to enable the Show in sidebar option and you will have quick access to ESPHome directly from the left HomeAssistant menu.

When the installation is done we could connect ESP32 microcontroller into a computer where Hass.io is running and on the top right side of ESPHome we should see more ports:

For ESP32 the middle option is what we are looking for and we should choose it.

ESPHome – Basic firmware

The best is not to start with the final version of firmware but gradually add more functionality by pieces.

At the beginning, we will only need active WiFi and Bluetooth scanning

Click on the big red + button and fill in the wizard:

  • Introduction And Name – flora_01 (or any other what you like)
  • Device Type – ESP32 Devkit v1 – or. another board
  • WiFi And Over-The-Air Updates – Set the data to your WiFi
  • Done! – done

Use the edit button to check the generated configuration and add line:


The complete configuration could look something like this:

  name: flora_01
  platform: ESP32
  board: esp32doit-devkit-v1

  ssid: "<WIFINAME>"
  password: "<WIFIPASSWORD>"


# Enable logging

# Enable Home Assistant API


Save the configuration and press the Upload button this time, which will first compile and then upload the new firmware via USB serial interface directly to ESP32.

19:56:52][I][app:096]: esphome version 1.13.6 compiled on Oct 20 2019, 19:50:15
[19:56:52][C][wifi:372]: WiFi:
[19:56:52][C][wifi:254]:   SSID: [redacted]
[19:56:52][C][wifi:255]:   IP Address:
[19:56:52][C][wifi:257]:   BSSID: [redacted]
[19:56:52][C][wifi:258]:   Hostname: 'flora_01'
[19:56:52][C][wifi:262]:   Signal strength: -61 dB ▂▄▆█
[19:56:52][C][wifi:263]:   Channel: 1
[19:56:52][C][wifi:264]:   Subnet:
[19:56:52][C][wifi:265]:   Gateway:
[19:56:52][C][wifi:266]:   DNS1:
[19:56:52][C][wifi:267]:   DNS2:
[19:56:52][C][logger:137]: Logger:
[19:56:52][C][logger:138]:   Level: DEBUG
[19:56:52][C][logger:139]:   Log Baud Rate: 115200
[19:56:52][C][logger:140]:   Hardware UART: UART0
[19:56:52][C][ota:029]: Over-The-Air Updates:
[19:56:52][C][ota:030]:   Address: flora_01.local:3232
[19:56:52][C][api:103]: API Server:
[19:56:52][C][api:104]:   Address: flora_01.local:6053

… But we will only be interested in information from the Bluetooth module later, which should gradually show all Bluetooth devices within range.

As soon as we see Got Xiaomi Mi Flora we should write down the MAC address in parentheses.

20:45:46][D][xiaomi_ble:118]: Got Xiaomi Mi Flora (C4:7C:8D:6A:9C:FF):
[20:45:46][D][xiaomi_ble:136]:   Moisture: 34%
[20:46:02][D][xiaomi_ble:118]: Got Xiaomi Mi Flora (C4:7C:8D:6A:9C:FF):
[20:46:02][D][xiaomi_ble:121]:   Temperature: 28.8°C
[20:46:02][D][esp32_ble_tracker:147]: Starting scan..

ESPHome – final firmware

Open the ESPHome configuration again and add one more section to the configuration:

  - platform: xiaomi_hhccjcy01
    mac_address: 'C4:7C:8D:6A:9C:FF'
      name: "Xiaomi MiFlora Temperature"
      name: "Xiaomi MiFlora Moisture"
      name: "Xiaomi MiFlora Illuminance"
      name: "Xiaomi MiFlora Soil Conductivity"
      name: "Xiaomi MiFlora Battery Level"

🥁If you are using ESPHome <1.14 you need to change platform configuration to value xiaomi_miflora

Click on the upload button and upload the updated firmware version.

After the restart, we should see in the ESPHome log the specific values of all sensor values that ESPHome from Mi Flora Plant has read.

20:11:46][D][xiaomi_ble:118]: Got Xiaomi Mi Flora (C4:7C:8D:6A:9C:FF):
[20:11:46][D][xiaomi_ble:130]:   Conductivity: 649µS/cm
[20:11:46][D][sensor:092]: 'Xiaomi MiFlora Soil Conductivity': Sending state 649.00000 µS/cm with 0 decimals of accuracy
[20:11:53][D][xiaomi_ble:118]: Got Xiaomi Mi Flora (C4:7C:8D:6A:9C:FF):
[20:11:53][D][xiaomi_ble:121]:   Temperature: 22.5°C
[20:11:53][D][sensor:092]: 'Xiaomi MiFlora Temperature': Sending state 22.50000 °C with 1 decimals of accuracy
[20:12:02][D][xiaomi_ble:118]: Got Xiaomi Mi Flora (C4:7C:8D:6A:9C:FF):
[20:12:02][D][xiaomi_ble:133]:   Illuminance: 82lx
[20:12:02][D][sensor:092]: 'Xiaomi MiFlora Illuminance': Sending state 82.00000 lx with 0 decimals of accuracy

HomeAssistant integration

Now we have one last step – adding Mi Flora Plant to HomeAssistant. Since we used ESPHome, the integration will be easy.

In HomeAssistant we click on Configuration / Integrations and in Discovered section you should automatically see ESPHome. Click Configure and confirm.

ESPHome configuration now appears in the Configured section, where you can see in detail the name of all sensors or you could rename them directly.

To display on the Dashboard in the case of Lovelace we can use something like this:

  - type: entities
      - entity: sensor.xiaomi_miflora_soil_conductivity
      - entity: sensor.xiaomi_miflora_illuminance
      - entity: sensor.xiaomi_miflora_moisture
      - entity: sensor.xiaomi_miflora_temperature
    title: Rostina - Fikus II
    show_header_toggle: false 

.. which will produce something like this:

That’s all. If you have any questions or suggestions let me know in comments.

Join the discussion

  • Thanks for the guide.
    I have several mi flora devices conntected to HA!
    After follow the guide, Home Assistant is unable to read the device’s battery level.
    The battery level isn’t show in ESPhome’s log after adding this in ESPhome:
    name: “Xiaomi MiFlora Battery Level”

    Any suggestions how to fix this?

    • Hi, the answer is easy and sad – the device does not send battery level data anymore (not even in a new packet type). You can get more details with git issue.

  • Thanks for the tutorial. It works quit good. I only have one question, is it possible to change the update frequency of the sensor values?

    • Hello, you think how often are sensors data sent? ESPHome is in this configuration as a listener and catching all Bluetooth broadcast messages from Flora device. And if I am not wrong Flora sending it every time when any update happens. What is the cause of why you would like to change that?