I wrote my own BLE scale to MQTT gateway on an ESP32 for the scale I use. It sends the data inside the advertised manufacturer data. Is there anyway to have this data sent in MQTT in hex rather than binary? Or do I have to learn the code and modify it and upload it myself?
I wanted to replace my custom program because I have stability problems sharing the radio between ble and wifi. But I noticed from other forums, that OpenMqttGateway may have those same problems.
And from your answer it appears that there is no binary that does hex for the manufacturer, but rather I need to look thru the code where this is output and turn it to hex myself, right?
I find it strange to have the sensor data into the manufacturer data, do you have some scan to share of the advertised data, or maybe share your piece of code?
…and after re-reading my original post, I want to make clear. The weight scale sends the readings within the manufacturer data. So I need to be able to read this out of MQTT, which doesn’t work when it’s in binary as it seems to get cut off as a zero terminated strings or perhaps something like that. I see it nicely in hex in the serial terminal of openmqttgateway’s firmware.
actually, I guess I don’t see the hex nicely in the serial console in the openmqttgateway firmware, but rather in the code that is in the BLE examples folder. And I guess that code has nothing to do with openmqttgateway, but I’m not sure. In any case, I didn’t see any of the code in the example folder that passed it thru to the wifi.
Thanks. Your sample looks perfect. I compiled everything and loaded the new esp32dev-ble firmware and parititions
I’m getting the manufacturer data as I had hoped now. I’ll write a small script to convert it to kg and let you know for success.
Is this the sort of thing that you wanted to convert and send in human readable? As I’m probably going to modify OMG to do that, now I’ve gotten into the code a bit.
I shoved it right after the if (advertisedDevice.haveManufacturerData())
in ZgatewayBT.ino
But I’m guessing you have a prettier place to put it. And may not want to force lbs. So I’ll leave it to you to choose what to do with it.
Note that I can not leave the Scan_duration at 10, because the scale throws many readings immediately over and over again, and then when it finally settles in, then it sends that particular reading with a “stable” flag. But if you scan for a long time (multiple seconds), it only gets the first advertisement, which isn’t likely to be the stable reading. So I set my Scan_duration to 2 seconds (and even with that, I worry it may miss the stable reading). Maybe there is a more elegant way to solve that, as your note that reducing Scan_duration below 10 seconds scares me.
These are all valid measurements. The Android app that they offer with the scale shows a fun meter that has a semi-instant readout of what the scale is displaying, I don’t remember now, but I think it was like a 5 hz update or something pretty fast like that. That is why they distinguish between “UI” scale readings and a “stable” measurement.
My concern is that if the scale catches one of those UI measurements, then it waits 2 seconds, then it might miss getting the stable measurement. I’ve tried about 10 times at 2s Scan_duration without a problem. And 10 second I missed well over half of them
So I’ll try the long term test, and after that, I’ll maybe add a beep when it gets a stable measurement to ensure a proper reading.