A connected thermometer in every room for 10 €: Bluetooth sensors + ESP32 + Gladys' automatic MQTT discovery

Hi Gladys community!

I’m the creator of OpenMQTTGateway and Theengs, and I’ve been discussing with Pierre-Gilles about integration into Gladys. The first step is MQTT integration with auto-discovery. Here’s a tutorial written by Claude that describes how it works with a small Bluetooth thermometer with a screen, ThermoPro or Xiaomi, bought for €10 to monitor humidity or temperature.

What few people know: these sensors broadcast their measurements in Bluetooth Low Energy continuously — and Gladys can now retrieve them automatically.

On the budget side, the comparison to equip 8 rooms with Zigbee:

Solution Cost for 8 rooms
Zigbee (Sonoff SNZB-02P ~€14 + dongle ~€25) ~€135
BLE ThermoPro (~€9/unit in pack) + ESP32 €8 ~€80
BLE Xiaomi LYWSD03MMC ~€5 (next tutorial) + ESP32 €8 ~€48

And unlike Zigbee: integrated LCD screen on each sensor (readable without opening Gladys), button cell battery lasting ~1 year, and the sensors you already own count for €0. You just need an « antenna » to listen to them: an ESP32 for ~€8 flashed with OpenMQTTGateway, which decodes over 120 sensor models and publishes them in MQTT.

And the cherry on top: Gladys’ MQTT integration now supports automatic discovery (Home Assistant Discovery format, announced by Pierre-Gilles here) — you need Gladys 5 for it to work with OpenMQTTGateway. Result: the sensors appear all by themselves in Gladys, with their features already configured. No MQTT topic to type manually.

Here’s the principle:

  BLE Sensors (€5-10)        ESP32 + OpenMQTTGateway (~€8)
  ┌──────────────┐
  │ ThermoPro    │ )))
  ├──────────────┤              ┌─────────────┐
  │ Xiaomi T301  │ ))) ~~BLE~~> │    ESP32    │
  ├──────────────┤              │     OMG     │
  │ Mi Flora     │ )))          └──────┬──────┘
  └──────────────┘                     │ WiFi / MQTT
                                       ▼
                              ┌─────────────────┐
                              │ Broker Mosquitto│
                              │  (in Gladys)  │
                              └────────┬────────┘
                                       │
                                       ▼
                              ┌─────────────────┐
                              │ Gladys 5        │
                              │ Auto Discovery │
                              └─────────────────┘

Total time: 15 minutes. No soldering, no tools to install on your computer. Let’s go!


Required Materials

Material Price Role
ThermoPro TP357/TP358 ~€10-12 (cheaper in packs of 2 or 3) Temperature + humidity, with screen — The star sensor: zero configuration, decoded out of the box
Govee H5075 / H5072 ~€12-15 Alternative without configuration, with screen, decoded out of the box
Xiaomi LYWSD03MMC ~€5 The cheapest, but requires a small wireless flash — this will be the subject of a next tutorial
Mi Flora HHCCJCY01 ~€12-15 Plant sensor (soil humidity, light, fertility)
SwitchBot Meter ~€15 Temperature + humidity, with screen
ESP32 (any model dev board, or M5Stack) ~€8 The BLE → MQTT antenna
USB Cable already in a drawer Power supply for the ESP32

Why the ThermoPro TP357 as the star sensor? It is decoded out of the box by Theengs Decoder (no flash, no app, no key: you put the battery and it emits in plain text), it has a screen, it is available everywhere on Amazon.fr (often ~€8-9/unit in packs of 2 or 3), and it is one of the sensors in my real setup. The « 15-minute » promise holds with it.

On my side, the tested setup: an M5Stack (ESP32) flashed with OpenMQTTGateway v1.8.x (esp32 BLE binary), and a handful of ThermoPro, Xiaomi, and SwitchBot sensors. But any ESP32 for €8 does exactly the same job.

:light_bulb: A single ESP32 covers ~10 meters around. For a large house, put one per floor: they all publish to the same broker, Gladys will see no difference.


Step 1 — Update Gladys + Enable MQTT Broker (2 min)

