[General Accessories] xmxm:
Current Version: Extraction Tool v5.92, Analytics Tool v5.60, iOS Extraction Tool v0.2, Fit Sync Tool v0.2 (Updated 6/20/2015)

Here is a tool I wrote for Xiaomi Mi band which provides following functionality:

1. Exports data from Xiaomi Mi band on both rooted and non-rooted Android phones and jailbroken (and possibly non-jailbroken) iPhones under Windows and Linux, generating file in CSV format which can be reviewed in Excel.

Bonoboo maintains a script to perform extraction directly on your smartphone (see link in post 3).

2. Extracts detailed (per minute) walking and running information from Mi Band database (thanks to the input provided by mritsch and Osid).

3. Produces files that can be uploaded to fitnesssyncer.com/ to syncronize data with various fitness services: FitBit/HealthVault/RunKeeper/JawBone and soon Google Fit! See 3rd post for details on data mapping for fitnesssyncer.

4. Provides multiple analytics reports to review extracted data. These reports can be shared on cloud drives to be accessed from anywhere (see post 3 for details)

5. Supports localized UI (currently supported languages are English, Russian, French, Spanish and Italian)

6. Support for synchronization data with Google Fit Service - see post #2 for details

How to use:

Preparation steps:

1. If you plan to use multiple packages, unpack them all to same directory.

1a. If you want to extract data from smartphone, download miband_extract package. To extract data from iOS devices, see to "To extract data from iOS devices" step.

1b. If you want to display local charts of your extracted data on your computer, download miband_analytics package.

1c. If you want to synchronize your extracted data with Google Fit, download miband_fit package.

2. Make sure you have USB drivers for your device properly installed and that your device is accessible by ADB when you connect it through USB

3. If you use it on windows, extract package has all binaries included, for Linux/OSX see comments below.

Checking configuration settings:

1. Review SDPath parameter value in run.bat/run.sh. The program will copy files from Mi app location to folder specified in SDPath before pulling them to desktop. In most cases default value (/sdcard) shoud work fine, however if your phone does not have this directory, find the path where your Internal/External SD is mounted and put that path string into SDPath value. Second most common value might be /storage/sdcard0

2. Review config.js and make any changes to your liking (set Goals for sleep hours and daily steps, force override UI language to specific value)

3. If you do not want main report being open every time you run extract, change OpenHTML=Y in run.bat/run.sh to OpenHTML=N

4. If your device is not rooted or have any issues with first (root) method that application uses and prefer to skip straight to the second (backup) method, set ForceBackupMode value to Y in run.bat.

5. If you want to generate Raw data extract in addition to summary data, set ExtractRaw parameter to Y, update Height parameter to your height in centimeters and update Weight parameter to your weight in kilograms. Please note that data extracted from raw blobs may be slightly different from total numbers in summary data.

If you are planning to use ADB over Wifi:

0. I would not be able to provide much support for ADB over Wifi - so many things could go wrong. Check you firewall settings, check TCPIP ports on both ends, but you are basically on your own.

1. If you are planning to use ADB over WiFi, edit run.sh and set up IPAddr value to IP address of your phone, if you use USB cable, leave IPAddr value blank. If you using non-default port, you may need to change TCPPort value.

2.You may also think of a great idea of running syncronization automatically and unattended using ADB over Wifi - at least I liked that idea initially. I gave that idea more thought and as of now I strongly recommend not to do it - having ADB running over Wifi is a security risk, if you have to use it over Wifi, enable it manually, run the sync and disable ADB over Wifi right away.

For Linux/OSX users:

1. You would need to to manually install android-sdk for (adb binary), sqlite3 version 3.8.3 or higher and openssl with zlib support (version 1.0.2 or higher with zlib support is recommended) to uncompress zlib data. Please note that versions of sqlite3 and openssl that are preinstalled on your machine might be too old to be used with this package, so you might need to obtain newer versions. For example, I was told that OSX has sqlite3 version 3.7.13 preinstalled and it is incompatible with some of functions used in script, so you would need version 3.8.3 at least. If you cannot get openssl with zlib support, you can use similar functionality from python instead - you will need to comment out a line with openssl zlib in run.sh and uncomment next line instead which invokes python script.

2. You'll need to grant execute permissions to run.sh by using chmod +x run.sh and you will need to execute run.sh instead of run.bat in steps listed below. You'll also need to make configuration changes in run.sh instead of run.bat

3. Check that your sqlite3 is properly configured for your time zone. Run following command and see if it returns correct timestamp:

bin\sqlite3 dbfile "select datetime('now','localtime');"

Running application:

1. Connect phone through USB and make sure USB debugging setting is enabled on your phone. Unlock phone screen.

2. Execute run.bat - if your phone is rooted, the data would be pulled automatically. If your phone is not rooted you would see backup screen and you need to press "Back up my data" button in the bottom left corner.

3. Data from your mi band will be saved to extract.csv file and extract.js. After extraction is complete, if OpenHTML is set to Y, mi_data.html will be opened automatically to show charts for your Mi usage.

4. HTML reports are using Google Charts framework and Google TOS does not allow storing their scripts offline along with the application, therefore you will need to have working internet access for reports to work. Your data is not being sent to Google, the internet connection is only used to download latest version of Google Charts javascripts.

Troubleshooting connectivity issues:

1. If you phone is rooted:

Review that your phone has /sdcard directory and it is writable. After you run extract, check if you have origin_db file in that directory. If you do not, ADB may have issues writing files to that directory. Check configuration settings section, item 1

2. If your phone is not rooted or if you use ForceBackupMode=Y:

Check if you get full backup screen, which looks like this:

If you do not get this screen, then Android backup functionality on your device is broken. If your phone is rooted, consider setting ForceBackupMode=N and using rooted method; if your phone is not rooted, try to run Helium Backup https://play.google.com/store/apps/details?id=com.koushikdutta.backup and see if it can backup MI app to sdcard.

To extract data from iOS devices:

Thanks to joshmosh for detailed instructions.

This is reported to work on jailbroken iPhone, but may work on regular iPhones as well - if you try it on non-jailbroken iPhone please let me know if it worked for you.

1. Get a copy of itools. Google it to find a download location (cnet might have it)

2. Plug in your iPhone to your PC

3. Open itools and click on Applications in top row

4. On the left you will find name of your iPhone and below "Applications". Click on Applications

5. Locate your application Mi Fit and click it. On the right you will find a button labelled "browse". Click it.

6. A window will open. Doubleclick on "Documents" then click on user.sqlite, then on "Export" above.

7. A window will open asking you where to export this file. Export it to a db subdirectory of miband extractor main directory and click OK. You should have a file db\user.sqlite now.

8. Once file is extracted to db\ directory, run runIOS.bat from main miband extractor directory. It should generate extract.js, extract.csv and minmaxtime.csv files and will open local charts in your browser if you have analytics package installed.

Screenshots:

[IMG="Main statistics report"]http://i.imgur.com/ALWh4zf.gif[/IMG]

[IMG="Activity by Day of Week report"]http://i.imgur.com/id5BV3q.gif[/IMG]

[IMG="Sleep statistics report"]http://i.imgur.com/tg1XKO9.gif[/IMG]