Send BLE characteristic to MQTT broker via Theengs Gateway

Hi.
I’ve just configured a BLE ESP32 device that show battery level on a specifies pin (32):


At the same time I’ve a TheengsGateway that publish all on an MQTT topic:
image
Anyway if by means MQTT explorer I’ll take a look to this topic I don’t see anything about Battery Level UUID BLE characteristic 2A19 and its value.
What I see is only this:
2023-03-07_111722
Nothing about battery level characteristic.
Any idea?
Thanks in advance

Hi @m4biz,

this should be picked up by the Battery Service decoder

could you turn on advertising/advanced data and show what data is being broadcast in MQTT Explorer then?

I’ve installed both TheengsGateway and Mosquitto on Home Assistant.
I don’t see advertising/advanced data .

Sorry, was in the OpenMQTTGateway mode there, for Theengs Gateway I think the debug levels might have the additional data included, but am not sure to be honest

Two questions:

  1. is OpenMQTT Gateway the same than TheengsGatewy but more powerful ?
  2. is there any Home Assistant integration for OpenMQTT Gateway ?

OpenMQTTGateway runs on ESP32/ESP8266 depending on what kind of gateway you chose to set-up. It also allows for RF, LoRa, IR gateways, whereas Theengs Gateway only decodes BLE devices.

And yes, OpenMQTTGateway also has Home Assistant integration and discovery, like Gateway does.

Just think of Theengs Gateway as the BLE side of OpenMQTTGateway which doesn’t require an ESP32, but can also run on your HA device.

No need you would have to change to OpenMQTTGateway for this, as showing the advertising/advanced data is also on the roadmap for Theengs Gateway. It would have just been helpful to investigate your above issue.

If you have an ESP32 lying around you could try it with installing esp32dev-ble on it.

Hi digiH.
I think your work will be very useful.
There are infinite application of a BLE to MQTT gateway that is also an Home assistant’s integration.
I’ll wait for your investigations and for a major release available.

I just installed the esp32dev-ble on my ESP32 WROOM dev board. I see the following in my MQTT broker:


So this means that all these devices are found, but none of them could be decoded. Right?

The Flower Care is supposed to be a miflora soil sensor. Those are supported by the project, right? Or the ESP32 itself does not do the decoding?

I am running this standalone, I don’t have HA. I was hoping to get all the data over MQTT.

That indeed looks very weird, especially since another devices has also correctly been recognised as a device tracker by the decoder and marked as "state": "offline", and working with the internal tracker sync below.

Can you copy and paste the complete JSON settings for BTtoMQTT and SYStoMQTT?

Sorry, did not get a notification on your post.

BTtoMQTT:

{"bleconnect":true,"interval":55555,"adaptivescan":true,"intervalacts":55555,"intervalcnct":3600000,"scanduration":10000,"hasspresence":false,"prestopic":"presence/","presuseuuid":false,"minrssi":-100,"extDecoderEnable":false,"extDecoderTopic":"undecoded","pubuuid4topic":false,"ignoreWBlist":false,"forcepscn":false,"tskstck":608,"crstck":3060,"enabled":true,"scnct":2,"onlysensors":false,"randommacs":false,"filterConnectable":false,"pubadvdata":false,"presenceawaytimer":120000,"movingtimer":60000}

SYStoMQTT:

{"uptime":127,"version":"v1.8.0","mqtt":true,"serial":false,"disc":true,"ohdisc":false,"env":"esp32dev-ble","freemem":89864,"mqttp":"1883","mqtts":false,"mqttv":false,"msgprc":37,"msgblck":0,"msgrcv":37,"maxq":28,"cnt_index":0,"minmem":32236,"tempc":51.11,"freestck":3956,"powermode":-1,"eth":false,"rssi":-69,"SSID":"xxxx","BSSID":"1E:21:B4:F5:85:AA","ip":"192.168.1.184","mac":"9C:9C:1F:C7:AF:7C","modules":["WebUI","BT"]}

I’m not seeing anything obviously wrong with the settings.

Could you set “pubadvdata” to true, to see which raw BLE data the devices are sending, which in your case seems to not be shown decoded, even tough at least two (C4:7C:… in the messages list, and D5:F7… in the internal device tracker sync) are correctly recognised and marked as device trackers by the decoder.

How did you install the esp32dev-ble binary, and did you erase the flash before the install? I n any case I would ask you to reinstall the binary with the erase flash option on, just in case.

I reinstalled it again with erase option. I used the web install.
How can I change “pubadvdata” to true? Is it possible via MQTT?

Have a look at the documentation at

