/miband-heartrate-osc

Enable and monitor heartrate with Mi Band 2, 3 or 4 on Windows 10.

Primary LanguageC#MIT LicenseMIT

Mi Band Heartrate

日本語

Enable and monitor heartrate with Mi Band device on Windows 10.

miband heartrate

Supported devices

  • Mi Band 2
  • Mi Band 3
  • Mi Band 4
  • Mi Band 5

Requirements

  • .NET Desktop Runtime 7.0+ (download)
  • Windows 10
  • Bluetooth adapter supporting Bluetooth 4.0/4.2 BLE

Usage

  • Download and unzip the latest build from release section

For Mi Band 2 or Mi Band 3

  • Un-pairing your Mi Band 2/3 from any devices

  • Connect and pair your Mi Band 2/3 to your computer

  • Launch MiBand-Heartrate.exe

  • Click on Manual Connect button and select your device from device list and set model on Mi Band 2 or Mi Band 3 then click on Connect

  • Once your device is successfully connected and authenticated, click on Start button

For Mi Band 4/5

  • Get your authentication key of your device, visit (freemyband.com) for more information

  • Connect and pair you Mi Band 4/5 to your computer

  • Launch MiBand-Heartrate.exe

  • Click on Manual Connect button and select your device from device list and set model on Mi Band 4 then click on Connect

  • A new window should appear, enter your authentication key then click on Ok

  • Once your device is successfully connected and authenticated, click on Start button

Automatic Connection

You can make an automatic connection by setting MiBand-Heartrate-2.exe.config in the same directory as MiBand-Heartrate-2.exe.

If you enable automatic connection, the Manual Connect button changes to a Auto Connect button.

Key Description Note
useAutoConnect Whether to connect automatically true to enable automatic connection
autoConnectDeviceVersion Device version 4 for Mi Band 4,5 for Mi Band 5
autoConnectDeviceName Bluetooth device name Basically MiBand 5 for Mi Band 5
autoConnectDeviceAuthkey 32-characters authentication key Example: 0123456789abcdef0123456789abcdef

Example

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
    </startup>
    <appSettings>
        <add key="useAutoConnect" value="true"/>
        <add key="autoConnectDeviceVersion" value="5"/>
        <add key="autoConnectDeviceName" value="Mi Smart Band 5"/>
        <add key="autoConnectDeviceAuthKey" value="0123456789abcdef0123456789abcdef"/>
    </appSettings>
</configuration>

Options

  • Export data in CSV file : Log your heartrate data into a CSV file with date, time and heartrate value

  • Write realtime date in text file : Continuously write heartrate value inside a text file

  • Send OSC to VRChat : Send your heartbeat and heart rate using OSC. See the next section for detailed specifications.

  • Continuous mode : Mi Band heartrate sensor can work in two different mode, one-shot and continuous. One-shot mode take 5 to 10 sec. to retrieve a heartrate value then stop. Continuous mode update heartrate value every 2 to 5 sec.

VRChat

Addresses

If "Send OSC to VRChat" is enabled, this app will continue to send the following messages

Addresss Value Type Description
/avatar/parameters/HeartRateInt Int Heart rate par min [0, 255]
/avatar/parameters/HeartRate3 Int Same as HeartRateInt
/avatar/parameters/HeartRateFloat Float Normalized Heart rate ([0, 255] -> [-1, 1])
/avatar/parameters/HeartRate Float Same as HeartRateFloat
/avatar/parameters/HeartRateFloat01 Float Normalized Heart rate ([0, 255] -> [0, 1])
This is useful when controlling shape keys with Radial.
/avatar/parameters/HeartRate2 Float Same as HeartRateFloat01
/avatar/parameters/HeartBeatInt Int 1 : QRS Interval (Temporarily set it to 1/5 of the RR interval)
0 : Other times
/avatar/parameters/HeartBeatPulse Bool True : QRS Interval (Temporarily set it to 1/5 of the RR interval)
False : Other times
/avatar/parameters/HeartBeatToggle Bool Reverses with each heartbeat

Build requirements

  • Visual Studio 2022 17.4+
  • Visual Studio .NET desktop development workload

Build

  • Clone git repository

  • Open MiBand-Heartrate.sln with Visual Studio

  • Right-click on MiBand-Heartrate-2 solution and select generate

Useful links

VRChat

Thirdparty licenses

OscCore | MIT Licence

License

MIT License