:warning: First: Update to Gladys 5!

Automatic discovery appeared in 4.86, but 4.x versions rejected the « wildcard » state topics used by OpenMQTTGateway. If you see this message in Gladys logs:

ignoring state topic +/+/BTtoMQTT/xxx, wildcards are not allowed

…it means you are not on Gladys 5, which includes the fix. If you use Watchtower (recommended Docker installation), the update is automatic. Otherwise, update the Gladys container before continuing.

Then: MQTT Broker in One Click

  1. Go to Integrations, type « mqtt » in the search and open MQTT Virtual Devices.

  1. In the Setup tab, enable the toggle « Use broker in a Docker container ». A blue box warns you that a Mosquitto broker will be launched on port 1883: click on « Install broker on Docker ».

  1. Once installed, the screen displays « Connected to the MQTT broker with success! » and the configuration:
    • Broker URL: mqtt://localhost
    • Username: gladys
    • a generated password (eye icon to display it) → copy it, we will need it in step 3.

The broker listens on port 1883 of your Gladys server’s IP, accessible from the entire local network. Note this IP (example: 192.168.1.117).


Step 2 — Flash OpenMQTTGateway from the Browser (5 min)

No need to install anything: the flash is done directly from the browser thanks to Web Serial.

  1. Connect the ESP32 via USB to your computer.

  2. Open Chrome or Edge (Firefox and Safari do not support Web Serial) and go to:

    :backhand_index_pointing_right: (Option 1) Upload from the web | Theengs OpenMQTTGateway v1.8.1

  3. In the list of binaries, choose esp32dev-ble.

  4. Click on Connect, select the serial port of your ESP32, then Install.

  5. Wait 2-3 minutes during the flash. :hot_beverage:

That’s all. The ESP32 restarts with OpenMQTTGateway on board, Theengs Decoder included (the decoder for the 120+ BLE sensor models).


Step 3 — Configure the WiFi and MQTT of the ESP32 (5 min)

On the first startup, the ESP32 does not yet know your network: it creates its own WiFi access point.

  1. On your phone or computer, connect to the WiFi network created by the ESP32 (name of the type OpenMQTTGateway).
  2. A configuration portal opens (otherwise, open 192.168.4.1 in the browser).
  3. Fill in:
Portal Field Value
WiFi SSID / password your WiFi network
mqtt server the IP of your Gladys server (ex: 192.168.1.17)
mqtt port 1883
mqtt user gladys
mqtt pass the password copied from the MQTT screen of Gladys in step 1
mqtt base topic home/ (:warning: leave the default value!)

  1. Validate. The ESP32 restarts and connects to your WiFi then to Gladys’ broker.

From there, it scans BLE every ~55 seconds and publishes each decoded sensor on a topic of the type:

home/m-gateway>/BTtoMQTT/<MAC-of-the-sensor>

For example, for a ThermoPro TP357:

{"tempc": 26.6, "hum": 88, "batt_low": true}

Or for my Oria T301 (a Xiaomi clone whose factory firmware transmits in plain text, MAC in A4:C1:38...):

{"tempc": 26.3, "hum": 62, "batt": 100}

And above all, it publishes the discovery configs (retained) on homeassistant/.../config — exactly what the new MQTT integration of Gladys knows how to read. :smiling_face_with_sunglasses:


Step 4 — Create Discovered Devices in Gladys (2 min)

Go back to Gladys: Integrations → MQTT Virtual Devices → Discovery tab.

Magic: your sensors are there, with their name, model, and features (temperature, humidity, battery…) already detected.

  1. Click on each device to create it in Gladys.
  2. Assign it a room (Bedroom, Bathroom, Basement…).
  3. Add the features to your dashboards: one card per room with temperature + humidity is very readable.

A few real examples of what comes up automatically at my place:

  • ThermoPro TP357/TP358: temperature, humidity, low battery alert
  • Oria T301 (LYWSD03MMC family clone, unencrypted factory firmware): temperature, humidity, battery
  • BlueCharm Beacons: temperature, accelerometer, battery voltage
  • SwitchBot Curtain / Blind Tilt: position, battery, light level (read-only — see the limitations section below)

