Code Monkey home page Code Monkey logo

export2garmin's Introduction

Export 2 to Garmin Connect

1. Introduction

1.1. Miscale module:

  • Allows fully automatic synchronization of Mi Body Composition Scale 2 (tested on XMTZC05HM) directly to Garmin Connect, with following parameters:
    • Date and Time (measurement, from device);
    • Weight (NOTE: kg units only);
    • BMI (Body Mass Index);
    • Body Fat;
    • Skeletal Muscle Mass;
    • Bone Mass;
    • Body Water;
    • Physique Rating;
    • Visceral Fat;
    • Metabolic Age.
  • Miscale_backup.csv file also contains other parameters (can be imported e.g. for analysis into Excel):
    • BMR (Basal Metabolic Rate);
    • LBM (Lean Body Mass);
    • Ideal Weight;
    • Fat Mass To Ideal;
    • Protein;
    • Data Status (to_import, failed, uploaded);
    • Unix Time (based on Date and Time);
    • Email User (used account for Garmin Connect);
    • Upload Date and Upload Time (to Garmin Connect);
    • Difference Time (between measuring and uploading);
    • Battery status in V and % (ESP32 only).
  • Supports multiple users with individual weights ranges, we can link multiple accounts with Garmin Connect.

1.2. Omron module:

  • Allows fully automatic synchronization of Omron blood pressure (tested on M4/HEM-7155T and M7/HEM-7322T Intelli IT) directly to Garmin Connect, with following parameters:
    • Date and Time (measurement, from device);
    • DIAstolic Blood Pressure;
    • SYStolic Blood Pressure;
    • Heart Rate.
  • Omron_backup.csv file also contains other parameters (can be imported e.g. for analysis into Excel):
    • MOV (Movement Detection);
    • IHB (Irregular Heart Beat);
    • Data Status (to_import, failed, uploaded);
    • Unix Time (based on Date and Time);
    • Email User (used account for Garmin Connect);
    • Upload Date and Upload Time (to Garmin Connect);
    • Difference Time (between measuring and uploading).
  • Supports 2 users from Omron device, we can connect 2 accounts with Garmin Connect.

1.3. User module:

  • Enables configuration of all parameters related to integration Miscale and Omron;
  • Provides export Oauth1 and Oauth2 tokens of your account from Garmin Connect (MFA/2FA support).

2. How does this work

  • Miscale and Omron modules can be activated individually or run together:
$ /home/robert/export2garmin-master/import_data.sh
Export 2 Garmin Connect v1.4 (import_data.sh)

18.07.2024-16:56:01 MISCALE * Module is on
18.07.2024-16:56:01 MISCALE * miscale_backup.csv file exists, check if temp.log exists
18.07.2024-16:56:01 MISCALE * temp.log file exists, checking for new data
18.07.2024-16:56:01 MISCALE * Importing data from a BLE scanner
18.07.2024-16:56:06 MISCALE * Saving import 1721314589 to miscale_backup.csv file
18.07.2024-16:56:07 MISCALE * Calculating data from import 1721314589, upload to Garmin Connect
18.07.2024-16:56:07 MISCALE * Data upload to Garmin Connect is complete
18.07.2024-16:56:07 MISCALE * Saving calculated data from import 1721314589 to miscale_backup.csv file
18.07.2024-16:56:07 OMRON * Module is on
18.07.2024-16:56:07 OMRON * omron_backup.csv file exists, check if temp.log exists
18.07.2024-16:56:07 OMRON * temp.log file exists, checking for new data
18.07.2024-16:56:07 OMRON * Importing data from a BLE scanner
18.07.2024-16:56:39 OMRON * Prepare data for omron_backup.csv file
18.07.2024-16:56:40 OMRON * Data from import 1721314552 upload to Garmin Connect
18.07.2024-16:56:40 OMRON * Data upload to Garmin Connect is complete
18.07.2024-16:56:40 OMRON * Saving calculated data from import 1721314552 to omron_backup.csv file
  • Synchronization diagram from Export 2 to Garmin Connect:

alt text

2.1. Miscale module | BLE VERSION

  • After weighing, Mi Body Composition Scale 2 is active for 15 minutes on bluetooth transmission;
  • USB Bluetooth adapter or internal module scans BLE devices for 10 seconds to acquire data from scale;
  • Body weight and impedance data on server are appropriately processed by scripts;
  • Processed data are sent to Garmin Connect;
  • Raw and calculated data from scale is backed up on server in miscale_backup.csv file.

