Using ESP32 to communicate with Xiaomi flora (miflora) plant sensor using BLE and posting the values on MQTT server. I also demonstrate the use of Home Assistant miflora sensor component.
Change ESP32 Partition: https://desire.giesecke.tk/index.php/2018/04/20/change-partition-size-arduino-ide/ Home Assistant miflora sensor: https://www.home-assistant.io/components/sensor.miflora/
GitHub: sidddy/flora Archived code from https://github.com/sidddy/flora below
config.h
// array of different xiaomi flora MAC addresses
char* FLORA_DEVICES[] = {
"C4:7C:8D:67:11:11", "C4:7C:8D:67:22:22", "C4:7C:8D:67:33:33"
};
// sleep between to runs in seconds
#define SLEEP_DURATION 30 * 60
// emergency hibernate countdown in seconds
#define EMERGENCY_HIBERNATE 3 * 60
// how often should the battery be read - in run count
#define BATTERY_INTERVAL 6
// how often should a device be retried in a run when something fails
#define RETRY 3
const char* WIFI_SSID = "ssid";
const char* WIFI_PASSWORD = "password";
// MQTT topic gets defined by "<MQTT_BASE_TOPIC>/<MAC_ADDRESS>/<property>"
// where MAC_ADDRESS is one of the values from FLORA_DEVICES array
// property is either temperature, moisture, conductivity, light or battery
const char* MQTT_HOST = "10....