yashsingh1/xdaforums huggingface dataset:
[Amazfit] pieralle:
I' m testion on android with qpython and it stops on the first line

/data/user/0/org.qpython.qpy/files/bin/qpython-android5.sh "/storage/emulated/0/qpython/scripts/amazfit_exporter.py" && exit

dragon:/ $ /data/user/0/org.qpython.qpy/files/bin/qpython-android5.sh "/storage/emulated/0/qpython/scripts/amazfit_exporter.py" && exit

File "/storage/emulated/0/qpython/scripts/amazfit_exporter.py", line 5

<!DOCTYPE html PUBLIC>

^

SyntaxError: invalid syntax

1|dragon:/ $

I'm new to python so heve you any suggestion?
[Amazfit] pieralle:
Same problem with python for windows, please help :(
[Amazfit] pieralle:
Ok, my fault the problem was created downloading from GITHUB !!!!
[Amazfit] DAVID_EST:
Could anybody send me its \data\data\com.xiaomi.hm.health\databases folder? with this i would be able to make a gpx exporter from the phone
[Amazfit] lowfass:
If you tell me how and you think i am able to do it i will be glad to help you again. you can contact me via facebook and i can do it in the evening today if nobody else cant help you.
[Amazfit] DAVID_EST:
Well i have been able to access my db file from mifit and i think that i could create android app that FOR ROOTED PHONES would allow to export all mifit app synced tracks to strava endomondo and others.

I will try to finish first the python app to from a PC upload data to these services and then I will start with this
[Amazfit] luc0_0:
Yes ! It would be perfect.
[Amazfit] alexinc:
i would really love to, but after opening those db-files with DB Browser for sqlite i was kind of overwhelmed... :eek: getting my sleep and step tracking back into watch seems to be a dream for now, but theoretically it should be possible i guess by just copying the right data-structure into its belonging db as those data is available in db for mifit app!?
[Amazfit] pieralle:
Hello, here is a copy of the folder; as you know the phone must be rooted to access this folder.

There is another discussion were was created a script to export the data from mifit

https://xdaforums.com/general/accessories/xiaomi-mi-band-data-extraction-t3019156
[Amazfit] vincenzo79:
Sync with Strava
[Amazfit] DAVID_EST:
It is a big pleasure for me to show here mi first Android App ever. It will allow you to export to GPX EVERY track from xiaomi amazfit that is synced with mifit . At this moment ROOT access is required in order to copy the DB from mifit app to this app: https://goo.gl/Jb8zAX

---------- Post added at 10:13 PM ---------- Previous post was at 10:10 PM ----------
[Amazfit] Beleriand:
Well that exports my oldest two tracklogs and then quits with a division by zero error.

And it is *.tcx not *.gpx which my OSM mapping software will not use without converting it. :(
[Amazfit] Beleriand:
Recorded today's walk with different options and i can confirm that trail running is type 3 and cycling is type 5.

Both were not exported by the script.

Indoor running and indoor cycling do not need GPX export as i am quite sure they do not record location data at all.
[Amazfit] pieralle:
1st DAVID_EST thankyou for your work, I have created this topic because I the sync with other apps is one issue of this fantastic smartwach, and you are doing a fantastic job!

Today I made a test with you app on a non-rooted phone (and obviously it closes with error) and with a rooted phone, and it works well; I have created the gpx file of my last run and imported in runtastic and it works well. As said by others, only the data containing gps information are now managed, if I try to export a treademill workout the application closes with error.
[Amazfit] Probus Maximus:
Division by Zero Error....

Hello. I am the maintainer of the forked repo. I have fixed the division by zero error (caused by activity that has no recorded steps or stopped in the middle without saving). The reason why the format was changed to TCX is that the original GPX format does not have the ability to record indoor sport activities like running on treadmill.

You can try to the new version and give me feedback on any issues...
[Amazfit] Beleriand:
Works fine but i need GPX. ;)
[Amazfit] dpenevdpenev:
I have tried https://github.com/citsai/amazfit_exporter but I get no messages nor any results for my sport_data.db.

Any idea?

My environment, python version and sport_data.db available if someone would like to test.

I should have about 10 running sessions, two are trail running.
[Amazfit] Probus Maximus:
If you want to send me your sport_data.db data and I can test to see why it would not give any results. One reason without looking at it might be the way that I check for time of last sync - it will only sync the activities after the last time it was synced (unless you enter "0" to sync everything from the beginning).
[Amazfit] dpenevdpenev:
Hi,

I sent you a private message

Dimitar
[Amazfit] Probus Maximus:
Got it. I run the script and I was able to extract all of your activities without errors.
[Amazfit] dpenevdpenev:
Hmm strange, probably I am missing something.

What I get in the Windows 10 shell

python.exe .\amazfit_exporter.py ..\data\sport_data.db .\

seems to get nothing in the current directory.

PS C:\projects\amazfit_exporter\data> python --version

Python 2.7.11

Thanks

Dimitar
[Amazfit] Probus Maximus:
I think I saw an error in your command: You are running the wrong script.

python.exe .\amazfit_exporter_cli.py ..\data\sport_data.db .\
[Amazfit] dpenevdpenev:
Oh sorry about that!

I have managed to export my activities in Strava.

All seems to work fine.

Do you know if Strava can show the elevation from the watch?

It seems it gets it from the map.

Thanks!
[Amazfit] Probus Maximus:
Strava does show the elevation from the watch - I put the elevation data from the barometric sensor on the watch in the TCX file.
[Amazfit] dpenevdpenev:
Hi Probus Maximus,

Well I am not sure. See the attached picture.

Gray profile in Strava and the Altitude extracted from the TCX file.

The Strava profile looks much more detailed and smooth.

But I am actually surprised how accurate the watch Altitude for this session looks.

(Altitude error seems to be below 10m)

I should test this for some other activity

Regards

Dimitar
[Amazfit] dpenevdpenev:
Another pretty good match . Either Watch altimeter/GPS is good for Altitude

or indeed Strava shows the watch altidude data 'enhanced' somehow.

To me it makes more sense that Strava would take the 'real' altitude from the google map.

Hmm, the destination of this trail was a hut which as per the description should be at 1450m above the sea.

Аs per https://www.daftlogic.com (google map) the hut is at 1340m so I think actually Strava is getting the Altitude from the map.

Thanks

Dimitar
[Amazfit] Probus Maximus:
Yes. I think you are correct in that Strava uses the GPS coordinates to get the altitude (which is too bad since sometimes the map data can have errors in it). Usually, the barometer sensor is more accurate than the map coordinates and most high end GPS sport watches have it on board.
[Amazfit] Beleriand:
It would make sense to provide the altitude from a digital elevation model as long as there is no information in the tracklog or if the information seems to be totally off like when recording in "running" or "walking" where the first trackpoins are at -20000 meters but if you recorded your track as "trail running" the elevation data should be fine and not replaced by a coarse 3d model of the earth.

A DEM is quite okay but it can not show every detail of cliffs, towers and peaks. just compare the two images, one with real elevation data from the watch and one from geonames.org
[Amazfit] Probus Maximus:
Regarding the elevation data - I think I found out how to get Strava to use the "more accurate" watch barometric sensor data. Here is the comparison between using the prior GPS satellite map data and watch barometric sensor data.

The script has been updated to reflect this...
[Amazfit] dpenevdpenev:
Hi Probus Maximus,

Can you share the secret ?

I am actually not sure if the watch altimeter is more reliable than the DEM.

Would be nice if Strava has an option to select from.

Dimitar
[Amazfit] dpenevdpenev:
Hello,

My second syncing was problematic

PS C:\projects\amazfit_exporter\src> python.exe .\amazfit_exporter_cli.py ..\data\sport_data.db .\

Traceback (most recent call last):

File ".\amazfit_exporter_cli.py", line 16, in <module>

lstupdtime = int(lstupd_f.read())

ValueError: invalid literal for int() with base 10: '1.48640280241e+12'

in the lstupd.txt I have 1.48640280241e+12

I had to sync everything to make it working.
[Amazfit] Probus Maximus:
Hmm... Somehow you are saving the "time of last sync" in an exponential/scientific format rather than a straight integer format (i.e.: 1486402024100) . It must be in your default Python setting that is doing it.

I will see how I can modify my problem to force it to save in an integer format.

Edit - I think I fixed it by forcing it into an integer value. You can try the new script again and hopefully you will not have the error (you will need to enter 0 again or go to the data directory and delete the lstupd.txt file).
[Amazfit] dpenevdpenev:
Thank you Probus Maximus!

I will test it next time I run.
[Amazfit] nikit05:
Guys, I did not read all the thread, probably below is off-topic, but I am using Chineese version of watch (1.2.6c) and now can easily export gps-tracks to both Strava and Mifit.

Shortly what to be done:

1. a. Go to Xiaomi account settings and set link with Facebook account. b. Install Strava on the phone, log in under Facebook account. c. Install latest MiFit from MiStore, log in under Xiaomi account

2. Now Install old version (1.1.5) of Amazfit watch app from MiStore (I can attach this apk here if required). Log in with Xiaomi account, then run MiFit and link it with Amazfit watch. Ensure that steps and trainjngs sync to MiFit.

3. Upgrade Amazfit watch app via Play Market to the version 1.1.7.1 (it supports Strava). Open app, log in to Facebook if it requests it

4. Upgrade Amazfit App to the latest version from Mi Store (now it is 1.2.1).

As result:

When you go to Activity Sync and press Exsercise Data - it syncs all trainings to Mifit, and trainings with gps-tracking - also to Strava

This works for me.

So I keep steps and sleep data in Mifit.

I can export traing data to Strava and then to Endomondo (and many other apps if required)
[Amazfit] Probus Maximus:
Yes. That is the same setup that I am doing and is working fine. However, many people here are still having problems (for various reasons) in getting this to work with the above procedure. Also, the current Strava sync using the Google Playstore Amazfit app do not sync the indoor activities (treadmill, stationary bicycling) with the detailed HR and pace information to Strava - that is the main reason that forced me to write a script to import my indoor activities "properly" to Strava even though I do not have problem getting MiFit and Strava to work.
[Amazfit] nikit05:
Added the old mi store Amazfit app version 1.1.5 to my post above. Sorry, did not find the way of editing post itself from phone xda app
[Amazfit] dpenevdpenev:
Thank you!
[Amazfit] 1immortal:
i have some weird issue:

tracked my ride with Strava's app and with the watch, and exported the activity with the Android app you've created.

everything is correct and right, except the max speed. with the Strava app by my phone, and with the watch, there is some 20 Km/h difference.

is it Strava related or its some incorrect export/import ?
[Amazfit] icekrim:
HI

I'm trying to add some lost training to strava i've save a sport_data.db files before resetting my watch, i can now extract the GPX files thanks to amazfit_exporter usefull tool!

however all my files can be imported inside strava or runtastic!(it write me an error : "Time information is missing from file. More Information.")

Does anyone can help me on this issue or test my file to check if he get the same error? find below the googledrive link for my sport.db file

https://drive.google.com/open?id=0B-3qiTRqPXHrMEN6dHU3T3EzNXM

thanks
[Amazfit] barciol:
Hi guys!

I have problem. How to connect Amazfit with Endomondo? or sync Mifit with Endomondo? Apps like SyncMyTrack don't work properly.

This is very important in these smart watch.

Please, help me.
[Amazfit] peter_find:
Hi all,

In the table "location_data", is stored pressure and altitude.

Does anyone knows the formula to convert pressure to altitude.

I've read dozens of sites, but I never found a formula that matches the watch calculations.

Thanks
[Amazfit] passosk58:
I use Mifit Exporter but I have a problema...all of activities (in GPX) that import from Mifit with Mifit_Exporter have 1 hour of delay that the real hour in activity. Can I fix this?? Thank you
[Amazfit] icekrim:
UP!:(
[Amazfit] Puzzlehead:
I am edit the phyton files and add time zone and create batch for export to gpx or tcx.

DB from Huami you must copy to DB directory.

drive.google.com/drive/folders/0ByaySoSDeGn2S0JndjE4WE8tOUU
[Amazfit] MrSpeedy1:
Hello,

I have an AmazFit CN A1602 with PaceFit 1.2.15. On my iPhone I use the AmazFit Watch App and Mi Fit App. The syncronisation with Strava does not work, in the MiFit App Strava is not displayed. I would like to copy my data to Runtastic. Can someone help me?

Thank you
[Amazfit] Puzzlehead:
In your db not location data for sport 1489180759000 (GMT: Fri, 10 Mar 2017 21:19:19 GMT) and some other.

I am generate GPX from your db with use this my guide miuios.cz/viewtopic.php?f=375&t=18750#p298122. TCX file is posible export to STRAVA

In amazfit_exporter generate GPX not function.

Here is your gpx drive.google.com/file/d/0ByaySoSDeGn2ckpWaFpwUUxkSE0/
[Amazfit] zell180:
so the best python script to export data is botmakerdvd or cistai? However Thank you both
[Amazfit] Puzzlehead:
Both. One for gpx, one for tcx.

Odesláno z mého Redmi 3S pomocí Tapatalk
[Amazfit] zell180:
And beetween gpx and tcx who is the best to upload it on runstastic or strava and how can i upload it? thanks
[Amazfit] peanek:
You can export ALL training data to Strava for 100% ? Also those one without GPS ? I mean like - Eliptical or Bike Indoor ?? Because for me it is only exporting data of workouts with GPS enabled.

rom is : PACEfied 1.2.19 and Amazfit Watch is 1.3.1.2
[Amazfit] icekrim:
Thanks a lot Puzzlehead it worked with TCX files !!!
[Amazfit] Puzzlehead:
Best for strava is TCX. TCX have more information.

Runtastic I not use.

---------- Post added at 05:41 PM ---------- Previous post was at 05:39 PM ----------

Export data from Amazfit in WINDOWS to TCX or GPX

1.) Download and install PYTHON

2.) Download and extract edited Amazifit Exporter to folder without spaces

