Featured

New xdrip now supports MiBand 5

Hello to all. I’m glad to announce the release of a new version of xdrip. It has a lot of changes suggested by patrons. I hope you enjoy them. Special thanks for patrons Monoid, kyungmee Yoo, mzst 123, Lukas Petro, Alberto HD,Otto75so3e, Michalis Velonakis whos supported this project. Their contributions were spent to buy a new MiBand5 and implement miband 5 integration and to improve xdrip features.

Please note, this is a beta xdrip version. If there are no issues, the pull request will be sent to the official xdrip application.

The configuration for MiBand5 was left unchanged. And has the same procedure as for MiBand4. (just make sure you use an updated patched MiFit v4.2.0)

Xdrip miband integration apk changelog

If you like this project and want to thank an author for work done or want to support further development of features, become a sponsor on Patreon

If you have some advices regarding features that you want to see, or want to see similar feature on some specific band type, please write them in the comment of the donation form.

Ver 0.3.2 (09.09.2020)

  • Debug. I order to simplify debugging, this version has a modified feedback recipient address. The xdrip log reports would be sent directly to my private server. If you have some issues please send me the logs so i can analyze them and suggest some solution. The logs can be sent via xdrip events logs interface. Before sending logs, please make sure you have added “MibandService:d” text (without quotes) in xdrip Settings->Less common settings-> Extra logging -> Extra tags for loggings . After this go to “Less common settings” -> View recent error interface. Leave enabled only “Low”, “Mid” and “High” checkboxes And click to “upload logs” button. If possible, in the feedback description text specify the approximate time when this error happens

Ver 0.3.1 (31.08.2020)

  • Fix. Use the same graph height and offset for all band screens and modes (required to correctly position “no connection” layers )
  • Fix. Graph display changes. Display prediction line even when there no treatments available.
  • Fix. Graph display changes. Display high and low lines under the bg line.
  • Fix. In rare cases, the wathface can stop updating (usually happens when Bluetooth connection lost while sending the nightmode )

Ver 0.3 (25.08.2020)

Featured

Future of the xdrip miband project

I’ve decided to improve miband integration, and change the method which was used to represent glucose data for MiBand4. Instead of the date modifying and using a custom watchface which interpreter a custom date format in correct way, i will generate entire watchface with a dynamic background and upload this watchface to the band. By using this method, all the disadvantages of changing the date on the watch will disappear, and your watch will be fully functional. So it would be possible to use it with any program, and all band features like weather, music control, fitness progress, and more would work.

In addition, this method allowing to display any data on the watch screen.

Upd. 29.01.2020

I’ve finished a new xdrip version . Would be grateful if someone can help to test it on different miband versions.

If this version would be stable, i’ll create a pull request for the official Xdrip apk version. So there would be a chance this patch would be added to the official aplication.

Upd. 29.04.2020

Great news! The pull request was recently approved and merged into official xdrip application. At the moment it is available in the latest nightly build xdrip version which can be downloaded from the following URL https://github.com/NightscoutFoundation/xDrip/releases

New watchface legend

Since v0.2.3 it is outdated watchface view

Real view on miband4 and v0.2.4 with enabled graph and bolus

Configuration tutorial by steps for v 0.2.x and 0.3.x

1. Obtaining auth key

