Closed luisgodelmo closed 4 years ago
Howdy, I would say, if it works for you with those changes, then that's awesome and go with that :thumbsup:
In my experience though, having to init/deinit in the loop was a source of memory leaks for one thing (unless I did the deinit(true) but then, of course, that also nuked the BT stack so, time to reset) so I didn't do it that way. Honestly, those maybe fixed in the newer esp32 libraries. Doing the init/deinit I noticed a reboot like once every 15 days, without it, I have an uptime on that thing into months. YMMV of course.
One other thing to consider is that the inkbird will only advertise/broadcast passively if there is a change in the values. If the values are the same, it doesn't seem to re-broadcast. I checked this by putting one into my 3d printer chamber and setting the heat precisely. As soon as I cranked up the heat by like .2oC then it did notice the change.
Either way, glad that you found this to help. It's definitely VASTLY better than relying on the raspberry pi's bluetooth stack. That thing's jst .. a nightmare sadly.
Hi, after implementing this I found that the first scan after reset always showed name & manufacturer, but from the 2nd scan these 2 values were not shown, so advertisedDevice.haveManufacturerData() was false and no data was published.
This was solved by adding init & deinit BLE in void loop(), I think that by doing this, every new scan found the inkbird sensors "for the first time", so that advertisedDevice.haveManufacturerData() = true and the code could run OK. Maybe after the first pairing the BLE data read was different, as the devices were no more "unknown" for the ESP32. I do not really know if this was the actual problem or why was this happening, and maybe there are more elegant solutions. This is my new void loop:
void loop() { BLEDevice::init("myBLEScan"); client.loop(); if (cnt == 0) { bleScan(); }
cnt=cnt+1;
if (cnt >= 5) { cnt=0; }
client.loop(); delay(5000); // or 5s BLEDevice::deinit(false); }
Makes this sense? At least solved my problem and now I can read them in Home Assistant.