3.) Conect your watch

4.) Run the batch Export_from_DB.bat

Then you can import TCX or GPX to some application.
[Amazfit] zell180:
Finally i've found how to Force strava Sync to work:

1) delete your xiaomi account from https://account.xiaomi.com/pass/del/

2) do a downgrade to 0.9.5 CN

3) uninstall Amazfit e MiFit from your smartphone. Go into app info and delete data first

4) create new xiaomi account

5) install Amazfit 1.1.5, log in with account create at point 4 and sync smartwatch

6) install Pacefied last version

7) install mi fit 2.2.12, log in with account create at point 4 and sync smartwatch

8) update Amazfit from PlayStore and log in Strava from Activity Sync

9) do your First sync
[Amazfit] euroclie:
Hello,

First of all thanks to everyone here in general and to pieralle in particular for this great thread and data extraction method.

Does anyone know if you can get the continuous HR data in a similar fashion? Despite backing up the whole watch using adb, I wasn't able to find a database containing the HR data, yet the watch itself is able to store it somehow, if only to display the continuous HR graph...

Best regards from France from a fellow Amazfit Pace user!
[Amazfit] emreteg:
Help

Hi everyone,

I use iphone. I am not good at these things. I have Ch version amazfit. Firstly, I cannot get sport_data.db. I do first step but when I try to do "java -jar abe.jar unpack export_data.ab export_data.tar" I cannot get anything. I downloaded abe but I dont know how to install it.

