Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
069a86c
Update README.md
creotiv Mar 18, 2018
ca92d29
Update README.md
creotiv Mar 18, 2018
2e8972b
Update README.md
creotiv Mar 18, 2018
41c708b
Merge branch 'master' of https://github.com/creotiv/MiBand2
creotiv Mar 18, 2018
63117cb
fix
creotiv Mar 18, 2018
e1db9db
dump and plot scripts
creotiv Mar 19, 2018
d070148
Rename exmaple.py to example.py
creotiv Mar 19, 2018
63412f7
Update example.py
creotiv Mar 19, 2018
cf99d2f
Update README.md
creotiv Mar 19, 2018
3f25ffa
Update README.md
creotiv Mar 19, 2018
fb07564
fix
creotiv Mar 19, 2018
1872ea6
Added raw sensor data grabbing for testing
creotiv Mar 20, 2018
791cd6e
Added debug data from phone
creotiv Mar 20, 2018
554dbe2
Fixed realtime heart measuring. Added realtime raw data from sensors.
creotiv Mar 23, 2018
56a9103
added parsing of gyro and raw heart data
creotiv Mar 24, 2018
34bc29d
fixes
creotiv Mar 26, 2018
6bca1e2
Update README.md
creotiv Mar 26, 2018
1c22670
Update README.md
creotiv Mar 29, 2018
089ad2b
Update README.md
creotiv Mar 29, 2018
9929aa6
Update plot.py
creotiv Aug 19, 2018
d6603ff
added previews data feature
FHantke Nov 5, 2018
5b89be5
fixed readme
FHantke Nov 5, 2018
4874776
clean
FHantke Nov 5, 2018
e86c45a
Merge pull request #15 from FHantke/master
creotiv Nov 23, 2018
626cfb7
Fix broken link
Pablohn26 Dec 20, 2018
a15aa5f
Update dump.py
creotiv May 21, 2019
ae96752
Update example.py
creotiv May 21, 2019
c8ac634
Update plot.py
creotiv May 21, 2019
401a058
fixes for python2/3
creotiv May 21, 2019
22b8eb5
Add setter for current time
Typere Jun 22, 2019
87b7b70
Merge pull request #28 from Typere/master
creotiv Jun 23, 2019
6dcd6ba
Merge pull request #19 from Pablohn26/patch-1
creotiv Jun 23, 2019
4da74a4
new alert_type
AIKoumei Sep 1, 2019
f19a9dd
Merge pull request #31 from AIKoumei/develop
creotiv Sep 1, 2019
6142867
Update README.md
creotiv Nov 12, 2019
29cb938
Update README.md
creotiv Dec 3, 2019
6ada906
base.py duplicate key removal
OldShaterhan Jan 19, 2020
d40f679
* Fixes binary payload for setting heart rate measurement interval in…
askvictor Jan 23, 2020
6093ffa
Merge pull request #38 from OldShaterhan/patch-1
creotiv Jan 23, 2020
3193baa
Merge pull request #39 from askvictor/master
creotiv Jan 23, 2020
838c9b0
Create LICENSE
creotiv Apr 6, 2020
fd0193f
Merge pull request #42 from creotiv/add-license-1
creotiv Apr 6, 2020
80df560
Using default authentication.
kev-m Jun 28, 2020
42d8b16
Adding raw PPG support
kev-m Jun 28, 2020
185a0a6
Starts to acquire some data
kev-m Jun 28, 2020
247a14b
No use printing integer time to the human
kev-m Jun 28, 2020
318ccde
Extracting and parsing PPG data
kev-m Jun 28, 2020
7c81032
Writing out 10 elements on a line
kev-m Jun 28, 2020
ca5d9f3
Adding utility to plot recorded PPG data
kev-m Jun 30, 2020
3204816
Cleaning up code
kev-m Jun 30, 2020
dee16fd
Live plotting works, but tweaking delta_t calculation
kev-m Jun 30, 2020
356234a
With hardcoded dt = 41, commented out calculation of dt using realtim…
kev-m Jun 30, 2020
5151ab0
Hard coded dt = 40, removed runtime calculation of dt using realtime …
kev-m Jun 30, 2020
ae9f71e
Adding details about raw PPG support
kev-m Jun 30, 2020
27b792a
Reformatting with autopep8
kev-m Jun 30, 2020
1ade97d
Username check
kev-m Jun 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.pyc
*.log
heartrate_*.*
.env
env
121 changes: 121 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
59 changes: 54 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# MiBand2
Library to work with Xiaomi MiBand 2
Library to work with Xiaomi MiBand 2 (Support python2/python3)
[Read the Article here](https://medium.com/@a.nikishaev/how-i-hacked-xiaomi-miband-2-to-control-it-from-linux-a5bd2f36d3ad)

# Contributors & Info Sources
1) Base lib provided by [Leo Soares](https://github.com/leojrfs/miband2)
2) Additional debug & fixes was made by my friend [Volodymyr Shymanskyy](https://github.com/vshymanskyy/miband2-python-test)
3) Some info that really helped i got from (Freeyourgadget team)[https://github.com/Freeyourgadget/Gadgetbridge/tree/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2]
3) Some info that really helped i got from [Freeyourgadget team](https://github.com/Freeyourgadget/Gadgetbridge/tree/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband2)

## Online Course "Object Detection with PyTorch"
Subscribe to my new online course: [LearnML.Today](http://learnml.today/)

# Run

Expand All @@ -18,11 +22,56 @@ pip install -r requirements.txt
```sh
sudo hcitool lescan
```
5) Run example.py
5) Run this to auth device
```sh
python example.py --mac MAC_ADDRESS --init
```
6) Run this to call demo functions
```sh
python example.py MAC_ADDRESS
python example.py --standard --mac MAC_ADDRESS
python example.py --help
```
6) If you having problems(BLE can glitch sometimes) try this and repeat from 4)
7) If you having problems(BLE can glitch sometimes) try this and repeat from 4)
```sh
sudo hciconfig hci0 reset
```
Also there is cool JS library that made Volodymyr Shymansky https://github.com/vshymanskyy/miband-js

# Raw PPG data

You can record raw [PPG](https://en.wikipedia.org/wiki/Photoplethysmogram) data to a file:
```sh
python3 dump_ppg.py MAC_address ppg_data.csv
```

The resulting data can be plotted:
```sh
python3 plot_ppg.py -f ppg_data.csv
```

![Raw Data](/raw_ppg.png)

![Raw Data Zoomed in](/raw_ppg_zoom.png)

Or you can also view raw the PPG data in realtime:

```sh
python3 plot_ppg.py -m MAC_address
```

# Donate
If you like what I'm doing, you can send me some money for pepsi(I dont drink alcohol). https://patreon.com/mlworld

<p xmlns:dct="http://purl.org/dc/terms/">
<a rel="license"
href="http://creativecommons.org/publicdomain/zero/1.0/">
<img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
</a>
<br />
To the extent possible under law,
<a rel="dct:publisher"
href="http://medium.com/@a.nikishaev">
<span property="dct:title">Andrey Nikishaev</span></a>
has waived all copyright and related or neighboring rights to
<span property="dct:title">Library to work with Xiaomi MiBand 2 </span>.
</p>
Loading