Select your platform and go to instructions:

2.2. Miscale module | ESP32 VERSION

  • After weighing, Mi Body Composition Scale 2 is active for 15 minutes on bluetooth transmission;
  • ESP32 module operates in a deep sleep and wakes up every 7 minutes, scans BLE devices for 10 seconds to acquire data from scale, process can be started immediately via reset button;
  • ESP32 module sends acquired data via MQTT protocol to MQTT broker installed on server;
  • Body weight and impedance data on server are appropriately processed by scripts;
  • Processed data are sent to Garmin Connect;
  • Raw and calculated data from scale is backed up on server in miscale_backup.csv file.

Select your platform and go to instructions:

2.3. Omron module | BLE VERSION

  • After measuring blood pressure, Omron allows you to download measurement data once;
  • USB bluetooth adapter or internal module scans BLE devices for 10 seconds to acquire data from blood pressure device (downloading data can take about 1 minute);
  • Pressure measurement data are appropriately processed by scripts on server;
  • Processed data are sent to Garmin Connect;
  • Raw and calculated data from device is backed up on server in omron_backup.csv file.

Select your platform and go to instructions:

If you like my work, you can buy me a coffee

Buy Me A Coffee

export2garmin's People

Contributors

robertwojtowicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

export2garmin's Issues

bodycomposition: Exec format error

Hi Robert,
thank you for your great project.
it was exactly what i was looking for.

There is only one problem when trying to process the data before it is uploaded.

sudo ./import_ble.sh
Mi Body Composition Scale 2 Garmin Connect v3.0 (import_ble.sh)

Data backup file exists, checking for new data
Importing and calculating data to upload
Data upload to Garmin Connect is complete

(I have to start it via sudo otherwise there are problems to execute/start btle.py)

but when checking the log:

cat temp.log sh: 1: /home/pi/miscale2garmin-3.0/bodycomposition: Exec format error Mi Body Composition Scale 2 Garmin Connect v3.0 (export_garmin.py) Processed file: 1644148841.tlog

If you need more information let me know.

Thanks for your effort and your time.
Cheers
Pascal

Raspberry Pi on Wi-Fi

Hi,
It seems to me that there is an issue with the program's operation when the Raspberry Pi is running on Wi-Fi. Running import_data.sh as a process causes Wi-Fi problems. The Raspberry Pi continuously disconnects and reconnects to Wi-Fi. The error on the router is "DC:A6:32:66:12:88@wlan1: disconnected, extensive data loss, signal strength -66". Naturally, the data does not import into Garmin Connect. It works fine with a wired connection.
BR Zbigniew

any way to skip a certain user?

Hi, I use miscale together with my wife. She does not have garmin account so I don't need to upload her data therefore I have not added her to the users array. But her data appears in the backup.csv files and once there it stops the upload of any further readings saying "There is no user with the given weight...". Is there anyway to modify the script so it just skips her data based on max weight?

Syntax error on scanner_ble.py

I successfully used one of the previous versions - v4.8 of the scanner_ble_py file. Unfortunately, with the new one I am getting a syntax error

    Unix_time = int(dt.timestamp(dt.strptime(f"{int((data[3] << 8) | data[2])},{int(data[4])},{int(data[5])},{int(data[6])},{int(data[7])},{int(data[8])}", "%Y,%m,%d,%H,%M,%S")))
                                                                                                                                                         ^
SyntaxError: invalid syntax

also

During preparation

sudo setcap 'cap_net_raw,cap_net_admin+eip' /usr/local/lib/python3.9/dist-packages/bluepy/bluepy-helper`

gives me an error

Failed to set capabilities on file `/usr/local/lib/python3.9/dist-packages/bluepy/bluepy-helper' (Invalid argument)
The value of the capability argument is not allowed for a file. Or the file is not a regular (non-symlink) file

Issue with upload to garmin

As the tittle sugeest....i get the error
sh: 1: /home/pi/miscale2garmin-3.0/bodycomposition: Exec format error

Any suggestions on what could be the issue?

There is no new data to upload to Garmin Connect

