The OpenHolter Project: D.I.Y. Cardiometry with
Arduino and Django.
Roberto Rosario
robertorosario.com
Slide 2
Slide 2 text
Who am I?
Slide 3
Slide 3 text
Who am I?
Hint:
Not him.
Slide 4
Slide 4 text
Who am I?
Slide 5
Slide 5 text
Who am I?
Slide 6
Slide 6 text
Who am I?
Slide 7
Slide 7 text
DISCLAIMER
I’m not a doctor or a medical practitioner. This talk is about my personal experiences
and covers my basic understanding about some topics using Internet sources. I share
this as an introduction of these topics only. This talk is not meant to be a scientifically
accurate document, do not use it or reference it as such. There many things in this talk
that can be and should have been made differently/better. The device shown in this talk
is not meant or claims to diagnose or cure heart diseases or conditions. I’m not
endorsing that you build this device. The material in this talk doesn’t substitute a visit to
your doctor or the years of study they endure to become doctors or the years of
experience they endure to become experts. If you decide use the information shown in
this talk or build the device shown in this talk, you do so at your own risk and assume
any and all consequences of such decision, relieving me of any and all liabilities.
Slide 8
Slide 8 text
What is
Cardiometry?
Cardio = Heart
Metry = Measurement
Slide 9
Slide 9 text
What is Electro
Cardiometry?
Electro = Electricity
Cardio = Heart
Metry = Measurement
Slide 10
Slide 10 text
What is an EKG
(or ECG)
Acronym:
Electro
Cardio
Gram
Electric Heart Diagram
Slide 11
Slide 11 text
Sample EKG. Wikipedia, Public Domain
Slide 12
Slide 12 text
Cardiac pacemaker. Wikipedia, CC BY-SA 2.5
Slide 13
Slide 13 text
Cardiac pacemaker. Wikipedia, CC BY-SA 3.0
Slide 14
Slide 14 text
ECG principle. Wikipedia, CC by 3.0
Slide 15
Slide 15 text
Sinus Rhythm. Wikipedia, Public domain
Slide 16
Slide 16 text
Sample EKG. Wikipedia, Public Domain
Slide 17
Slide 17 text
EKG leads. Wikipedia, Public Domain
Slide 18
Slide 18 text
Precordial leads. Wikipedia, Public Domain
Slide 19
Slide 19 text
Limb leads. Wikipedia, Public Domain
Slide 20
Slide 20 text
Limb leads. Wikipedia, Public Domain
Slide 21
Slide 21 text
Limb leads. Wikipedia, Public Domain
Slide 22
Slide 22 text
Sinus Rhythm. Wikipedia, Public domain
Slide 23
Slide 23 text
Sample EKG. Wikipedia, Public Domain
Slide 24
Slide 24 text
Vintage EKG machine. Wikipedia, Public Domain
Slide 25
Slide 25 text
Modern EKG machine. Wikipedia, CC by 3.0
Slide 26
Slide 26 text
What is a Holter? EKG + Time
EKG Histogram
Slide 27
Slide 27 text
Holter. Wikipedia GNU Free Documentation License
Slide 28
Slide 28 text
Holter. Wikipedia GNU Free Documentation License
Slide 29
Slide 29 text
Holter. Wikipedia GNU Free Documentation License
Slide 30
Slide 30 text
Canine Holter. Wikipedia, Public Domain.
Slide 31
Slide 31 text
Holter. Wikipedia GNU Free Documentation License
Slide 32
Slide 32 text
Why I decided to do this?
Slide 33
Slide 33 text
Queue flashback!
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
No content
Slide 38
Slide 38 text
No content
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
Problems
● An EKG is just a snapshot of your heart at a specific
moment.
● A moment when you might not have symptoms.
● Monitoring your heart requires a Holter.
● You need an appointment and referral for a Holter study.
● Holters fail. You have to start all over again.
● Holters only work for 24 hours.
Slide 42
Slide 42 text
Realisation
● An EKG is ADC sampling.
● Holter is an EKG with storage and battery. Or a data logger.
● I had all the knowledge to build an Arduino based data
logger.
● I could work on it 1 hour a day during my recovery.
Slide 43
Slide 43 text
No content
Slide 44
Slide 44 text
No content
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
Challenges
● Use off the shelves parts only. Orderwise known as
“stuff-I-could-get-on-eBay” strategy.
● Cheap.
● Simple.
● Use standard medical cables and electrodes.
● Modular or breakout boards.
Slide 47
Slide 47 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 48
Slide 48 text
No content
Slide 49
Slide 49 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 50
Slide 50 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 51
Slide 51 text
Bio Interface - Needs
● No voltage but differential voltage reading
● Signal amplification
● Adaptive signal filtering
● Analog to digital conversion
Slide 52
Slide 52 text
Bio Interface - Analog Devices AD8232
● $10-$20 USD
● Built-in voltage comparators
● Built-in amplifier
● Built-in filtering
● Power management
● Cons: No ADC
Slide 53
Slide 53 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 54
Slide 54 text
Real Time Clock - Needs
● Small
● Battery or SuperCap backed up
● Easy interface
Slide 55
Slide 55 text
Real Time Clock - Dallas DS3231
● $1 USD
● I2C Interface
● Unlike DS1302 and DS1307, has temperature
compensated crystal and crystal oscillator
● Has battery input and powerless timekeeping
Slide 56
Slide 56 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 57
Slide 57 text
Microcontroller unit - Needs
● Low power
● Analog to digital interface
● Faster than bio interface sampling rate
Slide 58
Slide 58 text
Microcontroller unit - Arduino Nano
● Clones at $4 USD
● Atmel Atmega 328 at 16 MHz
● Analog and digital pins
● 32 KB Flash (minus 2KB bootloader)
● I2C & SPI communications
● UART TTL to USB
Slide 59
Slide 59 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 60
Slide 60 text
Power management - Needs
● 5 volt output
● High size and weight to power ratio
● Low heat
Slide 61
Slide 61 text
Power management - Custom
● GTL 18650 5300mAh Lithium Ion ($2 USD)
● Lithium Ion charger module w/ output pins ($0.35 USD)
● 3.7v to 5v voltage inverter ($0.50 USD)
Slide 62
Slide 62 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 63
Slide 63 text
Graphical User Interface - Needs
● Small
● Low power or low energy mode
● Easy to interface
Slide 64
Slide 64 text
Graphical User Interface - Solomon
Systech SD1306
● $5 USD
● Multiple communication modes including I2C
● OLED
● Visibility
● Pixel based
● 2 x Push buttons
Slide 65
Slide 65 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Storage - SDCard & module
● $3 USD (card) + $1 USD (reader)
● Cons: Fast modes need license.
● SPI bus mode. This bus type
supports only a 3.3-volt interface.
This is the only bus type that does
not require a host license.
● 5V to 3V converter
● 5V to 3V level converter
Slide 68
Slide 68 text
Communications
SPI
I2C or I2C
Slide 69
Slide 69 text
What is SPI
The Serial Peripheral Interface bus (SPI) is a synchronous
serial communication interface specification used for short
distance communication, primarily in embedded systems. The
interface was developed by Motorola in the late eighties and
has become a de facto standard. Typical applications include
Secure Digital cards and liquid crystal displays.
Slide 70
Slide 70 text
What is SPI
SPI devices communicate in full duplex mode using a
master-slave architecture with a single master.
Slide 71
Slide 71 text
What is I2C
Short for Inter-IC, a type of bus designed by Philips
Semiconductors in the early 1980s. Is used to connect
integrated circuits (ICs).
Slide 72
Slide 72 text
What is I2C
I2C is a multi-master bus, which means that multiple chips can
be connected to the same bus and each one can act as a
master by initiating a data transfer.
Slide 73
Slide 73 text
Block diagram
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Slide 74
Slide 74 text
Block diagram - Communications
MCU
Bio
Interface
RTC Storage
Graphical
User
Interface
Power
Management
Analog
Digital
I2C
Digital
I2C
SPI
Slide 75
Slide 75 text
Organic interface - Connectors
● Many types and subtypes
○ Snap
○ Banana
○ Suction
○ Clip
○ Limb clips
○ Alligator
● Easiest to work and with the most pros: Snap
Slide 76
Slide 76 text
Organic interface - Connectors
Slide 77
Slide 77 text
Organic interface - Leads
● Build your own
○ Source connectors
○ Good wire gauge
● Included leads
○ Poor in all regards
● Lead + electrode
○ Not feasible
Slide 78
Slide 78 text
Organic interface - Leads
● Professional ones
○ Best connectors
○ Best wire gauge
○ Tangle resistant
○ Labeled
○ $20 USD
○ Easy to interface
Slide 79
Slide 79 text
Organic interface - Electrodes
● BIO Protech T815
○ Cloth
○ Extended wear (day)
○ Sweat resistant
○ Cons: Painful to remove
● BIO Protech T716
○ Foam
○ Cons: Not water resistant
● $20 USD for bag of 50
Slide 80
Slide 80 text
Organic interface - Electrodes
● BIO Protech T815
○ Cloth
○ Extended wear (day)
○ Sweat resistant
○ Cons: Painful to remove
● BIO Protech T716
○ Foam
○ Cons: Not water resistant
Slide 81
Slide 81 text
Firmware
● Modular
● Object oriented
● 3 modes of operation:
○ Realtime display
○ Recording
○ Serial port output
Slide 82
Slide 82 text
Libraries - Display: U8g2
● Large hardware support
● Support fonts
● Graphics drawing
● Low memory display mode (tiled)
● Custom icons
● GUI widgets like menus and dialogs
● Physical buttons interface and debouncing
Slide 83
Slide 83 text
Libraries - Storage: Bill Greiman’ SDfatlib
● Non monolithic
● Multiple classes: SdFat, SdBaseFile, SdFile, File,
StdioStream, ifstream, ofstream
● Mature
● Fast
● Economic memory usage
Slide 84
Slide 84 text
Libraries - RTC: Adafruit’s RTClib
● Supports several Arduino MCUs
● Provides access to the square wave pin
● Cons: High memory consumption
Sampling rate reliability
● Arduino’s crystal is subject to drift
● Interrupt driven
● Improve periodicity of readings
● Increase sample rate
Slide 88
Slide 88 text
Sampling rate reliability - Solution
Use the DS3231 square wave output pin to trigger Arduino’s
hardware interrupt and do sampling in an ISR.
Slide 89
Slide 89 text
Sampling rate reliability - Solution
The enable_interrupt function turns on the square wave pin
and enables the Arduino hardware interrupt pin to call a
callback function on the falling edge of the wave.
Slide 90
Slide 90 text
Sampling rate reliability - Solution
By default, a 4 KHz square
wave is used, triggering the
ISR 4,000 times a second
or once every 0.000244141
seconds. This, we’ll call
RTC ticks.
Slide 91
Slide 91 text
Sampling rate reliability - Solution
To get 100 samples a seconds, how many ticks between each?
1 / 100 / 0.000244141 =
every 40.959937086 ticks
Sampling rate reliability - Solution
Consumer
Hardware timer
Generator
Buffer
(FIFO Stack)
Lock
Realtime sampling and multithreading on the Arduino.
Slide 97
Slide 97 text
Recordings format
Slide 98
Slide 98 text
Recordings format
FAT only allows 8.3 filenames.
Slide 99
Slide 99 text
Recordings format
Unique non sequential filenames?
Slide 100
Slide 100 text
Recordings format
Hexadecimal unixtime!
Slide 101
Slide 101 text
Recordings format
Slide 102
Slide 102 text
Recordings format
Decimal to time_struct, to epoch, to datetime
Slide 103
Slide 103 text
Recordings format
Slide 104
Slide 104 text
Recordings format
Unique up to a second of difference.
Slide 105
Slide 105 text
Heartbeat detection A heartbeat is not a spike
but a wave
Slide 106
Slide 106 text
Heartbeat detection
Slide 107
Slide 107 text
Heartbeat detection
Slide 108
Slide 108 text
Heartbeat detection
Slide 109
Slide 109 text
Heartbeat detection
We are interested in #2
Slide 110
Slide 110 text
Heartbeat detection
Slide 111
Slide 111 text
Heartbeat detection
Slide 112
Slide 112 text
Heartbeat detection
Slide 113
Slide 113 text
Heartbeat detection
Slide 114
Slide 114 text
Heartbeat detection
Slide 115
Slide 115 text
Heartbeat detection
Slide 116
Slide 116 text
Heartbeat detection
Slide 117
Slide 117 text
Heartbeat detection
Slide 118
Slide 118 text
Heartbeat detection
Slide 119
Slide 119 text
The build
Slide 120
Slide 120 text
First prototype
Slide 121
Slide 121 text
First prototype
Slide 122
Slide 122 text
First prototype
Slide 123
Slide 123 text
First prototype
Slide 124
Slide 124 text
First prototype
Slide 125
Slide 125 text
It’s ALIVE!
Slide 126
Slide 126 text
No content
Slide 127
Slide 127 text
It’s ALIVE!
Slide 128
Slide 128 text
First prototype
● 3 modes of operation
● Pocket size
● Total cost ~ $30 USD
● 4 GB SD Card (vs. 128 MB
commercial
● 12 days battery life (vs. 1 day
commercial)
● Rechargeable via USB
● Upgradeable via USB
Slide 129
Slide 129 text
First prototype
● Total flash usage: 29KB
● Total RAM usage: 500 bytes
Slide 130
Slide 130 text
The App
Slide 131
Slide 131 text
Creating an
EKG journal
A chart is good. A journal is better.
Slide 132
Slide 132 text
Creating an
EKG journal
Recording downloader
Packaged program
Historic recordings
Metadata
Graphical
Tags
Share
Slide 133
Slide 133 text
No content
Slide 134
Slide 134 text
Not just a DMS, but also a
platform
Slide 135
Slide 135 text
Features of
interest
Mayan Apps
Generic templates
Metadata
Graphical previews
Tags
Email sharing
Access Control
Slide 136
Slide 136 text
App - Requirements
● Upload recordings
● Preview/render recordings
● Selection and trim
● Conversion to archival version
● Metadata, tagging, etc.
● Search
● Sharing
Slide 137
Slide 137 text
App
Slide 138
Slide 138 text
App - Registration
Slide 139
Slide 139 text
App - Registration
Slide 140
Slide 140 text
App - Registration
Slide 141
Slide 141 text
App - Models
Slide 142
Slide 142 text
App - Models
Slide 143
Slide 143 text
App - Models
Slide 144
Slide 144 text
App - Model views
Slide 145
Slide 145 text
App - Model views
Slide 146
Slide 146 text
App - Model views
Slide 147
Slide 147 text
App - Model views
Slide 148
Slide 148 text
App - Model views
Slide 149
Slide 149 text
App - Model views
Slide 150
Slide 150 text
App - Widget, dygraphs
Slide 151
Slide 151 text
App - Widget, dygraphs
Slide 152
Slide 152 text
App - API views
Slide 153
Slide 153 text
App - Capture form
Slide 154
Slide 154 text
App - Capture form
Slide 155
Slide 155 text
App - Capture form
Slide 156
Slide 156 text
App - Capture form
Slide 157
Slide 157 text
App - Capture form
Slide 158
Slide 158 text
App - Capture form
Slide 159
Slide 159 text
App - Capture form
Slide 160
Slide 160 text
App - Recording slices list
Slide 161
Slide 161 text
App - Recording slices previews
Slide 162
Slide 162 text
App - Recording slices comments
Slide 163
Slide 163 text
App - Recording slices categorization
Slide 164
Slide 164 text
App - Recording slices categorization
Slide 165
Slide 165 text
App - Recording slices categorization
Slide 166
Slide 166 text
App - Recording slices searching
Slide 167
Slide 167 text
App - Recording slices searching
Slide 168
Slide 168 text
App - Recording slices searching
Slide 169
Slide 169 text
Demo
Slide 170
Slide 170 text
What’s next?
Future enhancements, ideas,
wishes.
Slide 171
Slide 171 text
Improvements, wishlist
● Smaller
● Single board
● More leads
● Panic button
● Remove RTC -> Interrupt
● Wireless
● Battery level & low battery indicator
● Audible “beeps”
● Power save mode, smart power on & off
Slide 172
Slide 172 text
Improvements, wishlist
Slide 173
Slide 173 text
Improvements, wishlist
Mayan Box (Mayan on a battery powered, wireless, single
board computer)
+
OpenHolter = ??
Slide 174
Slide 174 text
Improvements, wishlist
Solar powered, last mile, electrophysiologist office.
Slide 175
Slide 175 text
Improvements, wishlist
Solar powered, on-the-field, emergency electrophysiologist
station.