Skip to content

Biometric Dual Heart Rate Streaming from Mobile Devices

Michael O'Brien edited this page Jul 5, 2023 · 4 revisions

Overview

  • Full phone metric capture - GPS, Gravity, Accell, Orientation, Magnetic field, pressure, altitude, ambience, heading
  • Additional device capture - 2 HRM bluetooth LE metrics - 2A37
  • Derived metric capture - Geohash, speed

Requirements/Features

     
R1 Redundant HRM tracking  
R2 Location based tracking correlation  
R3 Sensor tracking correlation  
R4 Data persistence on device  
R5 Data persistence on remote cloud  
R6 Live tracking of device via cloud  
R7 Cloud data export  
R8 Android specific requirements  
R9 iOS specific requirements  

Work Items

     
WI1 XCode project  
WI2 Java backend  
WI3 JS frontend  
WI4 Persistence backend  
WI5 Cloud infrastructure  

Use Cases

UC1: Heart Rate Tracking

iPhone X client screen and a mobile web based monitoring screen.

Heart rate fitness derivation

The heart rate follows the capacitator charge graph - logarithmic rise and logarithmic drop on exercise stop - an indicator of fitness

For example In the following graph you see that my fitness level increased by day 10 for 3 reasons (after I first started running in 2013 - the acceleration to peak rate, the peak rate and the deceleration from the peak rate.  The slower the rise combined with a lower absolute rise combined with a swift return is optimal

Screenshot 2023-07-04 at 20 32 29

UC2: Location Tracking

Every place where I turned on tracking - is available from the DB. Run the following to get the list of record sets (ones ending in 5 are exercise specific).

SELECT distinct userId  FROM biometric.gps_record r where  r.userId like '202002%';
# KML for google earth  http://biometric.elasticbeanstalk.com/FrontController?action=kml&u=202002210

Geo Tracking / Inventory

UC3: Heart rate correlation to Geography

Bluetooth 4 LE Mobile Rest client on iOS 12/3 with a backend JAX-RS JPA 2 Java cloud service.

  • Full phone metric capture - GPS, Gravity, Acceleration, Orientation, Magnetic field, pressure, altitude, ambience, heading
  • Additional device capture - 2 HRM bluetooth LE metrics - 2A37
  • Derived metric capture - Geohash, speed

API: Swagger

http://biometric.elasticbeanstalk.com/rest/read/json/latest/20190119

Code

JIRAs

Current system : https://github.com/obrienlabs/biometric/issues Older system : https://obrienlabs.atlassian.net/projects/BIOM/issues/BIOM-2?filter=allopenissues

Features

  • Live google maps/HRM browser based user tracking
  • KML google earth extract
  • CSV extract
  • XML extract
  • Dual HRM capture on iOS app for exercise alerts

Design

  • iOS 5-15 client - dual HRM tracking during run

Capturing sensor data during user activity - running

Capturing sensor data during user activity - rollerblade

20250904 Screenshot 2023-07-04 at 20 30 54

Live user tracking - in Cancun during a run

Google Earth view - KML extract http://biometric.elasticbeanstalk.com/FrontController?action=kml&u=201811075

Apple Watch HealthKit work needed

Implementation

Database Model

Key/Value

Relational : MySQL

mysql> select * from biometric.gps_record where userId='201904080' order by heart2 DESC LIMIT 1;
+----------+-----------+-----------+-----------+---------------+---------------+---------+--------------+----------+----------+----------+-------+-------+-------+--------+--------+--------+--------+----------+---------------+-------+-----------+-----------+-----------+----------------+------+-----------+------+----------+----------+-----------+----------+----------+-------+------+------------+------------+----------+---------------+---------------+-----------+---------+
| IDENT_ID | ACCELX    | ACCELY    | ACCELZ    | ACCURACY      | ALTITUDE      | bearing | geohash      | GRAVX    | GRAVY    | GRAVZ    | GYROX | GYROY | GYROZ | HEART1 | HEART2 | HRDEV1 | HRDEV2 | humidity | LATITUDE      | light | LINACCX   | LINACCY   | LINACCZ   | LONGITUDE      | PRES | provider  | PROX | RECV_SEQ | ROTVECX  | ROTVECY   | ROTVECZ  | SEND_SEQ | speed | temp | teslaX     | teslaY     | teslaZ   | tsStart       | tsStop        | userId    | version |
+----------+-----------+-----------+-----------+---------------+---------------+---------+--------------+----------+----------+----------+-------+-------+-------+--------+--------+--------+--------+----------+---------------+-------+-----------+-----------+-----------+----------------+------+-----------+------+----------+----------+-----------+----------+----------+-------+------+------------+------------+----------+---------------+---------------+-----------+---------+
| 11271220 | -0.763702 | -1.003540 | -0.230164 | 65.0000000000 | 76.0890050000 |      99 | f244mkh5h13t | 0.000000 | 0.000000 | 0.000000 | NULL  | NULL  | NULL  |   NULL |    109 | NULL   | NULL   | NULL     | 45.4180030000 | NULL  | -0.763702 | -1.003540 | -0.230164 | -75.7011200000 | NULL | 12.100000 | NULL |  3662206 | 0.532636 | -0.462588 | 0.541578 |     2234 |    -1 | NULL | -69.590858 | -20.243172 | 0.503548 | 1554738044948 | 1554738045010 | 201904080 |       0 |
+----------+-----------+-----------+-----------+---------------+---------------+---------+--------------+----------+----------+----------+-------+-------+-------+--------+--------+--------+--------+----------+---------------+-------+-----------+-----------+-----------+----------------+------+-----------+------+----------+----------+-----------+----------+----------+-------+------+------------+------------+----------+---------------+---------------+-----------+---------+
1 row in set (12.66 sec)

mysql> select count(1) from biometric.gps_record;
+----------+
| count(1) |
+----------+
| 11933650 |
+----------+
1 row in set (11.87 sec)

increase core count from 8 to 14
mysql> select count(1) from biometric.gps_record;
+----------+
| count(1) |
+----------+
| 11933650 |
+----------+
1 row in set (5.32 sec)

Deployment

Cloud Deployment

On Prem Deployment

Design Issues

DI 101: Fitbit BLE 2a37 Characteristic API for Heart Rate

Not yet https://community.fitbit.com/t5/SDK-Development/I-m-trying-to-read-Versa-Lite-Watch-heart-rate-using-using-the-Bluetooth/td-p/4399653

Via SDK https://dev.fitbit.com/build/reference/device-api/heart-rate/

Disclaimer

Warning: this article involves rollerblades - please wear all protective gear (helmet, gloves, kneepads, elbopads) - There is one other older developer that wears rollerblades in NA here - one of my coworkers at Google - https://www.wired.co.uk/article/ten-years-of-google-x

Links

Clone this wiki locally