If you want to use xdrip with Mi Band4 or Mi Band5, you need to get Mi Band Auth key (for the older devices (MiBand2 and Miband3), you can skip this step). The Auth key can be obtained with these simple steps (was copied from https://www.freemyband.com/ )

  1. Unpair band from the existing official app
  2. Uninstall official app
  3. Download and install the moddified MiFit application Mi Fit mod apk (updated to Mi Fit 4.2.0)
  4. Login into the Mi Fit with your email account
  5. Pair the band
  6. Enable band visibility in the MiFit settings.
  7. Now you can uninstall modified Mi Fit application and install official Mi Fit or any other apk you like to use together with miband. If you would use official Mi Fit aplication , you would need to Login into the Mi Fit with the email which was used with patched application.
  8. Finished! You can find your Auth key on /sdcard/freemyband folder of your phone

Notice:

  • If you reset (MAC address of band change) or unpaired your band, the Auth key need to be calculated again. The miband will change the MAC address, so you should change mac and auth key in xdrip(for auto search you can clear mac address and auth key fields)
  • The modded mifit apk is compatible with any firmware version installed on your band
  • You can do this procedure with any phone (if your phone doesn’t allow install apk outside Play Store, you can ask your friend to obtain this auth code for you)

2. xdrip configuration. Connecting to miband

  1. If you have original xdrip application installed on your phone, you would need to delete it. To save all your existent settings and glucose history, you can export your current database into file. To do this, click to the 3 dots on the main xdrip screen, select Import/export feature -> export database.
  2. Install latest patched xdrip from this link xdrip-miband . If you had a database backup, you can restore it by using export/import feature mentioned earlier.
  3. If you skipped “Obtaining auth key” phase (only for miband 2 and 3), go to MiFit settings, and enable band visibility.
  4. Place miband near the phone.
  5. Go to xdrip Settings -> Smart watch features -> MiBand and enable option “Use MiBand”.
  6. Normally miband should be automatically found, and you will see a notification with your model name. If this happen, you can skip next step.
  7. If it wasn’t found automatically, make sure the band visibility option was enabled in MiFit, then disable “Use MiBand” option and repeat step three. You can also enter the mac addres manually (in this case, there no need for visibility option enabled).
  8. Now the miband should be connected, but it is required authentification. On MiBand2 and MiBand3, you should approve authentification by touching the miband button. For MiBand4 or MiBand5 you don’t need to do anything. Normally auth key should be automatically extracted from the file /sdcard/freemyband which was generated by patched Mi Fit application. But if it was not generated, you should manually enter the key in “Auth key” field and retry everything from step 4
  9. Finally, you should see the message that your miband was succesfully authenticated and now you can control miband via xdrip.

3. xdrip configuration. General settings and installing glucose watchface

3.1. Configuration for MiBand4

If you use a MiBand4, you can receive a glucose readings in two ways.

  1. In standard miband way, using the text notifications 
  2. Displaying glucose values on the main band screen with help of dynamical custom watchface.
  1. When use a text notification, xdrip would send a message to the miband after every glucose reading.
  2. When use a “dynamical custom watchface” the xdrip will generate a new watchface after every reading and will send this watchface to the miband. This option available only for MiBand4. All miband features would work as before. The watchface with required measurement units (mmol or mg/dl ) would be automatically installed. It would use the units from the general xdrip settings.

The option “BG readings as notification” in MiBand settings allow to controll the way you prefer to receive glucose values. When it is enable , you would receive notifications after every glucose readings. And when it is disabled, this fancy “dynamical custom watchface” would be used.

You can also enable option Send alarms to receive glucose low/hight alerts. If you enable this option, you would get bg alerts as a phone call. Instead of the caller number, you would see an alarm text with the current glucose value. During alarm notification, it is possible to push on the ignore button on you band to skip alarm or push on hangup button to snooze alert. The low/high alarms can be configured directly in xdrip general settings

It is also possible to enable night mode feature (in miband screens/ features menu) This feature allow to decrease glycose synchronisation interval by specifying interval value and mode start/end time. This mode allow to improve miband battery life by reducing synchronization frequency.

Since v 0.2.4 it is possible to display bolus on the band (if this information present in xdrip). The bolus data can be displayed only when graph option enabled.

Finally to send reading to the see miband you should enable “Send reading” option

Notice

1. Keep your watch nearby with your phone, while phone transmitting data (actually the real BlueTooth connection distance can be even up to 50 meters 🙂 ) If your band will lost connection with the phone while transmitting watchface, it will automatically will use default miband watchface. This watchface would be replaced again after connection would be established
2. Take a note to the bluetooth connection status and last synchronisation date to make sure you see not outdated data. Always remember to
3. The band will not accept a new watcface if battery level is less then 10%. In this case the band will automatically swith to notification mode.

3.2. Configuration for MiBand2 and 3

The only possible way to receive bg values on these band versions is to receive them as a text notification. Such notification would be sent to miband after every reading.

Xdrip miband integration apk changelog

If you like this project and want to thank an author for work done or want to support further development of features, become a sponsor on Patreon

If you have some advices regarding features that you want to see, or want to see similar feature on some specific band type, please write them in the comment of the donation form.

The latest version which support MiBand5 can be found here

Ver 0.2.4.1 (15.03.2020)

  • Fixed App Crash at the settings screen on the first run.

Ver 0.2.4 (10.03.2020)

  • New. Added option to display bolus (when enabled graph)
  • Fixed issue with when BG numbers were displayed without infill
  • For better readability, BG number size was slightly increased
  • Added bg prediction line on the graph (would display 30 minutes prediction line)

At this moment, most of the issues were fixed, and i added many new features so I hope this would be the latest version 🙂 I have plans to merge it into the official xdrip build (if it would be accepted)

Ver 0.2.3 (23.02.2020)

  • New. Added option to disable graph on watch
  • New. Added a new watchface without graph (would be used when disabled graph)
  • New. Added option to collect heart rate data from miband. Update interval can be configured in MiFit or any thirdparty application. To see heart rate data in xdrip, the options “Use Health Data” and “Heart Rate sensor” which is located in Settings -> Smartwarch Features -> Smart watch sensors, should be enabled.
  • Improvement. Updated graph watchface view
  • Fixed. Authorisation issue on some miband 4 devices
  • Syncronized with official xdrip version

Added a new options which are available only when enabled engineering mode https://github.com/NightscoutFoundation/xDrip/wiki/Engineering-Mode

  • New. Added option which allow to disable hight MTU (when enabled, can fix watchface sync issues which may happen on some phones, but the watchface uploading would take much more time)
  • New. Added possibility to install custom watchface. The custom watchface files ‘my_watchface.bin’ and ‘my_image.png’ should be placed into into ‘xdrip’ folder on your phone. “my_watchface.bin” is a normal watchface and my_image.png is a watchface background image. The background image shouldn’t have more than 128 colors. For faster delivery and longer battery life, the wathcface size should be as small as possible.
  • New. Added offset option for custom watchface (defines offset between top of the background image and xdrip generated data)

Ver 0.2.2 (09.02.2020)

  • Improvement. Added BG update interval in night mode.
  • Improvement. UI improvements on the band settings screen.
  • Syncronized with official xdrip version

Ver 0.2.1.1 (03.02.2020)

  • Watchface. Fixed HR value when no data available.
  • Watchface. Increased font size for delta and bg date.
  • Fix in watchface generation algorithm which should fix “black” watchfaces reported by some users.
  • Fix. Requesting higher MTU size and use the size negotiated by Bluetooth protocol. (should fix watchface synchronization issue).
  • Improvement. BG alarms now work as call. On MiBand 3 and 4 the ignore button will delay alarm, and hangup will snooze alert.
  • Improvement. Authentification for miband2 and 3 (no need to approve auth after disconnection).
  • Improvement. Decrease brightness when uploading watchface. This can significantly improve band battery life. Also makes watchface update to be not so noticeable to people around.
  • Improvement. Added night mode settings.
  • Resend BG as notification if watchface cannot be installed when the battery level is less than 10%

Ver 0.2.0.1 (29.01.2020)

  • Quick-fix to fix a empty watchscreen and small styling issues

Ver 0.2.0 (29.01.2020)

  • New algorithm to represent glucose data, which use a dynamic watchface with a custom background. This allows using all miband features. (only for MiBand4)
  • Like in previous versions, MiBand 2 and 3 can receive bg values as a notifications.

Featured

Displaying blood glucose on Xiaomi MiBand fitness trackers

Upd. 29.1.2020 new xDrip version which allows using all MiBand4 features available here https://bigdigital.home.blog/2020/01/23/future-of-the-xdrip-miband-project/

Updates for the this xdrip version would be discontinued.

Introduction

The miband trackers it is a very good device for usual life tracking. There’s a lot to like in Xiaomi trackers. They are cheap and small. For about $40, you get a fitness tracker that has waterproofing, a heart rate monitor, text and call notifications, sleep tracking, workout tracking, and impressive battery life with up to three full weeks, depending on usage.

But they also can be used for originally unintended things.

In my case, the band was used to display a BG low/high alert notification from xdrip application.

Unfortunately, xdrip doesn’t support this band type from the box, so need to use workarounds to receive these notifications.

How to configure notification with the help a thirdparty apps were described in details in this article. https://a.kabachnik.info/blood-sugar-on-a-xiaomi-mi-band.html

But this solution has one disadvantage, to see, the current BG blood level it uses notifications, which usually updates every 5 minutes.  

After the release a MiBand4, i found a cool new thing it this band version. This time Xiaomi lets us to create and upload custom watchfaces .

So a few days ago I discovered a way of changing the watch face for a custom one. And and it took me to the idea that i can create own watchface that will display the values of glucose levels directly on the main screen.

But there was a restriction in realization such watchface. Since the watchface allow to display only time, date, and some status info, I was faced with the task of encoding the values of glucose levels into the available values that miband could display.

For such purposes, the fields of the day of the month, month, and day of the week were most suitable. To display an integer bg value i used a day of the month for decimal value was used a month and to display trend arrow i use a day of the week. In such case, i can display almost any value of the glucose but with one limitation, the maximum integer value could be 18. So if glucose would be more than, 18.9 mmol/L, the watch will display the maximum value as 18.9.

I also added a mg/dl glucose units. To correctly display these units, it is required to install another watchface. For mg watchafe the minimum possible value can be 10mg/dl and maximum value 299 mg/dl.

The watchfaces were designed and compiled with help of the in WF_Builder1.0.4 program can be found here

The watchface bins and source files located by the following links:

upd. Since xdrip version 0.1.3 the xdrip should keep a continuous connection with MiBand, so when miband connected, you will be sure that you see relevant glucose value. If the miband for some reason will lose connections with the phone, you will see a lighting blue indicator in the left bottom corner of the miband so you can consider the value can be outdated. 

No connection with xdrip (the glucose value can be outdated)

Next after this, i made a fork of the xdrip where integrated miband watchface support. Link to xdrip fork https://github.com/bigdigital/xDrip/tree/miband-integration. Link to compiled apk file can be found here xdrip-miband

This version of xdrip can send a notification to miband without any thirdparty tools. Also, it encodes and set the time on miband in a specific format, which allows displaying the BG values in such way:

Also were added a set of settings, which allow to adjust some band settings and see the status.

Unfortunately, the date modification (which required for custom watchface) has own disadvantages.

  1. It is impossible to use standard programs like Mi Fit. They continuously synchronizing time on the watchface, which leads to incorrect bg value displaying. (Note, if you would use thirparty programs, )
  2. The band cannot count steps in a normal way. So you cannot see your fitness progress.
  3. Since miband ver 4, the band developers introduced a new algorithm of the authentication. New devices and older devices with updated firmware require a server based pairing.  So now it is required to obtain an auth key which is normally cannot be extracted from MiFit program, but there exists a workaround (see more details in configuration tutorial)

But if you still want to have all miband features such as fitness progress, steps, sleep, weather, smart alarms, music control and more, it is possible to use notifications to send glucose values (there an option in the miband setting screen which allow to send bg reading as a notification ). In such case, there is no need to install custom watchface.

Configuration tutorial by steps

1. Obtaining auth key

If you want to use xdrip with Mi Band4, you need to get Mi Band 4 Auth key (for the older devices (MiBand2 and Miband3), you can skip this step). The Auth key can be obtained with these simple steps (was copied from https://www.freemyband.com/ )

  1. Unpair band from the existing official app
  2. Uninstall official app
  3. Reset your Mi Band (optional)
  4. Download and install the Mi Fit mod apk version
  5. Login into the Mi Fit with your email
  6. Pair the band
  7. Enable band visibility in the MiFit settings.
  8. Uninstall modified Mi Fit application (If you want to use all miband features, you can install official Mi Fit application again. Login into the Mi Fit with email which was used with patched application and enable “BG readings as notification” option. But in this case would be impossible to use xdrip watchface and display bg values on main screen.)
  9. Finished! You can find your Auth key on /sdcard/freemyband folder of your phone

Notice:

  • If you reset your band (MAC address of band change) the Auth key need to be calculated again. The miband will change the MAC address, so you should change mac and auth key in xdrip(for auto search you can clear mac address and auth key fields)
  • The mod apk is compatible with any firmware version installed on your band
  • You can do this procedure with any phone (if your phone doesn’t allow install apk outside Play Store, you can ask to a your friend to obtain your auth code for you)

2. xdrip configuration. Connecting to miband

  1. Install xdrip from this link xdrip-miband
  2. If you skipped “Obtaining auth key” phase, go to MiFit settings, and enable band visibility.
  3. Place miband near the phone.
  4. Go to Settings -> Smart watch features -> MiBand and enable option “Use MiBand”.
  5. Normally miband should be automatically found, and you will see a notification with your model name.
  6. If it wasn’t found autmatically, make sure the band visibility option was enabled in MiFit, then disable “Use MiBand” option and repeat step three. You can also enter the mac addres manually (in this case, there no need visibility option enabled).
  7. Now the miband should be connected, but it is required authentification. On MiBand2 and MiBand3, you should approve authentification by touching the miband button. For MiBand4 you don’t need to do anything. Normally auth key should be automatically extracted from the file /sdcard/freemyband which was generated by patched Mi Fit application. But if it was not generated, you should manually enter the key in “Auth key” field and retry everything from step 3
  8. Finally, you should see the message that your miband was succesfully authenticated and now you can control miband via xdrip.

3. xdrip configuration. General settings and installing glucose watchface

3.1. Configuration for MiBand4

If you use a MiBand4, you can receive a glucose readings in two ways.

  1. In standard miband way, using text notifications 
  2. Displaying glucose values on the main band screen with help of custom watchface and specific date modification.

When use a text notification, xdrip would send a message to the miband after every glucose reading. Also there no restrictions in the miband functonality. So you can use an official MiFit application to track activity and music controll.

To display glucose value on the main band screen the xdrip change a date on the band (the date represent the glucose value). Unfortunately, such things as fitness progress, step counters and weather directly related to the date on the tracker. So these features would not work correctly because the date on the band would be changed after every new glucose reading.
The things like music control (not sure regarding alarms and timers) not related to the date, so they should work fine. But official MiFit application continuously corrects the date on miband, which leads to the incorrect glucose values displayed on the band. So at the moment it is not possibe to use miband in such mode with the official apllication.

The option “BG readings as notification” in MiBand settings allow to controll the way you prefer to receive glucose values.

So if you want to see the reading on the main screen and ready to sacify life tracking functionality, you can disable “BG readings as notification” option and press on “Install miband4 watchface” button to install a custom watcface, which will display a bg readings directly on the main watch screen.

Notice: Keep your watch nearby with your phone, while phone transmitting data.

The watchface with required measurement units (mmol or mg/dl ) would be automatically installed. It would use the units from the general xdrip settings.

When the uploading process will be finished, you will see the new watchface on your miband.

Finally to send reading to the see miband you should enable “Send reading” option

3.2. Configuration for MiBand2 and MiBand3

These band version can only receive bg values as notifications. To receive bg reading, you would need to enable “Send reading” and “BG readings as notification” options.

Xdrip miband integration apk changelog

Ver 0.1.4 (16.01.2020)

  • Fixed: trend arrow is always horizontal

Ver 0.1.3 (13.01.2020)

  • Synchronized with original xdrip
  • Fixed bg timer (not fired when phone in sleep mode)
  • Update glucose value on miband after the midnight
  • Added Bluetooth autoreconnect (the band will keep Bluetooth connection)
  • Added “Find phone” functionality
  • APK recompiled with old signature version and should work on Android 6

Ver 0.1.2 (29.12.2019)

  • fixed apk crash when attempt to install miband watcface   

Ver 0.1.1 (28.12.2019)

  • added a mg/dl glucose units
  • synchronized with original xdrip

Ver 0.1 (3.12.2019)

  • Initial stable release  (support only mmol glucose units)
Create your website at WordPress.com
Get started