It sounds a bit overly complicated to me. A cron job running every 5 min does the job nicely. Any specific reason why you’d want to use presence detection instead of a cron job?
I guess it is. I was thinking that this way you could reduce the time until a measurement is displayed in HA. Maybe even make it possible to integrate into a magic mirror. On the other hand my intention was to reduce overhead from running the script every five minutes - although I realize that this overhead is most likely negligible.
yeah pretty much. overhead on scanning bluetooth constantly might actually be more…
The ESP32 link I posted above scans continuously. My home assistant instance runs on a NAS which doesn’t have Bluetooth and isn’t near my scale regardless, so this approach works well in that case.
AFAIK BLE presence detection is generally done through the same scan that is done to get the scale’s advertising data anyway, so they are one and the same.
Thank you for the reply, the size error is gone… But I’m facing other errors as well:
And is it possible to add MQTT password to the code?
I always see that warning in the pubsubclient, but all those others are new to me, perhaps different library version or something?
Are you building in an IDE like VS Code or via the CLI?
What does your platformio.ini look like?
I fixed the MQTT password field being incorrect, as well.
Im using VS Code IDE, and my platformio.ini:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.partitions = min_spiffs.csv
I’m new to PlatformIO so I don’t know how to properly build the platformio.ini.
Hrm, is your main.cpp file in the src/ directory of the project? Are there any other files in the /src directory? Looking around, it seems like people run into this problem when they have something wrong with the structure of how their platformio project is laid out.
If nothing is obvious, try this command to verify what’s where :
tree /path/to/yourproject
FWIW - As a sanity check, I created a new platform IO project, added the board_build.partitions change to the platformio.ini, and replaced main.cpp with the main.cpp from the github repo and built successfully.
I’m trying to figure out what is wrong with my PlatformIO settings, but I tried to compile and upload the OpenMQTTGateway everything went without any error, so I’m googling and looking for all possible ways to resolve this errors.
Sorry you’re running into problems. As a double sanity check to make sure I hadn’t installed something strange, I installed vs code and platform io onto a new machine, created a new project from scratch, and pasted my main.cpp over the existing main.cpp. Again, added the necessary line to the platformio.ini. I had to install the pubsubclient and arduinojson libraries, but it built right away.
I wish I could offer more help figuring out where things are going wrong.
No worries and thank you for your time. Im new to PlatformIO. And I completed all steps what you described above, except one thing
I installed and uninstalled Atom IDE in the past, and I think this is what giving me this trouble. Eventually I will figure out this, maybe over weekend when I will be free from my day job.
Hey everyone, thanks to @ned-kelly’s PR, I’ve updated my git repo.
This means the code is now available as a docker container
(Hoping this helps all the users who wanted it to run on hass.io)
Please note it’s the first time that I get involved in building a container, let alone publishing one, so if you spot some noob errors, be gentle
Hello all,
With th help of @pavon87 we added Xiaomi scale V1 support to OpenMQTTGateway on ESP32, here is the thread:
I would like to add also Xiaomi Scale V2, I did a first theorical approach there and I’m looking for testers to verify that the code is working.
Is there any people with an ESP32 and a Xiaomi Scale V2 that would like to participate in testing?
Hey everyone,
I’ve updated the container to make it multi architecture. Pulling lolouk44/xiaomi-mi-scale:latest now supports the following platforms:
- linux/amd64
- linux/arm64
- linux/arm/v6
- linux/arm/v7
I’ve updated the instructions on my git repo
I’d love to hear from hass.io users to see if that now works for them
Got a V2 Scale but no spare ESP32 I’m afraid. Maybe I can help with some of the "basics. What are you looking for ?
I’ll give it a go this week
Ah yes, it could be interesting to have some service data and uuid examples from the “beacon simulator” app scanning the mi scale v2 and the corresponding weight and impedances.
This way I would integrate this examples as unit tests.
Thanks, I don’t have any android device I’m afraid…
It’s a pity, if someone else have a Xiaomi V2 and an android, don’t hesitate to do the test
Hi lolouk44,
I tried your container on my rpi3. I had some errors because it was not build for rpi but after some research i managed to update ur Dockerfile to FROM arm32v7/python:3.8-rc-alpine and rebuild the image.
It looks like the container is running now but i do see in logs the following error:
exit status 1 from user root python3 /opt/miscale/Xiaomi_Scale.py
Do i need to update other things too to make it work on rpi3?
Thanks