Hi
Something goes wrong. I didn`t get where is a problem.

ESP32 working well
10:00:30.999 -> * Starting BLE scan:
10:00:31.739 -> BLE device found with address: 64:df:e8:..... non-target device
10:00:31.784 -> BLE device found with address: 6c:88:26:....., non-target device
10:00:31.923 -> BLE device found with address: ec:fa:5c:...., non-target device
10:00:32.616 -> BLE device found with address: c7:dd:15:..... <= target device
10:00:32.616 -> * Reading BLE data complete, finished BLE scan
10:00:33.351 -> * Connecting to WiFi: connected
10:00:35.886 -> IP address: 192.168.31.231
10:00:35.886 -> * Connecting to MQTT: connected
10:00:36.766 -> * Publishing MQTT data: 82.00;331;1660204397;to_import;2022-8-11 9:53:17;4.09;90
10:00:36.766 -> * Waiting for next scan, going to sleep

But when I start import_data.sh it doesn't send anything to Garmin.

  • Creating backup.csv file, checking for new data
  • Importing data from MQTT broker
  • (here I added to the log readed var)
    read_scale: 82.00;331;1660204397;to_import;2022-8-11 9:53:17;4.09;90
  • -2850 s time difference, synchronize date and time scale
  • There is no new data to upload to Garmin Connect

When I start it again - changind time difference all time
backup.csv is empty.

Raspberry Pi Bluetooth deamon missplaced

manuals:
4.1.1. Preparing operating system
sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service:
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap --experimental
--> ExecStart=/usr/libexec/bluetooth/bluetoothd --noplugin=sap --experimental

Docker image

Hi,
Can we run this code as Docker container ?

Works only white standing + potential workaround

Hi, I have a problem to make scripts work properly. Reading complete data from scale works only while I'm standing on it. If not, hasImpedance variable always results in 0, so i get incomplete data as output and therefore, upload to garmin connect fails.

I've noticed that if i turn of "weigh small object" option in dedicated app, i can get proper results almost every time event when i'm not standing on scale anymore. I wonder if anyone experienced this bahavior. It's weird because app gets results everytime, despite of selected options.

I'm using scripts with rPi4 if that matters.

Support for pounds?

Hi Robert, since weightlogger no longer works with Garmin after 2fA, I am using miscale2garmin and it works great. Thank you. Entering weight in kgs adds another step (conversion in a calculator) which though trivial, is needed each and every time.

Are reason you would not consider adding weight entry in pounds?

thanks, mike

Changed BT USB device and scan is empty

``Hello Robert,
regarding to your advice I changed BT adapter to EDUP EP-B3536 based on RTL8761B chipset.
previously my adapter was able to scan but I had problem with range - my bathroom is next to room when I have PC with miscale2garmin software - there's one ytong wall between.
My USB port is passed through from proxmox to VM with Debian 11.
I installed firmware was you stated and even tried firmware from Debian Repo (backports non-free)
when i run scan nothing shows:
`root@miscale:/opt/miscale2garmin-5# python3 ./scanner_ble.py
Mi Body Composition Scale 2 Garmin Connect v5.3 (scanner_ble.py)

  • Starting BLE scan:
  • Finished BLE scan
    root@miscale:/opt/miscale2garmin-5#
    but bluetooth shows adapter:root@miscale:/opt/miscale2garmin-5# bluetoothctl
    Agent registered
    [CHG] Controller 00:E0:4C:2F:1F:2C Pairable: yes
    [bluetooth]#
    `
    can you please help me with diagnostics?
    reagrds,
    Maciek

Bluetooth adapter interface problem

There were some problems with my bluetooth adapter interface during installation. In your code, you are using the hci0 interface of the bluetooth adapter by default.
This can be problematic for people who have multiple bluetooth adapters.

I just had to add a parameter to the Scanner function in the scanner_ble.py file - line 50 (in my case the bluetooth adapter is on the hci1 interface):

scanner = btle.Scanner(1).

I suggest adding this information to the README. It may help many people :)

Thanks!

Help for Error "Reading BLE data incomplete, finished BLE scan"

Hello Robert,
sorry, my english is not good, this is google translated.
I came across your project more by accident and that would be perfect for me, I have a Garmin fenix 6 for a short time and have had a Mi Scale 2 for a while (2020), now merging the values of the scale with Garmin Connect without going through others Apps would be perfect. But I have absolutely no idea about Arduino. I've now bought the hardware for your project and managed to get the program onto the ESP32 Pro. Aunt Google also helped me to "decrypt" the cryptic letters in the serial monitor (baud rate must be set to 115200) but now I can't go any further โ˜น.
It scans and finds the scale but aborts with "Reading BLE data incomplete, finished BLE scan"

22:34:31.685 -> ets Jul 29 2019 12:21:46
22:34:31.685 ->
22:34:31.685 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
22:34:31.685 -> configsip:0, SPIWP:0xee
22:34:31.685 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:34:31.685 -> mode:DIO, clock div:1
22:34:31.685 -> load:0x3fff0018,len:4
22:34:31.685 -> load:0x3fff001c,len:1044
22:34:31.685 -> load:0x40078000,len:8896
22:34:31.685 -> load:0x40080400,len:5816
22:34:31.685 -> entry 0x400806ac
22:34:32.473 ->
22:34:32.473 -> Mi Body Composition Scale 2 Garmin Connect v3.0 (esp32.ino)
22:34:32.473 ->
22:34:32.473 -> * Starting BLE scan:
22:34:33.816 -> BLE device found with address: 64:1c:b0:88:e5:94, non-target device
22:34:33.955 -> BLE device found with address: 6d:3d:15:07:65:75, non-target device
22:34:34.049 -> BLE device found with address: 05:47:e9:3c:a8:46, non-target device
22:34:34.141 -> BLE device found with address: 5c:ca:d3:70:f6:c8 <= target device
22:34:39.111 -> * Reading BLE data incomplete, finished BLE scan
22:34:39.111 -> * Waiting for next scan, going to sleep

What can be the reason, where can I start?

Scale timestamp is always UTC

Hi Robert,
I would like to report time zone mismatch between scale and OS (raspberry OS in my case).
I carefully followed your instructions how to set correct date and time for scale, but it didn't work for me. No matter what I do, it still returns UTC time, so time doesn't match for me. My local time is UTC+1 summertime so it's 2 hours difference. I was forced to modify import_data.sh and change threshold value from 1200s to 8400s (1200 + 7200(2 hours difference between scale and local time)).
I'm not sure if different account for Zepp Life (I use Mi account currently) will fix/change time. I can try this.
Anyway, I know how hard is to work in environment with multiple time zones. In such cases where scale doesn't respect local time it would be handy to have feature to apply some kind of offset automatically (like I did manually) by prompting user if he wants to apply time difference offset.

Can ESP be hidden inside miscale?

I still never worked with ESP and Arduino, but already bought the WeMos d1 Mini Module.

I have a body composition scales, and am wondering if it's possible to hide the module inside.

Batteries are ok, they have enough juice. What if to connect module to batteries, but to send in the deep sleep forever. But when the last segment of body composition bar lights up, to load module, connect it to Wifi, query the scales by BLE, send the data, and then to go back to sleep?

Or it's just a plain dumb idea of the battery killer?

Segmentation Fault

Hello, I am hoping for some pointers on how I could further troubleshoot this issue I am experiencing: Here is the temp.log after running import_data.sh

jtuck@raspberrypi-scale:~/miscale2garmin-5 $ cat temp.log
Segmentation fault

Mi Body Composition Scale 2 Garmin Connect v5.9 (export_garmin.py)

* Import data: 1700448665;89.5;450
* Calculated data: 19.11.2023;21:51;89.5;25.6;25.0;63.7;3.4;51.5;3;16;31;450;<some_username>@<some_domain>.com;19.11.2023;21:51

I scan run the scanner_ble.py manually and it runs as expected. Running import_data.sh seems to work providing the following output, but I can't find any results in Garmin that it actually uploaded and checking the temp.log is where I found the "Segmentation Fault"

jtuck@raspberrypi-scale:~/miscale2garmin-5 $ ./import_data.sh
Mi Body Composition Scale 2 Garmin Connect v5.9 (import_data.sh)

* backup.csv file exists, check if temp.log exists
* temp.log file exists, checking for new data
* Importing data from a BLE scanner
* Saving import 1700448665 to backup.csv file
* Calculating data from import 1700448665, upload to Garmin Connect
* Data upload to Garmin Connect is complete
* Saving calculated data from import 1700448665 to backup.csv file

Any ideas for how I can get to the bottom of my issue?

Import successful but nothing on Garmin Connect

Hi, first of all, thanks for this project, seems like a life saver for Garmin users.
I've recenetly setup miscale2garmin an I'm strugglin to get data on Garmin connect, everything seems fine. but nothing appears on Garmin Connect:

* temp.log file exists, checking for new data
* Importing data from a BLE scanner
* Saving import 1674745428 to backup.csv file
* Calculating data from import 1674745428, upload to Garmin Connect
* Data upload to Garmin Connect is complete
* Saving calculated data from import 1674745428 to backup.csv file```
The only strange thing I've notice is some really big offset, that I bypass by setting `offset: -11000`