Therefore I tried to do below steps

"Export data from Amazfit in WINDOWS to TCX or GPX

1.) Download and install PYTHON

2.) Download and extract edited Amazifit Exporter to folder without spaces

3.) Conect your watch

4.) Run the batch Export_from_DB.bat"

But I have below messages:

adbd cannot run as root in production builds

failed to copy '/data/data/com.huami.watch.sport/databases/sport_data.db' to './sport_data.db': Permission denied

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

Sistem belirtilen dosyayı bulamıyor.

************************************************** *****

** Download sport_data.db is completed. **

************************************************** *****

.

************************************************** *****

** Export to TCX press T **

** Export to GPX press G **

************************************************** *****

** and press Enter ** g

************************************************** *****

** Exporting to GPX **

************************************************** *****

.

'py' is not recognized as an internal or external command,

operable program or batch file.

************************************************** *****

** Export to GPX is done **

************************************************** *****

.

Press any key to continue . . ."

can anybody help me?
[Amazfit] Mafiaflix:
Hi everyone,

I can extract db file from the device but get an error report

'py' is not recognized as an internal or external command,

operable program or batch file.

Could anybody help me? I'm using windows 10.

Thanks alot.

Regard.

*******************************************************

** PGM download sport_data from the Huami watch **

** and export to TCX or GPX **

