ThermoPro TP25 and Switchbot Meter

That might be the case with nRFConnect, with OMG I would assume it would disconnect again after the write command, not at least since the radio is then also needed to connect to WiFi to send the MQTT messages.

Possibly the above is also the issue for this. Is the TP25 still connected to nRFConnect or another device?

That will be best answered by someone else, more knowledgeable with the the in depth BLE connection workings. But the above mentioned non constant pairing/connection and the radio sharing between Bluetooth and WiFi could also be a major reason for this not being currently possible.

I think i got some success here.

First of all, i managed to figure out why the command was failing. It turns out that the device has a ā€œmac_typeā€ of 1, and i needed to set that up on the write message. I missed that in the docs, but know i get a success on the write.

But an even better thing is that it turns out that i can read the values through a read command without the need to of sending the write command beforeā€¦so that simplifies thingsā€¦i will be doing some more tests, since i saw some delay in the response. But, while it is not broadcast, it looks workable.

Is there any chance to add the formating of the response message to openmqttgateway for parsing?

Thanks

1 Like

Easily missed sometimes :wink: glad itā€™s working properly now.

Even better!

Isnā€™t the JSON format of the responce message enough? How would you additionally want it to be formatted?

In OpenHAB you can just extract the individual JSON keys/values with JSONPATH transformation, either directly in the THINGS, like

ā€¦ transformationPattern="JSONPATH:$.temp1

or if receiving the whole message as a THING string in a rule whenever the read response is received/updated, by

ā€¦ transform("JSONPATH", "$.temp1", msg ā€¦

@DigiH ,
Mmm, setback, apparently, reading teh characteristic that contains the temperatures is masked until you write teh commandā€¦

@shmuelzon , i saw that you also have an mqtt gateway project, does my use case seem like something that can be accomplished with esp32-ble-mqtt?

As a summary, i have a meat thermometer that requires for a command to be written to a characteristic before use, and to use notifications for the temperature updates. The thermometer needs to remain connected to the gateway, and if not, when reconnected, the command needs to be written again.

I looked at the documentation, and it looks good, expect for the fact that it does not appear to be a way to write hex strings to the characteristics.

Thanks

@ricardol, yes, I believe you can do that with esp32-ble2mqtt. By default it will connect to devices and subscribe for notifications on any characteristics that support that. As for writing to a characteristic after each reconnect, you can either do that with an automation (after you receive the MQTT topic telling you that thermometer is connected) or, simpler yet, publish a retained message to your MQTT broker with the appropriate write command. Then, when esp32-ble2mqtt connects to the thermometer and subscribes on the MQTT write topic, it will immediately receive the write request and send that to the thermometer.

Regarding the content you want to write, you can write it as a byte array (base 10) instead of Hex, for now.

Hope that helps!

Thanks @shmuelzon, i will definetely give it a try.
How about writing to characteristics in Hex? Is that a possibility, or will i need a workaround for it?

Thanks

@ricardol, we can add a parser for hex, it has come up in the past but Iā€™ve never gotten around to it. As I wrote above, you can write your payload as bytes in decimal. If you need to write 01093e8f8a6c35ee26e3f8f1, that would be 1,9,62,143,138,108,53,238,38,227,248,241 with esp32-ble2mqtt.

This sounds great, i will give it a try, and let you know how it goes.
Thanks!

Hey @shmuelzon ,
Thanks for the instructions. I managed to compile and flash esp32-ble-mqtt to an ESP32-WROOM-32D.

That worked succesfully, and if i connect to my mqtt broker, i can see the BLE2MQTT device. It has the 5 topics regarding system info, but i do not see anything else. I do have some broadcasters in my environment, so i was expecting to at least see that. Another thing i noticed is that the blue light does not turn on.

Any ideas of what might be happening?

Thanks

Never mind, i moved the device away from where it was, and some devices started showing up. I will play around with it a little bit, and see how it goes.
thanks!

Hey @shmuelzon,
I managed to get my device visible by esp32-ble-mqtt.When i publish the topic to write the charactersitic to the device, it does not appear to work.

Something like that happen to me with openmqttgateway, where a parameter called ā€œmac_typeā€ needed to be set to 1 for the device to be written. Does esp32-ble-mqtt have a paraemter like that to set on write?

Thanks

Hey @ricardol,

No, esp32-ble2mqtt doesnā€™t have something like that mac_type parameter. I couldnā€™t understand exactly what it does from the documentation.
Are you sure that the write command didnā€™t work? Maybe the payload was wrong and I missed something when converting it to decimal. I suggest moving this discussion to a Github ticket and I can try and help there. If you can also grab the logs while connecting to your treadmill and sending the write command, that would also help.

Good day

Ok @shmuelzon , i have done that.

The issue is Issue trying to write characteristic to ThermoPro TP-25 Ā· Issue #167 Ā· shmuelzon/esp32-ble2mqtt Ā· GitHub
for your reference. We can keep discussing there.

Thanks for your help!