Backup file seems fine:

uploaded;1674744927;26.01.2023;11:55;83.2;0.0;26.9;26.6;57.9;3.1;50.3;2;17;38;432;santiago@***.com;26.01.2023;11:59;220
uploaded;1674745428;26.01.2023;12:03;83.2;0.0;26.9;26.6;57.9;3.1;50.3;2;17;38;434;santiago@***.com;26.01.2023;12:07;204
uploaded;1674745503;26.01.2023;12:05;83.0;-0.2;26.8;26.5;57.9;3.1;50.4;2;17;38;434;santiago@***.com;26.01.2023;12:08;205

What could be failing ?

miscale2garmin via Home Assistant

I am collecting the data from the Mi Scale 2 via Mqtt with Home Assistant (https://github.com/dckiller51/bodymiscale). Could that data be used to send it to Garmin Connect? If I understood how python files work, I think it would be easy to do, but it's beyond me. External projects can be integrated into Home Assistant via HACS. In fact, I see that your project is based on one of the projects that collect the data from the scale and send it to the Home Assistant. Could your project be integrated into Home Assistant? Sorry if I said nonsense. Thanks in advance.

* Reading BLE data incomplete, finished BLE scan

Hi, I have set up all things according to the guide, but the "scanner_ble.py" gets always "Reading BLE data incomplete". I downloaded the new version 4.8 but this still gets the same message.

stuck on "Importing data from BLE device"

Hi Robert,
I just managed to install VM with Debian 11 / Baseus BA04 BT 5.1 usb dongle
and scan works perfectly:
`root@miscale:/opt/miscale2garmin-4# python3 ./scanner_ble.py
Mi Body Composition Scale 2 Garmin Connect v4.4 (scanner_ble.py)

  • Starting BLE scan:
    BLE device found with address: 0c:95:41:15:9a:df <= target device
  • Reading BLE data complete, finished BLE scan`

but ./import_data.sh
is stuck on:
`root@miscale:/opt/miscale2garmin-4# ./import_data.sh
Mi Body Composition Scale 2 Garmin Connect v4.6 (import_data.sh)

  • Backup.csv file exists, checking for new data
  • Importing data from BLE device`

Please help me how to solve this
Regards,
Maciek

ESP32 program size is bigger than available memory

Hello,

I tried to build ESP32 project and I am unable to do it because I getting error of compiled program being bigger than available memory.

Flash: [==========] 111.8% (used 1465053 bytes from 1310720 bytes)

Maybe at least author can post exact versions of libraries? Because I used the newest one available.

Missing BT device when scanning stopped.

First of all amazing project.

Some feedback after testing it. I had to recompile bodycomposition because I'm using RPi with arm64. I can provide the 64-bit version if you would wish to add it. I also had some problems with BLE scanning. Turns out when the scanning was manually stopped (instead of the timeout) it wouldn't add the last device detected (which in that case would be the MiScale). For now I just removed that line from the code and reduced scanning time to 20sec. Not sure why that happens...

Home Assistant

Is it a way to use it on Home Assistant installed on Proxmox PVE?

AWK command and the resulting data/backup.csv

Hi, I'm doing the modification for direct parsing parameters from mi scale and posting them to Garmin connect.
Could you please provide:

  1. the result of doing the read_MQTT=`mosquitto_sub -h $host -t $locpath -u $user -P $passwd -C 1 (without awk addition)
  2. data/backup.csv file example you receive as a result of performing the shell script?

That would greatly help me.

Scanner_ble.py - can't find MiScale

I have Mi Body Composition Scale 2.

After setup scanner_ble.py I occured interesting thing.

sudo python3 scanner_ble.py 
Mi Body Composition Scale 2 Garmin Connect v5.1 (scanner_ble.py)
* Starting BLE scan:
  BLE device found with address: 4e:54:53:69:36:bf, non-target device
  BLE device found with address: 33:33:8e:fc:99:6e, non-target device
  BLE device found with address: 6f:a4:ef:19:29:ad, non-target device
  BLE device found with address: 4b:49:ce:9d:71:32, non-target device
  BLE device found with address: 18:ee:5f:47:ce:b3, non-target device
  BLE device found with address: 7b:28:76:8e:27:bf, non-target device
  BLE device found with address: 8c:79:f5:a4:b0:0b, non-target device
  BLE device found with address: 14:bb:6e:11:0b:25, non-target device
  BLE device found with address: 5a:73:36:59:9a:13, non-target device
  BLE device found with address: 08:28:d0:25:74:f8, non-target device
  BLE device found with address: d0:70:d8:05:45:fc, non-target device
  BLE device found with address: ec:df:ed:df:cf:ff, non-target device
  BLE device found with address: 27:f5:5c:df:79:e7, non-target device
  BLE device found with address: 56:23:4c:a9:43:5d, non-target device
  BLE device found with address: f1:08:39:1a:0a:7e, non-target device
  BLE device found with address: 0c:bb:a0:de:60:8b, non-target device
  BLE device found with address: e0:1e:cb:af:d0:04, non-target device
  BLE device found with address: f4:fe:fb:57:6b:9f, non-target device
  BLE device found with address: 61:08:23:7e:b2:94, non-target device
  BLE device found with address: 5c:c1:d7:40:d3:4f, non-target device
* Finished BLE scan

Bluetooth Mac adress of the scale from application is: e8:cb:ed:5e:8f:df.

When I scan bluetooth devices via bluetoothctl you can see there is a MIBFS device with other address:

michal@homeserver:~/Documents/miscale2garmin-5$ bluetoothctl
Agent registered
[CHG] Controller 00:1F:E1:C1:55:21 Pairable: yes
[CHG] Controller 04:7F:0E:17:A5:30 Pairable: yes
[bluetooth]# scanon
Invalid command in menu main: scanon

Use "help" for a list of available commands in a menu.
Use "menu <submenu>" if you want to enter any submenu.
Use "back" if you want to return to menu main.
[bluetooth]# scan on
Discovery started
[CHG] Controller 04:7F:0E:17:A5:30 Discovering: yes
[CHG] Device 5E:D8:34:D5:93:2B RSSI: -96
[CHG] Device 5E:D8:34:D5:93:2B TxPower: 6
[CHG] Device 5E:D8:34:D5:93:2B ManufacturerData Key: 0x004c
[CHG] Device 5E:D8:34:D5:93:2B ManufacturerData Value:
  10 05 76 1c d9 96 6d                             ..v...m         
[CHG] Device 76:86:61:64:5A:7F RSSI: -94
[CHG] Device 76:86:61:64:5A:7F TxPower: 12
[CHG] Device 76:86:61:64:5A:7F ManufacturerData Key: 0x004c
[CHG] Device 76:86:61:64:5A:7F ManufacturerData Value:
  10 07 1f 1f 26 a0 fa 3e 38                       ....&..>8       
[CHG] Device 4A:DD:D3:18:C8:30 RSSI: -96
[CHG] Device 4A:DD:D3:18:C8:30 TxPower: 8
[CHG] Device 4A:DD:D3:18:C8:30 ManufacturerData Key: 0x004c
[CHG] Device 4A:DD:D3:18:C8:30 ManufacturerData Value:
  10 05 34 18 cc 17 0e                             ..4....         
[CHG] Device EC:DF:ED:DF:CF:FF RSSI: -96
[CHG] Device EC:DF:ED:DF:CF:FF UUIDs: 0000181b-0000-1000-8000-00805f9b34fb
[CHG] Device EC:DF:ED:DF:CF:FF ManufacturerData Key: 0x0157
[CHG] Device EC:DF:ED:DF:CF:FF ManufacturerData Value:
  e8 cb ed 5e 8f df                                ...^..          

It seems like the scale is returning correct mac address in Manufacturer Data Value. When I enter ec:df:ed:df:cf:ff in scanner_ble.py, ofcourse it returns valid target device, but after run import_data.sh i get this:

michal@homeserver:~/Documents/miscale2garmin-5$ sudo ./import_data.sh 
Mi Body Composition Scale 2 Garmin Connect v5.1 (import_data.sh)

* Backup.csv file exists, checking for new data
* Importing data from a BLE scanner
* No BLE data from scale or incomplete, check BLE scanner
* There is no new data to upload to Garmin Connect

Same with the mac address from the application.

5.3 on Raspberry Pi3 Debian 64bit

I installed miscale2garmin-5(.2) on with Raspberry Pi OS 32bit and everything works fine.

I installed the latest version of miscale2garmin-5(.3) on another Raspberry Pi4 with 64bit OS, but here I have problems.

pi@raspberrypi:~ $ /home/pi/miscale2garmin-5/import_data.sh
Mi Body Composition Scale 2 Garmin Connect v5.3 (import_data.sh)

* backup.csv file exists, check if temp.log exists
* temp.log file exists, checking for new data
* Importing data from a BLE scanner
* Saving import 1673959399 to backup.csv file
/home/pi/miscale2garmin-5/import_data.sh: riga 99: /home/pi/miscale2garmin-5/backup.csv: Permesso negato
/home/pi/miscale2garmin-5/import_data.sh: riga 111: /home/pi/miscale2garmin-5/temp.log: Permesso negato
* Calculating data from import 1673959151, upload to Garmin Connect
* Upload to Garmin Connect has failed, check temp.log for error details
sed: espressione -e #1, carattere 40: comando `s' non terminato

temp.log

sh: 1: /home/pi/miscale2garmin-5/bodycomposition: Exec format error

Mi Body Composition Scale 2 Garmin Connect v5.3 (export_garmin.py)

* Import data: 1673959151;74.9;493
* Calculated data: 17.01.2023;13:39;74.9;25.0;23.9;54.1;2.9;52.2;2;14;36;493;[email protected];17.01.2023;13:47

Can this be run on linux server directly?

Hi, Robert,
looks like great work, but have a question.
I have a linux ubuntu server, it has Bluetooth built-in. Can this be somehow run on a linux machine without the need for the hardware project? I even have an mqtt server installed there, so would just appreciate some way to use the built-in BT to query the scale without building that chargeable external hardware box.
PS> I'm looking for a way to export the body parameters to garmin connect.

Strange syntax error in import_data.sh

I am already at the final stage. The scanner_ble.py works and finds the scale with the entered address, as well as the basic measurement data. When I want to run import_data.sh I get the message

python3 import_data.sh
File "import_data.sh", line 13
echo "Mi Body Composition Scale 2 Garmin Connect v4.7 (import_data.sh)"
^
SyntaxError: invalid syntax

Could this be due to an older version of python, ora raspbian? Currently I can only test the operation on this hardware.

Trying to get your script working on Raspberry Pi 4

Hi :)

