My name is Mariano and I am a biomedical engineer. I spent some weekends to design and realize a prototype of a low cost ECG device based on Arduino board connected via Bluetooth to an Android device (smartphone or tablet). I would like to share my "ECG SmartApp" project with you and you will find all instructions and software to build the ECG device. The device is intended only as a design research project and it is NOT a medical device so please read the Warnings before going on. The device is composed of a hardware board to acquire the ECG signals from the body and an Android App to record, process and store the signals.
The simple circuit design and layout are a good compromise for having both a low cost (few components) and good performance.
By excluding the Smartphone and disposable parts (electrodes and batteries), the device whole cost is around 40 Euros (43 US dollars).
This ECG device project is intended only as a design research project and it is NOT a medical device, so please read the Warnings and safety issues in the next step before going on.
Step 1: Warnings
This ECG device project is intended only as a design research project and it is NOT a medical device. Use ONLY battery (max voltage supply: 9V). DO NOT use any AC power supply, any transformer or any other voltage supply to avoid serious injury and electrical shock to yourself or others. Do not connect any AC-line powered instrumentation or device to the ECG device here proposed. The ECG device is electrically connected to a person and only low voltage batteries (max 9V) must be used for safety precautions and to prevent damage to the device. Placement of the electrodes on the body provides an excellent path for current flow. When the body is connected to any electronic device, you must be very careful since it can cause a serious and even fatal electric shock. The authors cannot be responsible for any harm caused by using any of the circuits or procedures described in this manual. The authors do not claim any of the circuits or procedures are safe. Use at your own risk. It is imperative that anyone who wants to build this device has a good understanding of using electricity in a safe and controlled manner.
Step 2: Needed Software Files (Android App and Arduino Sketch)
The ECG device can be built easily and only a basic knowledge of electronics is needed to realize the hardware circuit. No software programming knowledge is required since all you need is to install the App by opening the apk file from an Andriod smartphone and to upload the provided Arduino sketch on the Arduino board (this can be done easily by using the Arduino Software IDE and one of the many tutorials available on the web).
Step 3: Description
The device is battery powered and consists of a front-end circuit to acquire the ECG signals (limb leads only) through common electrodes and an Arduino board to digitalize the analog signal and transmit it to an Android smartphone via Bluetooth protocol. The related App visualizes the ECG signal in real time and gives the possibility to filter and store the signal in a file.
Step 4: Assembly Manual & User Manual
All detailed instruction to build the ECG device can also be found in the Assembly Manual file while all the info to use it are described in the User Manual file.
Step 5: HARDWARE DESCRIPTION
The simple circuit design and layout are a good compromise for having both a low cost (few components) and good performance.
The battery supplies (+Vb) the Arduino board and the led L1 when the device is turned on (R12 = 10 kOhm controls L1 current); the rest of the device is supplied by the Arduino 5 V voltage output (+Vcc). Basically the device works between 0 V (-Vcc) and 5 V (+Vcc), however the single supply is converted to dual supply by a voltage divider with equal resistors (R10 and R11 = 1 MOhm), followed by a unity gain buffer (1/2 TL062). The output has 2.5 V (the mid-voltage of the TL062 power supply: 0-5 V); the positive and the negative rails of power then give a dual supply (± 2.5 V) with respect to the common terminal (reference value). The capacitors C3 (100 nF), C4 (100 nF), C5 (1 uF, electrolytic) and C6 (1 uF, electrolytic) make the voltage supply more stable. For safety issue, each electrode is connected to the device through a protection resistor of 560 kOhm (R3, R4, R13) to limit the current flowing into the patient in case of a fault inside the device. These high resistors (R3, R4, R13) should be used against the rare situation when the low voltage power (6 or 9 V, according to the used battery supply voltage) comes directly to the patient leads accidentally, or due to the INA component failing. Besides, two CR high pass filters (C1-R1 and C2-R2), placed at two inputs, block the dc current and reduce unwanted dc and low-frequency noise generated by contact potentials of electrodes. ECG signal is so high pass filtered before the amplifying stage with a cut off frequency around 0.1 Hz (at -3 dB). The presence of R1 (as R2) reduces the input impendence of the pre-amplification stage so that the signal is reduced by a factor depending on the value of the R1 and R3 (as R2 and R4); such factor can be approximated as:
R1 / (R1 + R3) = 0.797 if R1 = 2.2 MOhm and R2 = 560 kOhm
It is more advisable to choose the couple C1 - C2 (1 uF, film capacitor) with capacity values very close each other, the couple R1- R2 (2.2 MOhm) with resistance values very close each other and the same for the couple R3 - R4. In this way, an unwanted offset is reduced and not amplified by the instrumentation amplifier (INA128). Any mismatch between circuit parameters of the components in the dual input circuit contributes to a degradation of the CMRR; such components should be very well matched (even the physical layout) so that their tolerance should be chosen as low as possible (alternatively the operator can measure their values manually with a multimeter in order to choose the couple components with the values as close as possible). R5 (2.2 kOhm) defines the INA128 gain according to the formula:
G_INA = 1 + (50 kΩ / R5)
ECG signal is so amplified by the INA and successively high pass filtered by C7 and R7 (with a -3 dB cut off frequency around 0.1 Hz if C7 = 1 uF and R7 = 2.2 MOhm) to eliminate any dc offset voltage before the last and higher amplification made by the operation amplifier (1/2 TL062) in a non-inverting configuration with a gain:
G_TL062 = 1 + (R8 / (Rp+R6))
To let the user change the gain at runtime, the operator can choose to use a variable resistor (trimmer / potentiometer) instead of Rp or a female socket strip for a resistor that can be changeable (because not soldered). However, in the first case it is not possible to know exactly the actually gain of the ECG signal (the values in mV of the data will be not correct) while in the second case it is possible to have the correct values in mV by specifying the value of Rp in the formula “Gain” inside the “Setting” section of the app (see User Manual). C8 capacitor creates a low pass filter with a -3 dB cut off frequency around 40 Hz as the RC filter composed by R9 and C9. The cut-off frequency value is given by the formula:
f= 1 / (2*π*C*R).
For low pass filters @ 40 Hz , RC components values are:
R8 = 120 kOhm , C8 = 33 nF , R9 = 39 kOhm , C9 = 100 nF
The ECG signal is so filtered in a band between 0.1 and 40 Hz and amplified with a gain equal to:
Gain = 0.797 * G_INA * G_TL062
Since R5 = 2,2 kOhm , R8=120 kOhm, R6=100 Ohm, Rp=2,2 KOhm ,
Gain = 0.797 * (1+50000 / 2200) * (1+120000 / (2200 + 100)) = 1005
To have accurate values for the filter cut-off frequencies, RC filter components should have a tolerance as low as possible (alternatively the operator can measure their values manually with a multimeter in order to choose the ones closest to the desired value).
The analog signal is digitalized by the Arduino board (A0 input channel) and then transmitted to the HC-06 module by the serial communication pins; finally, the data are sent to the smartphone by Bluetooth.
The reference electrode (black) is optional and can be excluded by removing the jumper J1 (or the operator can use a switch instead of the jumper). The circuit configuration is designed to work also with two electrodes; however, the reference electrode should be used to have a better signal quality (lower noise).
Step 6: COMPONENTS
By excluding the Smartphone and disposable parts (electrodes and batteries), the whole device cost is around 43 US dollars (here considered the single product; in case of a larger quantity, the price would go down).
For a detailed list of the all the components (description and approximate costs), please see Assembly Manual file.
Step 7: Need Tools
- Need Tools: tester, clippers, soldering iron, solder wire, screwdriver and pliers.
Step 8: HOW TO BUILD - Step1
- Prepare a perforated prototype board with 23x21 holes (around 62 mm x 55 mm)
- According to the PCB top layout showed in the figures, solder: resistors, connecting wires, female socket strip (for Rp) sockets, male and female header connectors (female header connectors position here reported in the figures is suitable for Arduino Nano or Arduino Micro), capacitors, Led
Step 9: HOW TO BUILD - Step2
- Connect all components according to the PCB bottom layout here showed.
Step 10: HOW TO BUILD - Step3
- Realize a wire connector for the battery using the battery strap/holder, female header connectors and heat shrink tubing; connect it to the PCB “con1” (connector1)
Step 11: HOW TO BUILD - Step4
- Realize three electrodes cables (using the coaxial cable, female header connectors, heat shrink tubing, alligator clip) and connect them to the PCB tightening them to the board with some rigid cables
Step 12: HOW TO BUILD - Step5
- Realize a switch (using the slide switch, female header connectors, heat shrink tubing) and connect it to the PCB
- Place the INA128, TL062 and Rp resistor into the correspondent sockets
- Program (see Software Description section) and connect the Arduino Nano board (perforated prototype board and female header connectors should be adjusted on the PCB if another Arduino board (e.g. UNO or Nano) is used)
- Connect the HC-06 module to PCB “con2” (connector2)
Step 13: HOW TO BUILD - Step6
- Connect the jumper J1 to use the reference electrode
- Connect the battery
Step 14: HOW TO BUILD - Step7
- Place the circuit inside a suitable box with holes for the Led, the cables and the switch.
A more detailed description is shown in the Assembly Manual file.
Step 15: OTHER OPTIONS
- The ECG signal for monitoring application is filtered between 0.1 and 40 Hz; the upper band limit of the low pass filter can be increased by changing R8 or C8 and R9 or C9.
- Instead of the Rp resistor, a trimmer or potentiometer can be used to change the gain (and amplify the ECG signal) at runtime.
- The ECG device can work also with different Arduino boards. Arduino Nano and Arduino UNO were tested. Other boards can be used (such as Arduino Micro, Arduino Mega, etc.) however the provided Arduino sketch file needs modifications according to the board features.
- The ECG device can work also with the HC-05 module instead of HC-06 one.
Step 16: SOFTWARE DESCRIPTION
No software programming knowledge is required.
Arduino Programming: Arduino sketch files can be uploaded on the Arduino board easily by installing the Arduino Software IDE (free download from the Arduino official website) and following the tutorial available on Arduino official web site. A single sketch file (“ECG_SmartApp_skecht_arduino.ino”) for both Arduino Nano and Arduino UNO is provided (the sketch was tested with both the boards). The same sketch should work also with Arduino Micro (this board was not tested). For other Arduino board, the sketch file may need changes. Installing the ECG SmartApp: To install the App, copy the provided apk file “ECG_SmartApp.apk” (or “ECG_SmartApp_upTo150Hz.apk” in case of the version for bandwidth at 150 Hz) on the smartphone memory, open it and follow the instruction by accepting the permissions. Before installing, it may be needed to change the smartphone setting by allowing installation of app from unknown sources (tick the box of “Unknown sources” option of the “Security” menu). To connect the ECG device with the HC-06 (or HC-05) Bluetooth Module, pairing code or password may be asked in case of the first Bluetooth connection with the module: enter “1234”. If the App does not find the Bluetooth Module, try to pair the smartphone with the HC-06 (or HC-05) Bluetooth Module by using the smartphone Bluetooth Setting (pairing code “1234”); this operation is needed only once (first connection).
Step 17: Source Files
Optional Source files are available here to modify or personalize the App. However, Android programming skills are needed.
Step 18: START WITH ECG SMARTAPP - Step1
- Be sure that the battery (max voltage supply: 9V) connected to the device is charged
- Clean the skin before placing electrodes. Dry dead skin layer, usually present on the surface of our body, and possible air gaps between the skin and the electrodes do not facilitate the ECG signal transmission to the electrodes. So a moist condition between the electrode and the skin is needed. The skin needs to be cleaned (tissue cloth soaked with alcohol or at least water) before placing the electrode gel pads (disposable).
- Place the electrodes according to the table below. In case of a non-disposable electrode, electrode conductive gel (available commercially) should be used between the skin and the metal electrode or at least a pad of cloth tissue soaked in tap water or in saline solution.
The device allows to record the ECG (LI, LII or LIII) also by using only 2 electrodes; the reference electrode (black) is optional and can be excluded by using a switch or removing the jumper J1 (see Assembly Manual). However, the reference electrode should be used to have a better signal quality (lower noise).
Step 19: START WITH ECG SMARTAPP - Step2
- Power on the ECG device by using the switch (red led turns on)
- Run the App on the smartphone
- Press the button “ON” to connect the smartphone to the ECG device (the App will ask you the permission to turn on Bluetooth: press “Yes”) and wait for the discovery of the HC-06 (or HC-05) Bluetooth Module of the ECG device. Pairing code or password may be asked in case of the first Bluetooth connection with the module: enter “1234”. If the App does not find the Bluetooth Module, try to pair the smartphone with the HC-06 (or HC-05) Bluetooth Module by using the smartphone Bluetooth Setting (pairing code “1234”); this operation is needed only once (first connection)
- When the connection is established, the ECG signal will appear on the screen; in case of LI (default lead is LI, to change lead please go to the “Setting” paragraph) the heart rate (HR) will be estimated in real time. The signal will be updated every 3 seconds
- To apply a digital filter, press “Filter” button and choose a filter from the list. By default, a low pass filter @ 40 Hz and a notch filter (according to the preferences saved in the Setting) are applied.
Step 20: SETTINGS
- Press the button “Set.” to open the setting/preferences page
- Press “User Manual (help.pdf)” to open the user manual file
- Select the ECG lead (LI is default)
- Select the notch filter frequency (according to the interference frequency: 50 or 60 Hz)
- Select the file saving option to save the ECG signal filtered or unfiltered on the file
- Press the button “Save settings” to save the preferences
Gain value can be changed in case of hardware modification or personalization of the ECG device.
Step 21: RECORDING ECG SIGNAL
- Insert the file name (if the user records more ECG signals in the same session without changing the file name, a progressive index is added at the end of the file name to avoid overwriting the previous recording)
- Press “Rec.” button to start recording the ECG signal
- Press “Stop” button to stop the recording
- Each ECG signal will be stored in a txt file inside the folder “ECG_Files” placed in the main root of the smartphone memory. ECG signal can be stored filtered or unfiltered according to the preferences saved in the setting
- Press “Restart” button to visualize again the ECG signal acquired in run time
- To record a new ECG signal, repeat the previous points
An ECG file contain the series of the samples (sampling frequency: 600 Hz) of the ECG signal amplitude in mV.
Step 22: OPENING AND ANALYZE AN ECG FILE
- Press “Open” button: a list of the files stored in the “ECG_Files” folder will appear
- Choose the ECG file to be visualized
The first part of the ECG file will be displayed (10 seconds) with no grid.
The user can scroll manually on the display to visualize any time interval of the ECG signal.
To zoom in or zoom out the user can press on the magnifying glass icons (right corner at the bottom of the graph) or use the pinch zoom directly on the smartphone display.
Time axis, voltage axis and the standard ECG grid will automatically appear when a time interval lower than 5 seconds will be visualized (by zooming in). Voltage axis (y-axis) values are in mV while time-axis (x-axis) values are in seconds.
To apply a digital filter, press “Filter” button and choose a filter from the list. By default a low pass filter @ 40 Hz, a filter to remove the wandering line and a notch filter (according to the preferences saved in the setting) are applied. The graph title displays:
- the file name
- the ECG frequency band according to the applied filters
- the label “wandering baseline removed” if the wandering baseline filter is applied
- the label “~ 50” or “~ 60” according to the applied notch filter
The user can make measurements (time interval or amplitude) between two points of the graph by using the “Get Pt1” and “Get Pt2” buttons. To choose the first point (Pt1) the user can press “Get Pt1” and select manually a point of the ECG signal by clicking directly on the graph: a red point will appear on the ECG blue signal; if the user misses the ECG curve, no point will be selected and the “no point selected” string will appear: the user has to repeat the selection. The same procedure is needed to choose the second point (Pt2). In this way, the differences (Pt2 – Pt1) of the time values in ms (dX) and the amplitude values in mV (dY) will be displayed. The “Clear” button clears the selected points.
The user can adjust the ECG signal gain by using the “+” button (to enlarge) and “-“ button (to reduce); maximum gain: 5.0 and minimum gain: 0.5
Step 23: FILTERS MENU
- NO digital Filter: remove all applied digital filters
- Remove wandering baseline: apply a particular processing to remove the wandering of the baseline. In case of a signal very noisy, the processing may fail
- High pass ‘x’ Hz: apply an IIR high pass filter according to the specified cut off frequency ‘x’
- Low pass ‘x’ Hz: apply an IIR low pass filter according to the specified cut off frequency ‘x’
- 50 Hz removal ON (notch+LowPass 25 Hz): apply a particular very stable FIR filter that is both a notch at 50 Hz and a Low Pass at around 25 Hz
- 60 Hz removal ON (notch+LowPass 25 Hz): apply a particular very stable FIR filter that is both a notch at 60 Hz and a Low Pass at around 25 Hz
- 50 Hz removal ON: apply a recursive notch filter at 50 Hz
- 60 Hz removal ON: apply a recursive notch filter at 60 Hz
- 50/60 Hz removal OFF: remove the applied notch filter
Step 24: HARDWARE SPECIFICATIONS
- Max Input signal amplitude (peak-to-peak): 3.6 mV (Max Input signal amplitude depends on the hardware gain)
- Voltage supply: USE ONLY BATTERIES (both rechargeable and not rechargeable)
- Min Voltage supply: 6V (e.g. 4 x 1.5V batteries)
- Max Voltage supply: 9V (e.g. 6 x 1.5V or 1 x 9V batteries)
- Sampling frequency: 600 Hz
- Frequency Bandwidth @ - 3dB (Hardware): 0.1 Hz - 40 Hz (The upper band limit of the low pass filter can be increased up 0.1 Hz - 150 Hz, by changing RC filter components (see Assembly Manual)
- CMRR: min1209 dB
- Amplification (Hardware_Gain): 1005 (it can be changed by replacing the gain resistor (see Assembly Manual) - Resolution: 5V / ( 1024 x Hardware_Gain )
- Bias Current max 10 nA - Number of ECG channels: 1
- ECG Leads: limb leads LI, LII and LIII
- Smartphone connection: via Bluetooth
- Theoretical Supply Current: < 50 mA (Based on the datasheet info of the different components)
- Measured Supply Current: < 60 mA (With a 9V voltage supply and Arduino Nano)
- Number of electrodes: 2 or 3
The device allows to record the ECG (LI, LII or LIII) also by using only 2 electrodes; the reference electrode (black) is optional and can be excluded by removing the jumper J1 (or the switch S2, see Assembly Manual file). However, the reference electrode should be used to have a better signal quality (lower noise).
Step 25: SOFTWARE SPECIFICATIONS
- ECG visualization during the recording (time window: 3 seconds)
- Heart Rate estimation (only for LI)
- Sampling frequency: 600 Hz
- ECG signal recording and saving into a txt file (filtered or unfiltered signals can be saved in the txt file according to the setting) on the smartphone internal memory (folder: “ECG_Files” placed in the main root)
- Data (samples) are saved as values in mV at 600 Hz (value of 16 digits)
- Saved file visualization with zoom option, grid, gain adjusting (from “x 0.5” to “x 5”) and two points selection (to measure time distance and amplitude difference)
- Smartphone display: the App layout adjusts for different display size; however for a better visualization, it is recommended minimum a 3.7’’ display with a resolution of 480 x 800 pixels
- High pass filtering @ 0.1 , 0.15 , 0.25 , 0.5, 1 Hz
- Low pass filtering @ 25, 35, 40 Hz (@ 100 and 150 Hz are available in the ECG SmartApp version for bandwidth at 150 Hz)
- Notch filtering to remove the powerline interference @ 50 or 60 Hz
- Wandering baseline removal
Step 26: GET IN TOUCH !
Participated in the
First Time Author