:hourglass_not_done: Patience on first discovery: BLE sensors only emit every 1 to 10 minutes depending on the model. Let it run for 10 minutes before concluding that it doesn’t work.


Step 5 — Useful Scenes with All This

Now that each room reports its temperature and humidity, a few life-changing scene ideas:

:cold_face: Freeze Alert (Basement, Garage, Greenhouse)

  • Trigger: basement temperature < 3 °C
  • Action: send a Telegram message « ⚠️ Risk of freezing in the basement (2.1 °C), think about the pipes! »

:shower: Bathroom Humidity → VMC

  • Trigger: bathroom humidity > 70 %
  • Action: turn on the VMC (smart plug)
  • And the reverse scene: humidity < 55 % → turn off the VMC.

With the ThermoPro at 88% humidity seen earlier, the VMC runs after every shower. :grinning_face_with_smiling_eyes:

:thermometer: Wine Cellar Monitoring

  • Trigger: basement temperature > 16 °C during the day
  • Action: notification + graph in the dashboard to track the drift over the year.

Honest Limitations (and Next Steps)

Let’s be transparent, not everything is perfect yet:

  • Controlling SwitchBot actuators (Curtain, Blind Tilt) is not yet supported by Gladys discovery. Their sensors report very well (position, battery, light level), but the tilt-only cover entities and the command templates used by OpenMQTTGateway are not yet managed. So: reading yes, command no — for now.
  • Discovery covers classic sensors (temperature, humidity, battery, etc.). More exotic entities may be ignored.
  • On the Gladys side, a native Bluetooth integration is being specified — discussions are open on this topic. In the long run, we can imagine doing without MQTT for BLE. Meanwhile, the OpenMQTTGateway + MQTT discovery solution is the best, and it is very robust.

Troubleshooting: The 5 Classic Pitfalls

1. Nothing appears in the Discovery tab, and Gladys logs say ignoring state topic +/+/BTtoMQTT/xxx, wildcards are not allowed → Your Gladys is not up to date: you need Gladys 5. Update (Watchtower does it automatically) and restart the ESP32 so that it republishes its configs.

2. You changed the base topic → Leave the base topic as home/ (the default value). This is the expected format, do not customize it.

3. « It doesn’t work » after 2 minutes → BLE sensors only emit every 1 to 10 minutes depending on the model. On first discovery, let it run for 10 minutes. The ESP32, on the other hand, scans every ~55 s.

4. Still nothing after 10 minutes → Check that the ESP32 is well connected to the broker: it publishes its status (LWT) on the topic home/<gateway-name>/LWT, which should be online. You can check this with MQTT Explorer, or with:

mosquitto_sub -h <Gladys-IP> -u gladys -P <password> -t "home/+/LWT" -v

If it’s offline or empty: recheck the broker IP, port 1883, username gladys and password copied from Gladys.

5. A sensor at the bottom of the garden never reports → BLE range is about 10 m (including walls, it’s quickly less). The solution is simple and cheap: add a second ESP32 (one per floor, one in the garage…), all configured on the same broker. Gladys naturally merges everything.


Conclusion

For less than 20 € (1 ESP32 + 1 ThermoPro), you have a first connected thermometer that appears automatically in Gladys, without the slightest sensor flash — and if a ThermoPro or a Xiaomi is already lying around at your place, your first sensor is free. Then, each additional room costs only ~10 €.

:pushpin: Next tutorial: the Xiaomi LYWSD03MMC at 5 € — the best quality/price ratio on the market, at the price of a small 2-minute wireless flash from the browser. Stay tuned!

  • :stopwatch: 15 minutes of setup
  • :wrench: Zero soldering, zero mandatory command line
  • :battery: 1 year of battery life
  • :house: 120+ supported sensor models

A big thank you to Pierre-Gilles for the automatic MQTT discovery that makes all this possible without manual configuration. :folded_hands:

And you, what BLE sensors do you have at home? Share your payloads and scenes in the replies!

So interesting all that!! Thanks! :wink: