ThermoPro TP25 and Switchbot Meter

That is a read/write characteristic.

1086fff0334348178bb2b32206336ce8 is the service
1086fff1334348178bb2b32206336ce8 is the characteristic i am writing to in that packet (read/write)
1086fff2334348178bb2b32206336ce8 is the characteristic you write to if you want to enable notify.

Sorry i did not send pics, this was faster.

Thanks

Yes, the NOTIFY is the problem here, not applicable to OMG.

So unfortunately you won’t be able to currently get its temperatures with OMG.

It is a real shame that the TP25 doesn’t seem to freely broadcast its temperatures in manufcaturerdata, like a lot of other brand BBQ thermometers do, and also as the ThermoPro Bluetooth Hygrometers Thermometers do :frowning:

Hey again @DigiH,

I understand that the notify might be the problem here, but i am a step before that.

When i write the packet i mentioned before, the Thermopro does 2 things:

-It acknowledges the value has been written
-It immediately sends an update with temperature values.

After that, if i want to enable notify, i can. But it does not look like it is required.

Right now am not at the point where i care about enabling notify. I just want to be able to writ the previous packet successfully. Maybe after that, i can just read values periodically, makes sense?

Thanks

Where and how does it send this update with the temperature values? As a response, like the confirmation of the WRITE success? Or as a broadcast?

Sorry, i realized i made a mistake here.

What actually happens is that, after sending that command, i receive an acknowledgement for the written command.

AFTER that, i can either enable notify on 1086fff2334348178bb2b32206336ce8 , or read the values from that characteristic too. No automatic update with temperature values
Thanks

1 Like

So periodically programmatically sending that command, waiting for the acknowledgement to be received and then reading the values is a possibility (while an awkward one) to get the temperatures from your TP25 though OMG and your controller.

If I understood everything correctly.

That almost completely correct.

i would only have to send that command once. After that, the TP25 remains connected.
I will have to read the characteristic periodically, however, that in my environment is not as awkward as you would think. The periodic reading can come from my automation software (Openhab)

For this to work though, i need that first command to succeed, and now it is failing. Is there a reason i would not be able to reproduce writing a value to a characteristic (Not a notify characteristic)

On a separate note, and just out of curiosity, is there a possibility openmqttgateway will every support notify scenarios? What is the technical obstacle behind it?

Thanks

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!