Low Power UART Bridge for MiFlora

Hello Community!

I recently built a small weatherproof, solar powered ESP32 device to collect data from some MiFlora plant sensors in my backyard. It runs on battery power, which is recharged by solar panels. Everything is working perfectly, except the device is draining the battery at night. I was going to use the deep sleep option to have the device run for 10 minutes and then sleep for 2 hours as I don’t need real time monitoring, but as soon as the device goes offline, HA reports all the devices as “Unavailable”. Is there a way to change the persistence of the data so HA will report the last value? Do I need to use an MQTT broker to accomplish this?

I’m new to ESPHome, so please excuse me if the question is simple.

Thank you!

If you are using deep sleep mqtt is a better option than the esphome api. As you haven’t shared your config, I can’t help more than that.

Thanks @nickrout ,

Here is my config for the device. It’s pretty simple - it just polls the BT addresses of the MiFlora devices and transmits over WiFi. I was hoping to keep it simple, but if MQTT is the best way to go, I’ll give it a try. I don’t use MQTT for anything right now, so it will be yet another learning opportunity.

esphome:
  name: miflora03
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: "MYSSID"
  password: "password"

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

esp32_ble_tracker:

sensor:
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Bed 1 Temperature"
    moisture:
      name: "Bed 1 Moisture"
    illuminance:
      name: "Bed 1 Illuminance"
    conductivity:
      name: "Bed 1 Conductivity"
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Bed 2 Temperature"
    moisture:
      name: "Bed 2 Moisture"
    illuminance:
      name: "Bed 2 Illuminance"
    conductivity:
      name: "Bed 2 Conductivity"
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Bed 3 Temperature"
    moisture:
      name: "Bed 3 Moisture"
    illuminance:
      name: "Bed 3 Illuminance"
    conductivity:
      name: "Bed 3 Soil Conductivity"
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Bed 4 Temperature"
    moisture:
      name: "Bed 4 Moisture"
    illuminance:
      name: "Bed 4 Illuminance"
    conductivity:
      name: "Bed 4 Conductivity"
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Bed 5 Temperature"
    moisture:
      name: "Bed 5 Moisture"
    illuminance:
      name: "Bed 5 Illuminance"
    conductivity:
      name: "Bed 5 Conductivity"
  - platform: xiaomi_hhccjcy01
    mac_address: 'A1:A1:A1:A1:A1:A1'
    temperature:
      name: "Herb Garden Temperature"
    moisture:
      name: "Herb Garden Moisture"
    illuminance:
      name: "Herb Garden Illuminance"
    conductivity:
      name: "Herb Garden Conductivity"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

I think mqtt is your answer.