*******************************************************

.

*******************************************************

** sport_data.db exist in your PC **

*******************************************************

.

*******************************************************

** Do you want download again? press Y/N **

*******************************************************

** and press Enter ** N

*******************************************************

** Export to TCX press T **

** Export to GPX press G **

*******************************************************

** and press Enter ** G

*******************************************************

** Exporting to GPX **

*******************************************************

.

'py' is not recognized as an internal or external command,

operable program or batch file.

*******************************************************

** Export to GPX is done **

*******************************************************

.

Press any key to continue . . .
[Amazfit] Puzzlehead:
ROM version?

Maybe do you have lock root.

Odesláno z mého Redmi 3S pomocí Tapatalk

---------- Post added at 03:30 PM ---------- Previous post was at 03:28 PM ----------

Python is not installed or not correctly

Odesláno z mého Redmi 3S pomocí Tapatalk
[Amazfit] bragiless:
https://www.python.org/downloads/

download latest phyton its work for me
[Amazfit] passosk58:
I have sport_data.ab file..

Now, how I can extract the activities in GPX files!?
[Amazfit] Puzzlehead:
Export data from Amazfit in WINDOWS to TCX or GPX

1.) Download and install PYTHON

2.) Download and extract edited Amazifit Exporter to folder without spaces

3.) Conect your watch

