The electrocardiogram (ECG) is an important parameter for analyzing the cardiac system. It serves as the primary diagnostic tool for patients with suspected heart disease, guiding appropriate cardiac investigations according to the disease or condition suspected. However, ECG measurements may generate noise, leading to false diagnoses. The wavelet transform is an effective and widely-used technique for eliminating noise. Typically, analysis and generation algorithms are developed on computer and using software built in. This paper presents a noise elimination algorithm based on the wavelet transform method, designed to operate on resource-limited Node microcontroller unit (MCU). An efficiency study was conducted to determine the optimum mother wavelet implementation of the algorithm, and the results showed that, when considering synthetic ECG signals, db4 was the most suitable for eliminating interference by achieving the highest signal to noise ratio (SNR) and correlation coefficient. In addition, this algorithm prototype can analyze ECG signals using the wavelet transform method processed in a microcontroller and is accurate compared to reliable programs. It has the potential to be further developed into a low-cost portable ECG signal measurement tool for use in remote medicine, healthcare facilities in resource-limited areas, education and training, as well as home monitoring for chronic patients.
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
Β
Electrocardiogram signal processing algorithm on microcontroller using wavelet transform method
1. International Journal of Electrical and Computer Engineering (IJECE)
Vol. 14, No. 2, April 2024, pp. 1530~1543
ISSN: 2088-8708, DOI: 10.11591/ijece.v14i2.pp1530-1543 ο² 1530
Journal homepage: http://ijece.iaescore.com
Electrocardiogram signal processing algorithm on
microcontroller using wavelet transform method
Akkachai Phuphanin, Metha Tasakorn, Jeerapong Srivichai
Department of Electrical Engineering, Faculty of Industry and Technology, Rajamangala University of Technology Isan,
Sakon Nakhon, Thailand
Article Info ABSTRACT
Article history:
Received Sep 7, 2023
Revised Oct 26, 2023
Accepted Nov 17, 2023
The electrocardiogram (ECG) is an important parameter for analyzing the
cardiac system. It serves as the primary diagnostic tool for patients with
suspected heart disease, guiding appropriate cardiac investigations according
to the disease or condition suspected. However, ECG measurements may
generate noise, leading to false diagnoses. The wavelet transform is an
effective and widely-used technique for eliminating noise. Typically,
analysis and generation algorithms are developed on computer and using
software built in. This paper presents a noise elimination algorithm based on
the wavelet transform method, designed to operate on resource-limited Node
microcontroller unit (MCU). An efficiency study was conducted to
determine the optimum mother wavelet implementation of the algorithm,
and the results showed that, when considering synthetic ECG signals, db4
was the most suitable for eliminating interference by achieving the highest
signal to noise ratio (SNR) and correlation coefficient. In addition, this
algorithm prototype can analyze ECG signals using the wavelet transform
method processed in a microcontroller and is accurate compared to reliable
programs. It has the potential to be further developed into a low-cost
portable ECG signal measurement tool for use in remote medicine,
healthcare facilities in resource-limited areas, education and training, as well
as home monitoring for chronic patients.
Keywords:
De-noise signal
Electrocardiogram
Microcontroller
Mother wavelet
Signal processing
Wavelet transform
This is an open access article under the CC BY-SA license.
Corresponding Author:
Akkachai Phuphanin
Department of Electrical Engineering, Faculty of Industry and Technology, Rajamangala University of
Technology Isan
Sakon Nakhon Campus, 47160, Thailand
Email: akkachai.ph@rmuti.ac.th
1. INTRODUCTION
Medical professionals and patients may be shielded from coronavirus disease starting in 2019
(COVID-19) exposure by telemedicine and eHealth platforms, which use high-speed communications
networks and application software for the delivery, management, and monitoring of medical services [1]. It is
evident that eHealth and telemedicine systems are crucial for addressing COVID-19 on a worldwide scale
[2]. As the disease spreads around the globe, medical facilities utilize telemedicine and eHealth platforms in a
variety of ways to improve patient care [3]. These include decreased medical expenses, diminished worker
tiredness, more worker sustainability, diminished physician exposure, and diminished need of personal
protective equipment (PPE) suits, such as dust filter masks and respirators [4].
In addition to the remote medical software platform, there are algorithms embedded in the remote
medical system. An algorithm that makes it easier to administer patient summaries that have been analyzed
by remote analytics [5], [6]. In order to deliver the most recent information, artificial intelligence (AI)
2. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1531
chatbot is used. Regarding COVID-19, it offers prevention recommendations as well as potential societal
remedies. It also provides real-time situation reports to medical practitioners [5]. A COVID-19 screening tool
is now being developed using AI to offer preliminary testing for patients with symptoms. and, if required,
suggest additional medical care. However, when there is sufficient and reliable data, both application
software platforms and AI chatbots will become more valuable and significant. As a result, a lot of research
has been done on developing mobile medical devices that include internet of things (IoT) technologies.
Patients can independently measure the fundamental variables required for diagnosis and transmission to
medical staff.
One of the most crucial physiological measures is pulse. The term "pulse" describes the pressure
produced as blood vessels expand and same in time with the heart's rhythmic contraction and expansion.
Therefore, the blood flow wave in the aorta that causes an aneurysm is caused by pulse rate [6]. Thus, heart
rate can be determined using pulse physiological parameters [7]. The study [6] presented an autonomous bed
shifting system for long-term bedridden patients using the patient's pulse rate as a measure of discomfort.
Disease monitoring is necessary because some medical problems necessitate long-term patient care,
especially in the case of chronic diseases [8]. Therefore, it is crucial to continuously check for such
occurrences. The monitoring of blood sugar levels, for instance, will vary depending on the individual. This
aids in scheduling activities, medications, and meals [9]. The architecture system was created using sensing
technology. The technology attempts to deliver real-time information on glucose levels and body
temperature. This also contains other data such as environmental temperature. This information is presented
graphically and is easily legible by humans for end users such as patients and healthcare professionals. A
remote monitoring system for individuals with persistent metabolic problems is described in the paper [8].
These include blood pressure and glucose monitors, smart scales, pulse oximeters, activity trackers, and
blood pressure monitors. The device is also capable of performing analyses that will help with medical
diagnostics.
Tele-ECG is a new IoT-based electrocardiogram (ECG) monitoring device that enables remote
medical monitoring of the condition of the heart [10]. The systems are still inferior to instruments used by
experts. However, by monitoring the patient's ECG over time, the procedure offers basic surveillance. The
ECG, which displays the heart's recorded electrical activity via electrodes on the body's surface, is thought to
be one of the most recognizable representations of heart function [10]. Heart electrical activity and heart rate
fluctuations are measured by physiological parameters ECG [11].
Applications for IoT and health surveillance are presented in the research [12]. Through sensors and
portable devices, the system is intended to capture ECG data together with other healthcare data. The author
also discusses on safely uploading these data to the cloud. This enables immediate access to medical
specialists. Given that earlier systems were expensive and had huge mounting locations, some researchers
[11] have suggested a 12-lead ECG system. Because of this, the suggested solution is portable and has
produced successful outcomes for home isolate systems. Additionally, ECG data can be sent from a distant
area to any point in the world to a medical specialist. Neyja et al. [13] proposed low-cost ECG health
monitoring system using internet of things with automated analytics and alarms includes energy-efficient
wearable sensor devices. The systems are linked to a smart gateway that can be accessed by cardiovascular
caregivers.
To monitor patients' ECG signals using a mobile tele-ECG application and do health assessments
without a doctor's involvement, was developed by Choudhari et al. [10]. The hidden Markov model (HMM)
and ECG sensors-based healthcare system implementation proposal was proposed by Nurdin et al. [14] with
the intention of enhancing patient monitoring and immediate patient assistance in case patients with diseases
related to the cardiovascular system. The construction of an ECG monitoring system was then described by
Rizqyawan et al. [15], in which the user can use the system while ECG signals are being transmitted. Finally,
DβAloia et al. [16] suggested that the design, execution, and development of ECG follow-up research.
According to research articles [10]β[16], it is a remote medical system that transmits ECG signals
obtained from sensors and transmitted via the Internet to medical personnel via the internet of things. These
studies, however, only send the raw sensor data collected from them without filtering the ECG signal, which
can result in inaccuracies in the ECG. The medical professionals will diagnose patients incorrectly if they
receive muddled signals because of noise. Only study [12], [14] suggested a technique to measure R-R peaks
to calculate heart rate, and the algorithm may be prone to errors if the ECG data contains noise.
The measured ECG readings are contaminated by noise. ECG noise can take many different forms,
including: Random noise called as gaussian noise occurs during transmission, Muscular artifacts or noise
caused by muscle contractions (MA). Electrode motion interference caused by the movement of the body,
which moves the electrode and amplifies the signal. The chest region moves equally as a result of breathing,
creating baseline wander (BW) noise [17]. The ECG activity data is obscured by all four noises, which can
also lead to incorrect heart rate estimations and difficult R peak detection.
3. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1532
In paper [18] discusses the results of using different types of wavelet filters with various thresholds
and levels to de-noise ECG signals. The study concludes that the wavelet filter is a good choice for de-
noising ECG signals due to its ability to suit many signals and applications. However, it is crucial to choose
the appropriate wavelet filter type that is similar to the signal in shape or close to its shape. The study finds
that the four-level Daubechies (db4) type is optimal for the Massachusetts institute of technology-Beth Israel
arrhythmia (MIT-BIH) database, while the level two of Symlets 4 (sym4) is suitable for ECG signals from
the monitoring system. The discrete wavelet transform (DWT) based wavelet denoising technique is used
with three different wavelet functions and four different thresholding methods [19]. The study involved the
analysis of ECG signals collected from a cohort of ten female participants aged between 20 and 25 years.
These signals were obtained while employing the Stroop color-word test as a means of inducing mental
stress. The result shows that the Coiflets 5 (coif5) wavelet function and the and rigrsure thresholding rule are
the most effective for removing noise from ECG signals, as demonstrated.
Within the scope of study [20], an innovative approach is introduced for the purpose of reducing
noise in ECG signals through the utilization of wavelets. The methodology centers around the application of
a genetic algorithm, which systematically explores an extensive array of quadrature filter banks. Its objective
is to identify the optimal filter bank that results in the minimal signal-to-noise ratio (SNR). Consequently, the
wavelet and scaling functions associated with the selected filters are acknowledged as the most effective
choice for achieving the task of de-noising. Simulation results show that using the proposed method and the
obtained wavelet improves the SNR of the noisy ECG signal by about 2.5 dB. While Majumdar [21]
describes a proposed method for de-noising ECG signals using wavelet energy and a sub-band smoothing
filter. In contrast to the conventional approach of wavelet threshold de-noising, this novel method exclusively
targets wavelet coefficients necessitating threshold de-noising, determined through wavelet energy analysis.
Meanwhile, it retains the original values of other coefficients. Furthermore, the technique incorporates a
sub-band smoothing filter to amplify the ECG signal's quality through advanced noise reduction. The
experimental results show that the proposed method effectively removes noise from the noisy ECG signals
compared to existing methods.
In recent years, advancements in medical research have led to significant breakthroughs in the field
of cardiac health and diagnostics. One notable area of progress has been the development of innovative
techniques for analyzing ECG signals, aiming to detect critical features like the QRS complex and R-peaks
with remarkable accuracy and efficiency. Research such as study [22] highlights the integration of chaos
analysis, short-time Fourier transform (STFT), and principal component analysis (PCA) to automate QRS
complex detection, offering impressive sensitivity and accuracy rates. In a similar vein, Gupta et al. [23]
introduces a novel application of PCA for R-peak detection, avoiding the need for pre-processing in noisy
ECG signals. Meanwhile, Gupta et al. [24] presents a computer-aided diagnosis system utilizing chaos
analysis to extract non-linear patterns in ECG signals, enhancing arrhythmia detection. Beyond ECG
analysis, other studies such as studies [25] and [26] apply machine learning techniques to retinal blood vessel
segmentation and the identification of high-risk carotid artery plaques, demonstrating the potential for
automated disease detection and prevention. Additionally, research like [27] explores the importance of
collateral circulation in preserving myocardium during coronary artery occlusion, emphasizing the need for
accurate collateral flow assessment in surgical planning. Furthermore, Li et al. [28] introduces a motion
compensation method for 3D coronary artery reconstruction, which proves effective in reducing artifacts and
improving image quality. Finally, Velut et al. [29] analyzes coronary trees using magnetic resonance
angiography (MRA) to estimate the capability of MRA in providing insights into the vascular network. This
collective body of research represents a significant leap forward in the diagnosis and treatment of cardiovascular
and arterial conditions, promising enhanced accuracy, automation, and patient care in the field of cardiac health.
The utilization of wavelet transform, an advanced and effective technique for noise reduction, has
gained prominence in enhancing the performance of ECG signal processing algorithms, as demonstrated in
previous studies [18]-[29]. However, it is noteworthy that, up to this point, wavelet transform-based signal
processing has primarily been confined to traditional computer-based processing platforms and software
applications like MATLAB and LabVIEW. One notable gap in the existing research landscape is the limited
exploration of implementing wavelet transform algorithms for ECG signal processing within embedded
systems, specifically microcontrollers. To date, there has been a dearth of investigations into the adaptation
of wavelet transform techniques to microcontroller-based ECG signal processing. This represents an
uncharted territory in which the potential benefits of wavelet transform, known for its efficacy in noise
reduction, have yet to be fully realized. Therefore, this research endeavors to bridge this gap by presenting a
novel approach: the application of wavelet transforms principles for ECG signal processing on a
microcontroller, specifically the node MCU. This pioneering effort seeks to unlock the advantages of wavelet
transform in noise elimination within the context of resource-constrained embedded systems, potentially
extending its utility to a broader range of real-world applications.
4. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1533
2. ECG SIGNAL PROCESSING PROCESS
There is noise in the measured ECG data. A data processing step is required to get rid of the noise
and get a clear signal. Signal processing entails two steps: Wideband noise removal and baseline wandering
noise removal both employ the wavelet transform approach. Wavelet transform: wavelet transform is a
commonly used method for signal estimation [30], [31] and signal compression [32]. Since the Fourier
transform simply analyzes the signal in terms of frequency, the wavelet transform transforms the signal to be
considered in terms of position and frequency [30]. So, the wavelet transforms signal exhibits less distortion
as a result. The ECG signal is also a type of non-stationary signal since it represents the electrical activity of
the heart during each heartbeat, which changes over time [33]. A Fourier transform that is appropriate for the
analysis of discrete signals is therefore inappropriate. The wavelet transform's foundation is the extraction of
the signal's edge components so that each sub-characteristics components can be considered [31]. Definition
of wavelet transformation in mathematics constant is
π(π, π) = β« π(π‘)ππ,π(π‘)ππ‘
β
ββ
(1)
ππ,π(π‘) =
1
βπ
πβ
(
π‘βπ
π
) (2)
When π(π‘) is signal, ππ,π(π‘) is an analytical function with a time shift, scalability feature. In
practice, we can use the discreate wavelet transform to calculate the coefficients for each order of
subcomponents (decomposition). The decomposition can use a set of finite impulse response (FIR) filters that
act as low pass filters and high pass filters. Then, reduce the sample frequency in half (down sampling). It is
possible to employ the discrete wavelet transform algebraically; the fundamental convolution procedures are
given
ππ
(π)
= β πππ2πβπ
(πβ1)
π = 1, 2, β¦ , π
πβ1
π=0 (3)
ππ
(π)
= β βππ2πβπ
(πβ1)
ππ
(0)
= π₯π
πβ1
π=0 (4)
When ππ
(π)
is approximation coefficients in component π of low pass filters and ππ
(π)
is detail coefficients in
component π of high pass filters. For input signal N and the coefficient of the low-pass filter (ππ) and high
pass filter (βπ) defined by the mother wave function [34]. The Daubechies 6 function (db06), which has a
signal structure resembling the ECG signal, was used for this study [35].
3. ECG SIGNAL PROCESSING ALGORITHM ON NODE MCU
An algorithm for ECG signal analysis using wavelet transform techniques on a node MCU
microcontroller consists of five blocks: ECG signal acquisition, moving average, wavelet transform, peak
detection, and heart rate calculation, as shown in Figure 1. The signal acquisition function stores the ECG
signal (block 1), which has a frequency of 125 Hz, in a data array. The data array requires two R-peaks for
heart rate calculations. To accurately capture both peaks of the heart rate data, a minimum of 200 data points
need to be collected in the array. Nonetheless, if the number of arrays is fewer than 200, it is possible that
two R-peaks may not be present in the louder array, potentially leading to erroneous heart rate calculations by
the algorithm. The captured ECG signal is affected by two types of noise: baseline noise, caused by breathing
or body movements, which has a low frequency, and wideband noise, caused by muscle artifacts and
instrumentation noise. Baseline noise and wideband noise are two types of noise that can affect the quality of
an electrocardiogram (ECG) signal. ECG is a vital medical test used to record the electrical activity of the
heart over time. Noise in the ECG signal can obscure important information and make it difficult to interpret
the results accurately. Therefore, both signals are incorporated into the original data for processing, allowing
us to assess the effectiveness of our proposed algorithm. Hence, within the program designed for embedded
into the microcontroller, it utilizes a total of 54,886 bytes of global memory (equivalent to 67% of the total
memory). In our simulation, all 10-second ECG signals are stored on an external memory card. The Node
MCU reads the data from the memory card and stores it in a data buffer as if it were reading from an ECG
sensor. When executing a single cycle of the program to process ECG signals, the average total execution
time is 249 milliseconds. This duration is deemed suitable for real-time display should the algorithm be
employed in real-life scenarios in the future.
The moving average function (block 2) is an alternative form of averaging that differs from the
conventional averaging method in which all data are averaged. Moving averages employ a fixed number of
windows to average and shift the windows according to the position of the data. In signal processing, moving
5. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1534
averages are utilized to smooth signals from short-term overshoots or fluctuations caused by noise, serving as
a high-pass filter. However, there exist filters that are more effective than moving average filters but are also
more complex and unwieldy. Thus, to reduce complexity and processing time to suit the capabilities of the
node MCU, this article utilizes a moving average for baseline noise elimination. Figure 2 illustrates the
working process of the moving average function. The process begins by initializing the window size to 49
and calculating the mean of the data in the window range. By adjusting the size of the moving window, you
can control the degree of noise reduction versus the level of detail preservation. Larger window sizes result in
greater noise reduction but can also smooth out genuine signal variations. Window scaling experiments show
that a window size of 49 is suitable for eliminating low-frequency noise generated in ECG signals. A window
size of 49 was chosen for the implementation of the moving average filter to effectively mitigate low-
frequency noise, such as baseline noise, in our simulations. The mean is computed using the position of the
data as the middle position of that window, and the position of the data is shifted until it reaches the data in
the last position. As a result of the moving average, we obtain a signal that resembles baseline noise.
Consequently, when we subtract this signal from the noisy ECG signal, we eliminate the baseline noise.
However, it is important to note that while moving average filters are effective for reducing low-frequency
noise, they may not be as effective at removing high-frequency noise or preserving sharp transitions in the
signal. The choice of filter type and parameters should be based on the specific characteristics of the noise
and the desired signal fidelity. Hence, an additional step is necessary to eliminate noise by employing
wavelet transform.
Figure 1. Flow diagram of algorithm ECG signal processing on Node MCU
Initialization: window=49, sum=0, k=0
for i=0 until i<length of ECG_noise
for j= β(windowβ1)/2 until j=(windowβ1)/2
if (iβj) not in range of ECG_noise
do nothing;
else
sum=sum+ECG_noise(iβj);
k=k+1;
end if
end for
base_line(i)=sum/k;
ECG_remove_baseline(i)=ECG_noise(i)βbase_line(i);
k=0;
end for
Figure 2. Pseudo code of moving average part
In wavelet transform function (block 3), a wideband noise elimination technique using wavelet
transform is employed. The wavelet transform is utilized to decompose a signal into its frequency
components, similar to the Fourier transform. However, the Fourier transform only provides the frequencies
contained in the signal and may not be applicable to all signals, such as ECG signals with sudden changes of
short duration. In contrast, wavelet transformation separates time-domain signal components by utilizing two
6. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1535
fundamental properties: scale and location. While the Fourier transform primarily provides frequency
information, the wavelet transform exhibits a distinct advantage when applied to signals characterized by
abrupt, short-duration changes, as is often the case with ECG signals. It is worth emphasizing that the
wavelet transform provides a dual perspective, offering insights into both frequency and time-domain
characteristics, rendering it particularly well-suited for the comprehensive analysis of ECG signals.
Moreover, wavelet transformations reduce the size of the data to half of the original size while preserving all
important characteristics. Therefore, wavelet transform was chosen to eliminate wideband confounding.
Figure 3 illustrates the discrete wavelet transform utilizing the convolution principle. The input signal (x) that
has been processed with baseline noise is convolved with the signal h, which is the filter coefficient of the
mother wavelet. The convolution process results in a signal with a length of (x) + length (mother wave) β 1.
Only the odd-numbered indices, which are the sum of the low-frequency component signals, are selected
from this result, known as the approximation coefficients. The approximation coefficients eliminate
wideband noise and reduce the size of the ECG signal by half, while preserving its essential characteristics.
This process also reduces the time required to calculate the maximum peak in the next step.
Initialization: Size of variable x, y, z =length of (x+h)β1
for i=0 until i<length of x
for j=0 until jβ€i
y(i)=y(i)+x(j)*h(iβj);
end for
end for
ECG_decomposition=odd index of y
Figure 3. Pseudo code of wavelet transform part
The function 4,5 in ECG signal processing is peak detection (block 4) and the calculation of the
heart rate (block 5) value of the data set. As the ECG signal data stored in the array (ECG_decomposition
array) only has two peaks, we can split the data into two parts and determine the maximum value in each
segment. The highest value in the first part corresponds to the highest peak R1, and the highest value in the
second part corresponds to the highest peak R2. The program will then store the position of each peak value.
The position values of the two R peaks are subsequently subtracted to determine the time difference, which is
then multiplied by 0.016 (βT=1/62.5) to find the heart rate frequency, expressed as the number of beats per
minute by multiplying by 60 seconds. This process is show in Figure 4.
Initialization: peak_1=0; peak_2=0;
Pos_peak1=0; Pos_peak2=0;
for i=0 until length(ECG_decomposition)/2
if ECG_decomposition(i)>peak_1
Pos_peak1=i;
end if
end for
for i=length(ECG_decomposition)/2 until length(ECG_decomposition)
if ECG_decomposition(i)>peak_2
Pos_peak2=i;
end if
end for
HR=(1/(Pos_peak2βPos_peak2)*0.016)*60;
Figure 4. Pseudo code of peak detection part and heartrate calculation
4. RESULTS AND DISCUSSION
As part of the experimental and performance analysis, as well as validation of the algorithm for
analyzing ECG signals using the wavelet transform technique developed for use on the node MCU board
presented in this article. We have divided the experiment into two parts to study the efficiency of using the
wavelet transform principle for noise elimination in ECG signals. Part one validates the noise elimination
algorithm for node MCU compared to reliable wavelet transform programs. The second part examines the
algorithm's performance against the normal human heart rate range (65-85 bpm), and analyzes and tests the
performance of the selected mother wavelet for synthetic ECG signal analysis.
7. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1536
To validate the ECG signal analysis algorithm employing the wavelet transform method
implemented on the node MCU board, we performed a comparative analysis of the results with a widely
recognized function in the reliable computer programs, known for its established credibility in ECG signal
analysis. Figure 5 illustrates an example of the comparative results, showing that the ECG signal analysis
algorithm utilizing the wavelet transform technique, executed on the node MCU board, exhibits similarities
to the use of pre-existing functions in reliable computer programs, with a correlation coefficient of 0.99. The
correlation coefficient indicates that the ECG signals processed by the algorithm running on the node MCU
exhibit similarity to those processed using the function within the robust program. This observation serves as
empirical evidence supporting the correctness and suitability of the wavelet transform algorithm implemented
on the node MCU for ECG signal analysis.
Figure 5. Comparison of the results of wavelet (Micro) with the function of computer programs
The second part of our study aims to analyze the selection of an appropriate mother wavelet for
processing ECG signals without interference to validate the true capabilities of the ECG signal processing
algorithms. To simulate pure ECG signals without any interference, we generated a simulated ECG signal
with varying heart rates of 65, 70, 75, 80, and 85 beats per minute at a sampling frequency of 125 Hz.
Investigating algorithm efficiency often involves introducing noise to the original signal. In a previous study
[36], noise was incorporated within a range of -12 to 12 dB to assess the performance of beat detection
algorithms. In our current research, we have introduced two specific types of noise: baseline noise with an
amplitude of 50 mV and wideband noise with a power level of 15 dB. Figure 6 provides an example of a
simulated ECG signal with a heart rate of 85 beats per minute. Figure 5 has been to visually represent the
ECG signal illustrating the efficacy of a window size of 49 in effectively eliminating the baseline noise in
Figure 6.
Figure 6. Synthetic ECG and Noisy synthetic ECG with heart rate 85 bmp
As mentioned earlier, the wavelet transform method relies on wavelet coefficients that function as
weights for each frequency component level. Therefore, it is essential to select a coefficient function for the
mother wavelet that is suitable for the signal being processed. However, previous studies have shown that the
use of different mother wavelets for ECG signal analysis yields varying performance results. Since ECG
signal analysis and noise elimination are typically performed on computers with ample computational
resources, wavelet transform method can be applied at multiple levels to obtain the best possible signal.
However, due to resource constraints on microcontroller boards, the ECG signal analysis algorithm presented
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Wavelet (computer programs) Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Noisy
8. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1537
here only performs a one-level wavelet transform. Therefore, to determine the most efficient and suitable
mother wavelet for the ECG signal analysis algorithm, we apply the wavelet transform method on a
microcontroller board. We evaluate the performance of several commonly used mother wavelets, including
db4, db5, db9, coif5, bior3.3, and Sym4, which have demonstrated high efficiency in past research.
Additionally, we test the basic mother wavelet Haar, which has the fewest coefficients among the mother
wavelets and requires less memory, to assess its performance and compare it with the other mother wavelets
commonly used for analyzing ECG signals. The choice of mother wavelets, including Harr, db4, db5, db9,
coif5, bior3.3, and Sym4, for evaluating their performance in ECG noise elimination is based on several
factors relevant to wavelet analysis and signal processing. These wavelets are part of a broader family of
wavelets with distinct properties, and their selection is motivated by various considerations. Firstly, the
selected wavelets belong to different wavelet families (e.g., Daubechies, Coifman, Biorthogonal, Symlet),
each characterized by unique properties and filtering capabilities. This diversity enables us to investigate the
influence of various wavelet families on the efficacy of ECG noise elimination. Figures 7 to 13 depicts a
comparison between the original ECG signal and the ECG signal processed to eliminate noise by the wavelet
transform method using different mother wavelets, namely Harr, db4, db5, db9, coif5, bior3.3, and Sym4. As
observed from the figure, the signal processing technique successfully eliminates the baseline noise with an
amplitude of 50 mV. However, for the wideband noise, the power of 15 dB can be eliminated but still leaving
a little amount. Moreover, the wavelet transform method resulted in higher amplitude peaks of ECG signals
Q, R, S, and T. However, the lowest amplitude P peak, which is close to the amplitude of the wideband noise,
is almost absent.
Figure 7. Result of ECG data processing algorithm using Harr wavelet with heart rate 85 bmp
Figure 8. Result of ECG data processing algorithm using db4 wavelet with heart rate 85 bmp
Figure 9. Result of ECG data processing algorithm using db5 wavelet with heart rate 85 bmp
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
9. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1538
Figure 10. Result of ECG data processing algorithm using db9 wavelet with heart rate 85 bmp
Figure 11. Result of ECG data processing algorithm using coif5 wavelet with heart rate 85 bmp
Figure 12. Result of ECG data processing algorithm using bior3.3 wavelet with heart rate 85 bmp
Figure 13. Result of ECG data processing algorithm using Sym4 wavelet with heart rate 85 bmp
We consider the simulated ECG signal as a pristine reference signal, characterized by its cleanliness
and clarity. This reference signal is subsequently subjected to the addition of both baseline and wideband
noise, thereby serving as a benchmark for evaluating the efficacy of the noise removal algorithm based on the
wavelet transform principle. To substantiate the effectiveness of ECG signal processing employing the
wavelet transform principle and to select the appropriate mother wavelet, we rely on quantitative measures
frequently employed in prior research. These measures encompass signal-to-noise ratio (SNR), correlation
coefficients between the original ECG signals and the processed signal (r), as well as the root mean square
error (RMSE), as defined by (5) to (7):
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original Wavelet (Micro)
-100
0
100
200
300
400
0 1 2 3 4 5 6 7 8 9 10
ECG
(mV)
Time (sec)
Original
10. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1539
πππ (ππ) = 10πππ10 (
β [π π(π)]2
πβ1
π=0
β [π ππ(π)βπ π(π)]2
πβ1
π=0
) (5)
π =
β (π πβπ π
Μ Μ Μ )β(π ππβπ ππ
Μ Μ Μ Μ Μ )
πβ1
π=0
ββ (π πβπ π
Μ Μ Μ )2
πβ1
π=0 β (π ππβπ ππ
Μ Μ Μ Μ Μ )2
πβ1
π=0
(6)
π πππΈ = β
1
π
β (π ππ(π) β π π(π))2
πβ1
π=0 (7)
when π π is the original ECG signal and π ππ is the processed ECG signal.
The SNR is a measure of the quality of a signal, indicating how much the signal power in a given
signal compares to the noise power. Figure 14 show the SNR of each mother wavelet used with different
heart rates, ranging from 65 to 85 bpm in increments of 5 bpm. The results indicate that the SNR of every
mother wavelet increases with increasing heart rate. Among the mother wavelets, the db4 wavelet exhibited
the highest SNR values for heart rates of 65, 70, 80, and 85 bpm, with values of 6.44, 6.67, 6.93, and 7.06,
respectively. In contrast, the db9 wavelet yielded the highest SNR at 75 bpm with a value of 6.90, while the
bior3.3 wavelet had the lowest SNR values overall. Figure 15 presents the average SNR values of all heart
rates to determine the mother wavelet that yielded the highest SNR. The db4 wavelet yielded the highest
mean SNR of 6.77, while the bior3.3 wavelet had the lowest mean SNR of 5.83. Heart rate, denoting the
frequency of heart beats per minute, serves as a fundamental physiological parameter. A higher heart rate
signifies an increased rate of cardiac contractions, resulting in a greater number of cardiac cycles occurring
within a specified temporal interval. In the context of ECG data, each cardiac cycle manifests as a distinctive
pattern characterized by key waveforms, including the P-wave, QRS complex, and T-wave. These
waveforms, collectively termed fiducial points, hold invaluable diagnostic information. Elevations in heart
rate correspond to a heightened occurrence of cardiac cycles per unit of time. Consequently, the fiducial
points (P, QRS, T) materialize more frequently within the ECG signal. This heightened frequency enhances
their distinctiveness amidst the backdrop of potential noise, thereby augmenting the SNR within the ECG
signal.
Figure 14. SNR of mother wavelets with different heart rates
Figure 15. Comparison between the mother wavelet in terms of the mean SNR
6.27
6.27
6.54
6.69
6.77
6.44
6.67
6.73
6.93
7.06
6.28
6.54
6.69
6.71
6.92
6.43
6.67
6.90
6.79
6.87
6.39
6.54
6.75
6.68
6.85
5.54
5.74
5.95
5.83
6.09
6.39
6.65
6.71
6.92
6.92
5.0
5.2
5.4
5.6
5.8
6.0
6.2
6.4
6.6
6.8
7.0
7.2
HR = 65 HR = 70 HR = 75 HR = 80 HR = 85
SNR
Heart rate (beats per minute)
Haar db4 db5 db9 coif5 bior3.3 Sym4
6.51
6.77
6.63
6.73
6.64
5.83
6.72
5.00
5.50
6.00
6.50
7.00
Haar db4 db5 db9 coif5 bior3.3 Sym4
SNR
Mother wavelet
11. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1540
Figure 16 show the correlation coefficient between the original ECG signal and the processed
ECG signal, wherein a value close to 1 indicates that the signal processing algorithm can eliminate a
significant amount of noise and that the processed ECG signal is similar to the original signal. From
Figure 16, it was observed that as the heart rate increased, the correlation coefficient also increased. This
observation corresponds to the SNR illustrated in Figure 14 because a high SNR indicates that the
algorithm can eliminate noise and leave only the original ECG signal, resulting in a high correlation
coefficient. Upon considering each mother wavelet, it was found that all mother wavelets yielded similar
correlation coefficients. However, db4, db9, coif5, and sym4 produced the highest correlation coefficients.
Figure 17 shows the average correlation coefficients of all heart rates, which demonstrated that the mother
wavelet with the highest correlation coefficient, db4 was 0.955. Figure 18. illustrates the RMSE for each
heart rate. It was discovered that when heart rates were at 65, 80, and 85, the utilization of the mother
wavelet db4 resulted in the lowest RMSE values of 28.95, 30.23, and 30.69, respectively. Meanwhile, the
mother wavelet db9 resulted in the lowest RMSE values at heart rates of 70 and 75, with values of 28.71
and 29.24, respectively. On the other hand, the mother wavelet bior3.3 produced the highest error, which
is consistent with the SNR and the lowest correlation coefficient. Figure 19. illustrates the average RMSE
across all heart rates, which was found to be the lowest for db4 at 29.74. A suitable mother wavelet for
ECG signals depends on several factors, including the characteristics of the ECG signal, the required
resolution in time and frequency domains, and the specific application of interest. One commonly used
mother wavelet for ECG signals is the Daubechies wavelet. It has a compact support, which means that it
is localized in time and frequency domains. This property makes it well-suited for analyzing signals with
abrupt changes, such as ECG signals that contain QRS complexes. Another commonly used mother
wavelet for ECG signals is the Symlet wavelet. It has similar properties to the Daubechies wavelet but
with slightly better time-frequency localization. Other wavelets that can be used for ECG signal analysis
include the Coiflet wavelet, the Biorthogonal wavelet, and the Harr wavelet. The choice of the mother
wavelet can also depend on the specific application of interest. It is important to note that the choice of the
mother wavelet is not the only factor that determines the performance of wavelet-based ECG signal
analysis methods. Other factors such as the decomposition level, thresholding method, and feature
extraction techniques should also be considered.
Figure 16. Correlation coefficient of mother wavelets with different heart rates
Figure 17. Comparison between the mother wavelet in terms of the mean correlation coefficient
0.933
0.938
0.946
0.952
0.960
0.940
0.948
0.955
0.961
0.968
0.939
0.945
0.952
0.958
0.966
0.941
0.949
0.955
0.960
0.968
0.941
0.948
0.955
0.960
0.967
0.931
0.938
0.946
0.950
0.959
0.940
0.949
0.955
0.960
0.967
0.85
0.87
0.89
0.91
0.93
0.95
0.97
0.99
HR = 65 HR = 70 HR = 75 HR = 80 HR = 85
Correlation
coefficient
Heart rate (beats per minute)
Haar db4 db5 db9 coif5 bior3.3 Sym4
0.946
0.955
0.952
0.954 0.953
0.945
0.954
0.940
0.945
0.950
0.955
0.960
Haar db4 db5 db9 coif5 bior3.3 Sym4
Correlation
coefficient
Mother wavelet
12. Int J Elec & Comp Eng ISSN: 2088-8708 ο²
Electrocardiogram signal processing algorithm on microcontroller using wavelet β¦ (Akkachai Phuphanin)
1541
Figure 18. RMSE of mother wavelets with different heart rates
Figure 19. Comparison between the mother wavelet in terms of the mean RMSE
In the context of R-wave identification, our algorithm stands out as a straightforward and efficient
solution suitable for implementation in microcontrollers. It exhibits a commendable ability to precisely
pinpoint the R-peaks within the array data, enabling us to subsequently compute the temporal separation
between these R-peaks in alignment with the data sampling frequency. However, it is worth noting that more
sophisticated algorithms, as referenced in [22], [23] are available for the accurate localization of QRS peaks.
When such algorithms are applied to determine the positions of these peaks with precision, the timing of
these peak occurrences can prove valuable in the diagnosis of heart diseases.
5. CONCLUSION
The article describes a study on the use of wavelet transform principles for analyzing ECG signals to
eliminate interference that may occur during measurement. The article presents an algorithm that can
eliminate interference using wavelet transform principles processed in a node MCU and a peak detection
algorithm for calculating heart rate. The algorithm was tested on both simulated and real ECG signals using
parameters such as SNR, correlation coefficient, and RMSE to evaluate performance. In the study of the
performance of the ECG signal processing algorithm, we conducted two tests. The first test aimed to validate
the accuracy of the wavelet transform algorithm used in the node MCU by comparing it with the computer
programβs built-in function. The results showed that the algorithm was accurate with a correlation coefficient
of 0.99. The second test aimed to determine the most suitable mother wavelet for selecting heart rate in the
range of 65-85 beats per minute, which is the normal human heart rate. The db4 mother wavelet was found to
be the most suitable, based on the best values of average SNR, correlation coefficient, and RMSE, which
were 6.77, 0.954, and 29.74, respectively. The results showed that the most appropriate mother wavelet for
signal processing in the simulation model was the db4 wavelet, which provided the highest average SNR and
correlation coefficient values. The db9 wavelet also provided a low average RMSE value and SNR and
correlation coefficient values that were similar to those of the db4 wavelet. In this paper, we demonstrate the
feasibility of implementing complex algorithms, such as the wavelet transform, for ECG noise elimination on
a small microcontroller. Furthermore, the test results demonstrate the accurate performance of the algorithm
for detecting the two R-peaks within the ECG array data, facilitating precise heart rate calculations.
Furthermore, we present the results obtained from employing various mother waveforms to analyze and
assess their efficiency. However, due to memory constraints, the frequency sampling rate was limited to
125 Hz, and the filter bank output frequency was reduced by half. This resulted in the wavelet transform
29.50
30.07
30.47
31.08
31.76
28.95
28.99
29.81
30.23
30.69
29.49
29.14
29.97
31.00
31.18
28.96
28.71
29.24
30.70
31.37
29.10
28.71
29.76
31.09
31.46
32.10
31.96
32.62
34.31
34.32
29.12
28.78
29.88
30.25
31.21
25
26
27
28
29
30
31
32
33
34
35
HR = 65 HR = 70 HR = 75 HR = 80 HR = 85
RMSE
Heart rate (beats per minute)
Haar db4 db5 db9 coif5 bior3.3 Sym4
30.57
29.74
30.16
29.79
30.02
33.06
29.85
29.0
29.5
30.0
30.5
31.0
31.5
32.0
32.5
33.0
33.5
34.0
Haar db4 db5 db9 coif5 bior3.3 Sym4
RMSE
Mother wavelet
13. ο² ISSN: 2088-8708
Int J Elec & Comp Eng, Vol. 14, No. 2, April 2024: 1530-1543
1542
being performed on only one level, which allowed some noise to remain in the signal. Increasing the
sampling rate or using more complex multiresolution algorithms to process the signals would be a challenge
in future research. Finally, the proposed algorithm prototype exhibits significant potential for a diverse range
of applications that extend beyond the realm of remote medicine. Notable among these applications are the
utilization in wearable health devices, remote monitoring, health and wellness Apps, healthcare facilities in
resource-limited areas, education and training, as well as home monitoring for chronic patients. These
identified applications underscore the algorithm's adaptability and its capacity to thrive within a spectrum of
healthcare and medical technology contexts, rendering it an asset for advancing cardiac care and diagnosis.
Within the constraints of price accessibility to the general public and the requisite quality standards.
REFERENCES
[1] K. Okereafor, O. Adebola, R. Djehaiche, M. El, and B. El, βExploring the potentials of telemedicine and other non-contact
electronic health technologies in controlling the spread of the novel coronavirus disease (Covid-19),β SSRN Electronic Journal,
vol. 8, pp. 1β14, Apr. 2020.
[2] J. Kaminski, βInformatics in the time of COVID-19,β Canadian Journal of Nursing Informatics, vol. 15, no. 1, 2020.
[3] A. Doshi, Y. Platt, J. R. Dressen, B. K. Mathews, and J. C. Siy, βKeep calm and log on: Telemedicine for COVID-19 pandemic
response,β Journal of Hospital Medicine, vol. 15, no. 5, pp. 302β304, Apr. 2020, doi: 10.12788/jhm.3419.
[4] J. E. Hollander and B. G. Carr, βVirtually perfect? telemedicine for Covid-19,β New England Journal of Medicine, vol. 382,
no. 18, pp. 1679β1681, Apr. 2020, doi: 10.1056/nejmp2003539.
[5] S. Nataraja and P. Nataraja, βIoT based application for e-health an improvisation for lateral rotation,β in RTEICT 2017 - 2nd IEEE
International Conference on Recent Trends in Electronics, Information and Communication Technology, Proceedings, May 2017,
vol. 2018-Janua, pp. 1018β1021. doi: 10.1109/RTEICT.2017.8256753.
[6] M. F. Domingues et al., βInsole optical fiber sensor architecture for remote gait analysis - an e-health solution,β IEEE Internet of
Things Journal, vol. 6, no. 1, pp. 207β214, Feb. 2019, doi: 10.1109/JIOT.2017.2723263.
[7] E. Patti, M. Donatelli, E. Macii, and A. Acquaviva, βIoT software infrastructure for remote monitoring of patients with chronic
metabolic disorders,β in Proceedings - 2018 IEEE 6th International Conference on Future Internet of Things and Cloud, FiCloud
2018, Aug. 2018, pp. 311β317. doi: 10.1109/FiCloud.2018.00052.
[8] T. N. Gia et al., βIoT-based continuous glucose monitoring system: A feasibility study,β Procedia Computer Science, vol. 109,
pp. 327β334, 2017, doi: 10.1016/j.procs.2017.05.359.
[9] L. Ungurean and A. Brezulianu, βAn internet of things framework for remote monitoring of the healthcare parameters,β Advances
in Electrical and Computer Engineering, vol. 17, no. 2, pp. 11β16, 2017, doi: 10.4316/AECE.2017.02002.
[10] V. Choudhari, V. Dandge, N. Choudhary, and R. G. Sutar, βA portable and low-cost 12-lead ECG device for sustainable remote
healthcare,β in Proceedings - 2018 International Conference on Communication, Information and Computing Technology,
ICCICT 2018, Feb. 2018, vol. 2018-Janua, pp. 1β6. doi: 10.1109/ICCICT.2018.8325879.
[11] M. S. Hossain and G. Muhammad, βCloud-assisted industrial internet of things (IIoT) - enabled framework for health
monitoring,β Computer Networks, vol. 101, pp. 192β202, Jun. 2016, doi: 10.1016/j.comnet.2016.01.009.
[12] T. Nguyen Gia et al., βLow-cost fog-assisted health-care IoT system with energy-efficient sensor nodes,β in 2017 13th
International Wireless Communications and Mobile Computing Conference, IWCMC 2017, Jun. 2017, pp. 1765β1770. doi:
10.1109/IWCMC.2017.7986551.
[13] M. Neyja, S. Mumtaz, K. M. S. Huq, S. A. Busari, J. Rodriguez, and Z. Zhou, βAn IoT-based e-health monitoring system using
ECG signal,β in 2017 IEEE Global Communications Conference, GLOBECOM 2017 - Proceedings, Dec. 2017, vol. 2018-Janua,
pp. 1β6. doi: 10.1109/GLOCOM.2017.8255023.
[14] M. R. F. Nurdin, S. Hadiyoso, and A. Rizal, βA low-cost Internet of Things (IoT) system for multi-patient ECGβs monitoring,β in
ICCEREC 2016 - International Conference on Control, Electronics, Renewable Energy, and Communications 2016, Conference
Proceedings, Sep. 2017, pp. 7β11. doi: 10.1109/ICCEREC.2016.7814958.
[15] M. I. Rizqyawan, M. F. Amri, R. P. Pratama, and A. Turnip, βDesign and development of Android-based cloud ECG monitoring
system,β in Proceedings - 2016 3rd International Conference on Information Technology, Computer, and Electrical Engineering,
ICITACEE 2016, 2017, pp. 1β5. doi: 10.1109/ICITACEE.2016.7892444.
[16] M. DβAloia, A. Longo, and M. Rizzi, βNoisy ECG signal analysis for automatic peak detection,β Information (Switzerland),
vol. 10, no. 2, p. 35, Jan. 2019, doi: 10.3390/info10020035.
[17] A. S. Ahmed, K. S. Rijab, and S. A. Alagha, βA study of chosen an optimum type of wavelet filter for de-noising an ECG
signal,β International Journal of Current Engineering and Technology, vol. 10, no. 05, pp. 749β756, Oct. 2020, doi:
10.14741/ijcet/v.10.5.9.
[18] P. Karthikeyan, M. Murugappan, and S. Yaacob, βECG signal denoising using wavelet thresholding techniques in human stress
assessment,β International Journal on Electrical Engineering and Informatics, vol. 4, no. 2, pp. 306β319, Jun. 2012, doi:
10.15676/ijeei.2012.4.2.9.
[19] V. M. Kaviri, M. Sabaghi, and S. Marjani, βDe-noising of ECG signals by design of an optimized wavelet,β Circuits and Systems,
vol. 07, no. 11, pp. 3746β3755, 2016, doi: 10.4236/cs.2016.711314.
[20] D. Zhang et al., βAn ECG signal de-noising approach based on wavelet energy and sub-band smoothing filter,β Applied Sciences
(Switzerland), vol. 9, no. 22, p. 4968, Nov. 2019, doi: 10.3390/APP9224968.
[21] A. D. S. Majumdar, βComparative analysis of Coiflet and Daubechies wavelets using global threshold for image de-noising,β
International Journal of Advances in Engineering and Technology, vol. 6, pp. 2247β2252, 2013.
[22] V. Gupta and M. Mittal, βQRS complex detection using STFT, chaos analysis, and PCA in standard and real-time ECG
databases,β Journal of The Institution of Engineers (India): Series B, vol. 100, no. 5, pp. 489β497, Mar. 2019, doi:
10.1007/s40031-019-00398-9.
[23] V. Gupta, N. K. Saxena, A. Kanungo, P. Kumar, and S. Diwania, βPCA as an effective tool for the detection of R-peaks in an
ECG signal processing,β International Journal of System Assurance Engineering and Management, vol. 13, no. 5, pp. 2391β2403,
Oct. 2022, doi: 10.1007/s13198-022-01650-0.
[24] V. Gupta, M. Mittal, and V. Mittal, βChaos Theory: An emerging tool for arrhythmia detection,β Sensing and Imaging, vol. 21,
no. 1, Feb. 2020, doi: 10.1007/s11220-020-0272-9.