{"id":15629861,"url":"https://github.com/dkhmelenko/miband-android","last_synced_at":"2025-04-09T17:26:30.300Z","repository":{"id":46639832,"uuid":"61156251","full_name":"dkhmelenko/miband-android","owner":"dkhmelenko","description":"Unofficial SDK for Xiaomi Mi Band","archived":false,"fork":false,"pushed_at":"2021-08-04T02:37:10.000Z","size":223,"stargazers_count":258,"open_issues_count":15,"forks_count":40,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-02T15:08:53.875Z","etag":null,"topics":["kotlin","mi-band","sdk","xiaomi-bands"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkhmelenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-14T21:15:37.000Z","updated_at":"2025-03-15T01:53:26.000Z","dependencies_parsed_at":"2022-08-03T05:45:55.399Z","dependency_job_id":null,"html_url":"https://github.com/dkhmelenko/miband-android","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkhmelenko%2Fmiband-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkhmelenko%2Fmiband-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkhmelenko%2Fmiband-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkhmelenko%2Fmiband-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkhmelenko","download_url":"https://codeload.github.com/dkhmelenko/miband-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248076259,"owners_count":21043738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","mi-band","sdk","xiaomi-bands"],"created_at":"2024-10-03T10:29:22.529Z","updated_at":"2025-04-09T17:26:30.281Z","avatar_url":"https://github.com/dkhmelenko.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\n[![GitHub Actions](https://github.com/dkhmelenko/miband-android/workflows/Android%20CI/badge.svg)](https://github.com/dkhmelenko/miband-android/actions)\n\nThis is unofficial SDK for Mi Band. This repository contains 2 modules:\n* miband-sdk-kotlin -- SDK for interraction with the MiBand\n* app -- Sample application demonstrating how to work with SDK.\n\nThe app was not tested with Mi Band 2 or newer bands. In case some of the method returns incorrect data or works wrong, pleare report an issue. \n\nThe idea came from [this project](https://github.com/pangliang/miband-sdk-android). However, due to reactive vision of SDK it was reimplemented. Most of methods are implemented using [RxJava](https://github.com/ReactiveX/RxJava) library. Therefore the basic knowledge of reactive streams is required.\n\n# Contribution\nIn case you have ideas or found an issue, don't hesitate to create pull request or an issue.\n\n# How to use\n**IMPORTANT: Use this SDK on your own risk, developer of this SDK is NOT responsible for any unpredictable results.** \u003cbr/\u003e \u003cbr/\u003e\n\n### Discovery\nIn order to start sending and receiving commands from the MiBand, you have to connect and pair with it. Available devices for connection can be found using `startScan()` method.\n\n```kotlin\nmiBand.startScan().subscribe { result -\u003e\n                val device = result.device\n                // save found device\n            }\n```\nScanning can be interrupted any time using the method `stopScan()`.\n\n### Connection\nNext action is to establish connection to the device (MiBand). The fuction `connect(device)` is responsible for that. The fuction returns Observable which emits a boolean value indicating if connection was established or not.\n```kotlin\nmiBand.connect(device).subscribe { connected -\u003e\n                if (connected) {\n                    // connection established\n                } else {\n                    // resolve connection issue\n                }\n            }\n```\nAfter successfully established connection device needs to be paired. The function `pair()` will do pairing to the connected device.\n```kotlin\nmiBand.pair().subscribe { \n                // device is ready for communication\n            }\n```\n### Communication\nWhen the band is connected and paired many different actions can be performed such as read battery information, start/stop vibration, read and change user information, read current steps in realtime, read heartrate and many other.\n\nThere are few examples how to perform those actions. \n*Read battery information*\n```kotlin\nmiBand.batteryInfo.subscribe { batteryInfo -\u003e\n                ...\n            }\n```\n*Start vibration*\n```kotlin\nmiBand.startVibration(VibrationMode.VIBRATION_WITHOUT_LED).subscribe {\n                ...\n            }\n```\n*Realtime steps notification*\n```kotlin\nmiBand.setRealtimeStepsNotifyListener(object: RealtimeStepsNotifyListener {\n                override fun onNotify(steps: Int) {\n                    ...\n                }\n            })\nmiBand.enableRealtimeStepsNotify().subscribe()\n```\nReading heartrate can be done in a similar way: first setup the listener using `setHeartRateScanListener()` and then call the method `startHeartRateScan()`.\n\n\nAll available methods for reading band information are available in class [MiBand.kt](https://github.com/dkhmelenko/miband-android/blob/master/miband-sdk-kotlin/src/main/java/com/khmelenko/lab/miband/MiBand.kt). All methods have JavaDoc documentation explaining how the method works. They are:\n* startScan()\n* stopScan()\n* connect(device)\n* pair()\n* readRssi()\n* batteryInfo()\n* startVibration() / stopVibration()\n* enableRealtimeStepsNotify() / disableRealtimeStepsNotify()\n* setUserInfo(userInfo)\n* startHeartRateScan()\n* setLedColor()\n\n# License\n\n[Apache Licence 2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nCopyright 2020 Dmytro Khmelenko\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkhmelenko%2Fmiband-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkhmelenko%2Fmiband-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkhmelenko%2Fmiband-android/lists"}