4.) Run the batch Export_from_DB.bat

Then you can import TCX or GPX to some application

Odesláno z mého Redmi 3S pomocí Tapatalk
[Amazfit] jrdev9:
I export tcx files and they do not show the heart rate and do not show the distance
[Amazfit] MacArtur77:
Hello, thanks DAVID_EST for your great job. With the help of your python script I was able to extract the GPX data from my Amazfit Pace (running software version 1.3.3a).

I have one observation and a hint. With the 1.3.3a they added more sport disciplines (which they call "type"). Your current version of the amazfit_exporter.py does not extract the "bike" tracks. I experimented with your script to learn that the biking is type=5. In order to extract bike tracks along with the walk tracks, I had to modify the following line 12 in your script:

cur.execute('SELECT track_id, start_time from sport_summary where type=2 or type=1')

to read:

cur.execute('SELECT track_id, start_time from sport_summary where type=5 or type=2 or type=1')

Thanks again and best regards,

MacArtur77
[Amazfit] Diginix:
Thanks for that great script to export all that valuable data to PC. That makes the Amazfit even better than it already is.

But there should some more optimized in the GPX script in line 20 of amazfit_exporter.py

cur.execute('SELECT location_data.latitude, location_data.longitude, location_data.altitude, location_data.timestamp from location_data, sport_summary where location_data.track_id=' + str(track_id) + ' and sport_summary.type=[B][COLOR="Red"]2[/COLOR][/B] ')

If I have a bike gps track with type 5, it must also be in the db query at the end (red marked). At this place it needs always the correct type from the track_id.

But I don't know how to do it generic. For me, I have edit the line with the right type. But it would be much better if it is always the right one.
[Amazfit] zuperjotmeil:
TCX and FIT are designed for fitness activities, so they can contain more fitness data than GPX.

eg TCX or FIT supports laps (splits). So your device could record a new lap whenever you press the lap button, or automatically after a set distance, eg every 1km. Also they support pauses, if you want to stop the activity at one point, then start again later. Whereas GPX is essentially just a series of points (with timestamps).

I am not sure whether Strava actually uses the laps or pauses recorded on the device, I suspect it will recalculate them anyway, based on the GPS points and time.

As standard, GPX does not support heart rate, cadence or power data. But this can be added with extensions. The most popular format for these extension was created by Garmin, it is also supported by a variety of other software/websites (including Strava). But some devices might record heart rate/cadence in a different format in the GPX file.

TCX or FIT can also contain summary data, for the whole activity. eg the total time, distance, calories, device used, type of sport. Some of this is used by Strava, eg to display the device, or automatically select the activity type.

TCX and GPX are both XML formats, which can be fairly inefficient in terms of file size. But this does mean they can be easily edited, eg in a text editor. FIT is a binary format, so is much smaller file size, typically about 1/10 of the size. File size is usually not a problem anyway - even if you are recording at 1 point per second, a 3 hour activity would be about 1MB in GPX format. So not really an issue, unless your device has very limited memory, or a slow internet connection for uploading.

So in general, you probably won't notice much difference between formats for uploading to Strava. Though TCX or FIT may give you a bit more data. And FIT would be a smaller file size.
[Amazfit] Diginix:
Nice explanation but has nothing to with my actual question for simple modification of the Python script.

There are tools and websites out there that doesn't support TCX, but GPX. And why should I use an additional converter first when it is simply possible to export directly GPX from the sport_data.db?

Maybe [MENTION=8407745]MacArtur77[/MENTION] can help.

Here is my solution (line 14-19 in gpx/amazfit_exporter.py):

cur.execute('SELECT track_id, start_time, type from sport_summary where type=5 or type=2 or type=1')
running_sessions = cur.fetchall()
for running_session in running_sessions:
track_id=running_session[0]
tiempo_init=running_session[1]
cur.execute('SELECT location_data.latitude, location_data.longitude, location_data.altitude, location_data.timestamp from location_data, sport_summary where location_data.track_id=' + str(track_id) + ' and type="' + str(running_session[2]) +'"')