That's a great idea to export Xiaomi data to Garmin. I'm using Fenix 6 Pro so I prefer to store all my data in Garmin connect app.

I'm using Raspberry Pi 4 with latest Debian Bullseye, everything is updated :) Scale model is exact the same - XMTZC05HM. Firmware version of scale shown in Xiaomi app is 1.0.0.12.

I've run into few problems:

  1. bluetooth.service had a bit different path of ExecStart - ExecStart=/usr/libexec/bluetooth/bluetoothd so i just added "--noplugin=sap". There seems no bluetooth folder in lib directory, it exists only in libexec.
  2. I used armv6 version of bodycomposition (i'm not sure it's the right one).
  3. I can't run any script without sudo.
  4. scanner_ble.py reads data only when I'm standing on the scale, I thought it should work 15 minutes from using it (maybe I misunderstood your readme :)). The data it showed into console was: 88.65;466;1646906408;2022-3-10 11:0:8
  5. export_garmin.py shows that there is no user with the given weight. I've edited the script with maxweight 95 and minweight 75 so it should work.
  6. import_ble.sh shows No BLE data from scale or incomplete but I think that's because export_garmin.py isn't working.

Please don't mind if some of the problems are obvious - I'm a beginner linux user and a beginner java programmer so I may do something wrong... :)

New faster way

There is more faster and powerfull metode.
No nead masquitto and mqtt broker.
Use ESPhome rot esp32 with native component xiaomi_miscale.
The other way same as in your topic.
Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.