Thanks for the help, now I am getting some additional parameters:

This is my miflora sensor. But I have been using this for probably 2-3 years and the firmware has not been updated. Is it possible that it is running a very old firmware?

{"id":"C4:7C:8D:60:9E:08","mac_type":0,"adv_type":0,"name":"Flower care","rssi":-67,"servicedata":"3102980079089e608d7cc40d","servicedatauuid":"0xfe95"}

This is a temperature sensor, probably some less known product. I don’t expect this to be supported:

{"id":"30:AE:A4:01:8C:E3","mac_type":0,"adv_type":0,"name":"MOCREO","manufacturerdata":"41818801d8b0460800000000018ce3000000","rssi":-51}

Some unknown sensor:

{"id":"1B:58:D5:04:0F:1D","mac_type":1,"adv_type":3,"rssi":-76,"servicedata":"4a1723513151301132bd8e8eb059c448502315221c0150f6e21e6b","servicedatauuid":"0xfef3"}

Yet another unknown sensor:

{"id":"88:4A:18:86:B8:41","mac_type":0,"adv_type":0,"name":"ck_10013f927e","rssi":-66,"txpower":0}

I seem to have two of these:

{"id":"88:4A:18:86:B8:41","mac_type":0,"adv_type":0,"name":"ck_10013f927e","rssi":-66,"txpower":0}

I ordered a few bluetooth temperature sensors from Ali, which has not arrived yet. I would be interested if those are supported. Not Xiaomi models, but some more generic ones.
I will test again once those arrive.

We do not have a decoder for this particular Flower Care model included yet, as there seem to be several slightly different versions of these MiFlora/FlowerCare/VegTrug … around. I will look into adding one, for which seems to be the HHCCJCY01. Do you know which sense values it has? temperature, moisture, fertility, illuminance … ?

Can you let me know which model of the MOCREO sensor you have, and also give another reading like the above, but with the temperature and possibly humidity as shown in its native app at the same time? Then we could also include a new decoder for this device.

Seems to be the same one, as the id/MAC address is identical, or some beacon with a default id/MAC which might be settable for it :wink: as to it/they only broadcasting its/their name, there is not much to decode from any non-existing additional advertising data. If you ever find out what it is the only possible inclusion could be as a device tracker.

No idea what this one might be, but could possible be some decodable information it its servicedata, if you ever find out which device it is.

For the plant sensor, I am extracting the data on a different ESP32 using this project: GitHub - sidddy/flora: ESP32 BLE client for Xiaomi Mi Plant sensors. This may help.

{"id":"C4:7C:8D:60:9E:08","mac_type":0,"adv_type":0,"name":"Flower care","rssi":-65,"servicedata":"31029800a9089e608d7cc40d","servicedatauuid":"0xfe95"}

last decode from the other project:

{"temperature": 20.5, "moisture": 12, "light": 112, "conductivity": 139, "battery": 66}

I need to fire up the Mocreo sensors, I have not used them for a while, the based station is somewhere in boxes, but the sensors still transmitting with the built in battery.

I will check some of the other devices with nrf connect, sometimes I see the device name there. Probably some are phones, but also seen GoPro popping up as a device. I will try to get you some data if we see benefit adding them to the project.

Got me again :wink: yes, the Flower Care values can only be retrieved by connecting to the device, not by BLE advertising broadcast decoding. So the usual problem with users not seeing decoded values is that de default connection interval is 1 hour. So you should see correct decoding every 60 minutes on the same MQTT topic as your copied undecoded message, or have a look on the same documentation page as the linked to above pubadvdata and look for setting a shorter intervalcnct.

Keep in mind though, that value retrieval through connection has a larger toll on the battery life of your device, so try not to set it too frequent, or maybe leave it at 60 minutes, now that you know if should come up correctly with that interval only.

Would be good to get this in if it’s possible to decode through its BLE advertising data.

1 Like

Here is the data from the two Mocreo sensors:
ST6 (temperature and humidity):

{"id":"30:AE:A4:01:50:54","mac_type":0,"adv_type":0,"name":"MOCREO","manufacturerdata":"4183ec0257b0030906110000015054000000","rssi":-44}

Battery: 87 %
Temperature: 23 C
Humidity: 42.8 %

ST5: temperature only:

{"id":"30:AE:A4:01:8C:E3","mac_type":0,"adv_type":0,"name":"MOCREO","manufacturerdata":"4181e701d8b09e0800000000018ce3000000","rssi":-59}

Battery: 88 %
Temperature: 21.9 C

I hope I did not mix up the messages.