MICROCONTROLLER-BASED HUMAN STRESS DETECTION SYSTEM
USING FUZZY LOGIC
AWAIS GUL AIRIJ
A project report submitted in partial fulfilment of the
requirements for the award of the degree of
Master of Engineering (Electronics & Telecommunication)
Faculty of Electrical Engineering
Universiti Teknologi Malaysia
DECEMBER 2015
iii
DEDICATION
Gratefully dedicated to my family, my mentor and friends. I couldn’t have completed
this without you all. Thank you for your love, support and guidance.
iv
ACKNOWLEDGEMENT
I am indeed grateful to Almighty ALLAH for providing me the opportunity
and strength to commence and conclude my Master of Engineering at Universiti
Teknologi Malaysia.
It is a great pleasure to express my heart-felt gratitude to my supervisor Dr
Shaikh Nasir Bin Shaikh Husin for his inspirational guidance, kind supervision and
comprehensive advice throughout the duration of my work.
I wish to express my deepest appreciation to my previous supervisor Dr
Rabia Bakhteri. The present work would not have been possible without her
encouragement and support. I thank Dr Rabia Bakhteri for her detailed and insightful
feedback, which helped me shape this research. It was a great honour to work under
her supervision for nine months. However, she had to move to Canada for some
reason and she could not help me complete this research under her supervision.
Finally, I would like to thank my father Muhammad Yaqoob Memon, my
brother Naeem Aziz Memon along with my other family members and friends for
their encouragement throughout my work. I would not have been able to complete
this without them. I also would like to appreciate all those who have helped me
directly or indirectly towards the completion of this project.
v
ABSTRACT
This research presents a working prototype of human stress detection
device capable of measuring human stress level perhaps also for autistic children.
The device records human physiological signals in order to determine the mental
stress level. High stress levels may be dangerous especially for certain individuals
such as autistic children who are unable to express mounting levels of stress. The
autistic children can have frequent tantrums and seizure activities without any visible
signs or symptoms, making this device a useful tool for parents and doctors to
anticipate any harmful behaviours of autism. This research focuses on the hardware
and software development of a low cost microcontroller-based stress detection
system prototype. The prototype was designed using Arduino Mega platform and
tested with 35 clinical patients. The data from two sensors is fed to the
microcontroller using its two analog input pins and the sensor data is sent to the
fuzzy logic module which is pre-programmed into the microcontroller for further
processing. The output of the prototype is displayed on the LCD module connected
to five digital pins of the microcontroller. In addition, three LEDs are connected to
three digital pins of the microcontroller which light up in accordance with the stress
levels. In order to test the developed system, an experiment was designed which
requires subjects to perform mental calculations to solve arithmetic problems. The
experiment involves three phases: low stress phase (P-1), medium stress phase (P-2)
and high stress phase (P-3). The results showed that the prototype measures the stress
levels with high degree of accuracy and efficiency. Apart from that, the results also
highlighted that the stress neither depends on age nor gender.
vi
ABSTRAK
Kajian ini membentangkan prototaip alat pengesan tekanan minda manusia
yang digunakan untuk mengukur tahap tekanan manusia dan juga untuk kanak-kanak
autistik. Peranti berfungsi untuk merakam isyarat fisiologi manusia bagi menentukan
kadar tekanan. Tahap tekanan yang tinggi mungkin berbahaya terutamanya untuk
individu tertentu seperti kanak-kanak autistik dimana mereka tidak mampu untuk
menyatakan dengan jelas perasaan atau tekanan yang dihadapi. Kanak-kanak autistik
boleh mempunyai tantrum yang kerap dan bersikap agresif secara drastik tanpa
sebarang tanda yang boleh dikesan dengan awal, menjadikan peranti ini alat yang
berguna untuk ibu bapa dan doktor untuk menjangka tingkah laku yang berbahaya
dari penghidap autisme. Kajian ini memberi tumpuan kepada pembangunan
perkakasan dan perisian mikropengawal kos rendah berasaskan prototaip sistem
pengesan tekanan. Prototaip ini telah direka menggunakan platform ‘Arduino Mega’
dan kemudian diuji dengan 35 orang pesakit klinikal. Data daripada dua sensor
disalurkan ke mikropengawal dengan menggunakan dua pin input analog dan data
tersebut dihantar ke modul logik kabur (Fuzzy Logic) yang telah diprogramkan
dalam mikropengawal untuk proses seterusnya. Output prototaip ini dipaparkan pada
modul paparan kristal cecair (LCD) yang disambungkan dengan lima pin digital
mikropengawal. Di samping itu, tiga diod pemancar cahaya (LED) disambungkan
kepada tiga pin digital mikropengawal yang menyala mengikut tahap tekanan. Bagi
menguji prototaip yang dibangunkan, pesakit dikehendaki menyelesaikan masalah
aritmetik dengan melakukan teknik pengiraan secara mental atau congak.
Eksperimen ini melibatkan tiga fasa iaitu fasa tekanan rendah (P-1), fasa tekanan
sederhana (P-2) dan fasa tekanan tinggi (P-3). Keputusan menunjukkan bahawa
tahap tekanan dapat diukur dengan tepat dan cekap. Selain itu, kajian ini
merumuskan bahawa tekanan tidak bergantung kepada umur atau jantina.
vii
TABLE OF CONTENTS
CHAPTER TITLE PAGE
DECLARATION ii
DEDICATION iii
ACKNOWLEDGEMENT iv
ABSTRACT v
ABSTRAK vi
TABLE OF CONTENTS vii
LIST OF TABLES x
LIST OF FIGURES xi
LIST OF ABBREVIATIONS xiii
LIST OF APPENDICES xiv
1 INTRODUCTION 1
1.1 Project Background 1
1.2 Problem Statement 2
1.3 Research Objectives 3
1.4 Research Scope 3
1.5 Research Contributions 3
1.6 Thesis Organization 3
2 LITERATURE REVIEW 5
2.1 Introduction 5
2.2 Project Background 5
2.2.1 Case Studies on Autism Spectrum Disorder 6
2.3 Types of Stress 7
2.3.1 Acute Stress 7
viii
2.3.2 Episodic Acute Stress 7
2.3.3 Chronic Stress 8
2.4 Sensors/Devices 8
2.4.1 Galvanic Skin Response Sensor 8
2.4.2 Pulse Sensor/Blood Volume Pulse 9
2.4.3 Temperature Sensor 9
2.4.4 ASL 504 Eye Gaze Tracker 10
2.4.5 Peizoelectric Film Sensor 10
2.4.6 Accelerometer 11
2.4.7 EEG Sensor 11
2.4.8 Force Sensor 12
2.5 Artificial Intelligence 12
2.5.1 Fuzzy Logic 12
2.5.2 Bayes Net Classifier 13
2.5.3 Support Vector Machine 13
2.5.4 Decision Tree 14
2.6 Related Literature 14
3 RESEARCH METHODOLOGY 17
3.1 Introduction 17
3.2 Sensors 18
3.2.1 Working Principle of Heartbeat / Pulse Sensor 19
3.2.2 Working Principle of Galvanic Skin Response Sensor 19
3.3 LCD Module 20
3.4 Arduino Mega Board 20
3.5 Indicator 21
3.6 Moving Average 21
3.7 Decision-Making Module 22
3.8 Data Collection 23
4 HARDWARE DESIGN 24
4.1 Interfacing Pulse Sensor with Arduino 24
4.2 Interfacing GSR Sensor with Arduino 25
4.3 Interfacing LCD Module with Arduino 27
ix
4.4 Arduino Pinouts 28
4.5 Fuzzy Logic Module with Arduino 29
4.5.1 Fuzzy Logic Rules 29
4.5.2 Membership Function 29
4.6 Final Prototype 31
5 RESULTS AND DISCUSSION 32
5.1 Results 33
5.2 Discussion 34
6 CONCLUSION AND FUTURE RECOMMENDATIONS 36
6.1 Conclusion 36
6.2 Future Recommendations 36
REFERENCES 37
Appendices A - B 40-56
x
LIST OF TABLES
TABLE NO. TITLE PAGE
2.1 Summary of literature review 16
4.1
Pin functions of LCD module 27
xi
LIST OF FIGURES
FIGURE NO. TITLE PAGE
1.1
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3.1
3.2
3.3
3.4
3.5
3.6
4.1
4.2
4.3
4.4
4.5
Stress Response to a Stressor (stimuli)
The reaction of stress factors is governed by ANS
GSR sensor
Pulse sensor
Temperature sensor
ASL eye gaze tracker
Piezo-electric film sensor
Accelerometer
Device to record brain waves
Force-sensing resistor
System architecture
Project flowchart
Working principle of photoplethysmography
Arduino Mega board
LEDs as indicators
Fuzzy decision-making
Heart rate (pulse) sensor by pulsesensor.com
Testing heart rate sensor with Arduino
Grove GSR sensor
Testing grove GSR sensor with Arduino
48x84 graphic LCD module
1
6
8
9
9
10
10
11
11
12
17
18
19
21
21
22
24
25
26
26
27
xii
4.6
4.7
4.8
4.9
4.10
5.1
5.2
5.3
5.4
Pin connections between Arduino & LCD module
Membership function curve (trapezoidal) for low stress
Membership function curve (trapezoidal) for med stress
Membership function curve (trapezoidal) for high stress
Final prototype of stress detection system
Working of human SDS prototype
Stress levels in males for all three phases
Stress levels in females for all three phases
Testing of LM35 temperature sensor with Arduino
28
30
30
30
31
32
33
34
35
xiii
LIST OF ABBREVIATIONS
ANS - Autonomic Nervous System
ASD - Autism Spectrum Disorder
BVP - Blood Volume Pulse
ECG - Electrocardiography
EEG - Electroencephalography
eFLL - Embedded Fuzzy Logic Library
FLM - Fuzzy Logic Module
GSR - Galvanic Skin Response
LCD - Liquid Crystal Display
MRI - Magnetic Resonance Imaging
PPG - Photoplethysmography
REI - Rhythmic Entertainment Intervention
SC - Skin Conductance
SDS - Stress Detection System
SVM - Support Vector Machine
xiv
LIST OF APPENDIX
APPENDIX TITLE PAGE
A Arduino Code for Stress Detection System 63
B Evaluation Form 63
CHAPTER 1
INTRODUCTION
The present research aims at developing a working prototype in order to
detect stress by using Arduino Mega. The device makes use of human physiological
signals measured with the help of various electronic sensors, along with a fuzzy logic
decision-making system to calculate the stress levels accurately.
1.1 Project Background
The term “stress” basically refers to the physical reaction of a person in
response to an unpleasant/dangerous environmental condition or stimuli [1] as shown
in figure 1.1. Over-stress has proven to be one of the major factors contributing to
several serious health problems such as high blood pressure, hypertension,
cardiovascular diseases and panic attacks [2].
Figure 1.1: Stress response to a stressor (stimuli)
According to a research, stress is categorized into three types namely; acute
stress, episodic acute stress and chronic stress [3]. Acute stress and episodic acute
stress do not cause much damage as they are for a short period making people
anxious and frightened but are easily treatable [3]. However, on the other hand, the
2
chronic stress lasts longer and causes serious complications depending upon the type
of patients [4, 5]. As a result of stress, stress-response hormones such as epinephrine,
norepinephrine and cortisol are secreted which can be a contributing factor in cardiac
abnormalities[5] along with some other serious complications. Moreover, high levels
of stress can cause commonly known mental disorders namely; depression and
anxiety[4].
The system proposed in this project can non-invasively detect stress levels in
humans through some physiological signals such as skin conductance, temperature,
heart rate and blood pressure measured with the help of various electronic sensors.
1.2 Problem Statement
Nowadays, everybody is stressed, however, the type of stress dealt within the
very research and complications caused by it are limited to a specific group of
people. The children suffering from Autism Spectrum Disorder (ASD) are the focus
of study. According to a research, every 1 in 166 births suffers from ASD [6].
Autistic children can have seizures, panic attacks, suicide thoughts, commit homicide
and can also be harmful to their surroundings when they are under stress. But there
are no visible signs or warnings when under high stress.
Currently, low cost commercial device for detecting stress is not available.
Nonetheless, devices to monitor temperature, heart rate and variations in respiration
exist. Furthermore, even such high-end devices are devoid of detecting stress on their
own. For instance heart rate variation alone is incapable of detecting stress. There is
a dire need for a stand-alone device that can detect stress by using a couple of
physiological signals and process them further in order to decide whether the person
is under stress or not. Such device will possibly help the parents and doctors to
anticipate harmful behaviours of autism.
3
1.3 Research Objective
The objectives of this research are:
1) To study the fuzzy logic and familiarize with embedded fuzzy logic library
(eFLL) for Arduino.
2) To interface electronic sensors with Arduino Mega board.
3) To measure physiological signals accurately using electronic sensors.
4) To develop a prototype of human stress detection system.
5) To test the prototype functionality on intended subjects.
1.4 Research Scope
The scope of this research covers development of a human stress detection
system prototype consisting of Arduino Mega 2560 microcontroller board, LCD
display, pulse sensor, grove GSR sensor and LEDs as indicators. AtMega2560
microcontroller is the main processing unit for the entire system and is programmed
using Arduino IDE.
1.5 Research Contributions
Prior research has shown various approaches of stress detection but
unfortunately, there is no device available till today which is accurate and low cost.
This research aims to develop a prototype of human stress detection system which is
capable of accurate measurement of human stress levels at a very low cost.
1.6 Thesis Organization
This thesis consists of six chapters. The first chapter discusses the
background, problem statement, intended objectives and the scope of this research.
4
Chapter 2 includes the literature review focused on techniques, experimental setup,
results and drawbacks found in previously built devices for stress detection purpose.
In chapter 3, the working principles of the sensors and other components are
discussed. Later in chapter 4 the design of the system is discussed in terms of
interfacing the sensors, designing output display along with an indicator and
designing of the fuzzy logic system. The next chapter presents the results obtained
from the developed stress detection prototype and discussion on the results. The
problems and challenges faced during this research are also included in chapter 5.
Finally, a conclusion of the entire research and some recommendations for future
improvements are given in chapter 6.
37
REFERENCES
[1] D. Carneiro et al., “Multimodal behavioral analysis for non-invasive stress
detection,” Expert Systems with Applications, vol. 39, no. 18, pp. 13376-
13389, Dec 15, 2012.
[2] J. Wijsman et al., “Towards mental stress detection using wearable
physiological sensors,” 2011 Annual International Conference of the IEEE
Engineering in Medicine and Biology Society, pp. 1798-1801, 2011.
[3] J. Bakker, M. Pechenizkiy, and N. Sidorova, “What's Your Current Stress
Level? Detection of Stress Patterns from GSR Sensor Data,” pp. 573-580,
2011.
[4] A. Fernandes et al., "Determination of stress using blood pressure and
Galvanic Skin Response." pp. 165-168. International Conference on
Communication and Network Technologies (ICCNT).
[5] G. S. Everly, et al., “A Clinical Guide To The Treatment Of The Human
Stress Response,” pp. 3-51, 2013.
[6] A. S. Hamid BehnamA, et al., “Analyses of EEG background activity in
autism disorders with fast Fourier transform and short time Fourier measure,”
International Conference on Intelligent and Advanced Systems 2007, pp.
1240-1244, 2007.
[7] V. J. Madhuri, et al., “Stress Management Using Artificial Intelligence,”
2013 Third International Conference on Advances in Computing and
Communications, pp. 54-57, 2013.
[8] I. Goel, and D. Kumar, “Design and Implementation of Android Based
Wearable Smart Locator Band for People with Autism, Dementia, and
Alzheimer,” Advances in Electronics, vol. 2015, pp. 1-8, 2015.
[9] P. Maureen Grissom, Neuropsychologist Developmental Assessment &
Intervention Center Bedford Hills, NY 10507 “Autism Spectrum Disorders,”
April 15, 2013.
[10] C. o. R. E. I. Strong Institute, “Autism Case Studies.”
[11] T. Tamura et al., “Wearable Photoplethysmographic Sensors—Past and
Present,” Electronics, vol. 3, no. 2, pp. 282, 2014.
38
[12] G. Q. Zhao et al., “A Pervasive Stress Monitoring System Based on
Biological Signals,” 2013 Ninth International Conference on Intelligent
Information Hiding and Multimedia Signal Processing (Iih-Msp 2013), pp.
530-534, 2013.
[13] Mohammad S. Sharawi, et al., “Design And Implementation Of A Human
Stress Detection System: A Biomechanics Approach,” Proceeding of the 5th
International Symposium on Mechatronics and its Applications (ISMA08),
Amman, Jordan,, May 27-29, 2008.
[14] S. K. G. Ashish Patel, Qamar Rehman, M. K. Verma, “Application of Fuzzy
Logic in Biomedical Informatics,” Journal of Emerging Trends in Computing
and Information Sciences, vol. 4, pp. 57-62, 1 Jan, 2013.
[15] V. J. Madhuri, M. R. Mohan, and R. Kaavya, “Stress Management Using
Artificial Intelligence,” 2013 Third International Conference on Advances in
Computing and Communications (Icacc 2013), pp. 54-57, 2013.
[16] K. R. Ruggeri., “Bayesian networks,” Encyclopedia of Statistics in Quality &
Reliability, 2007.
[17] F.-T. Sun et al., "Activity-Aware Mental Stress Detection Using
Physiological Sensors," Mobile Computing, Applications, and Services,
Lecture Notes of the Institute for Computer Sciences, Social Informatics and
Telecommunications Engineering M. Gris and G. Yang, eds., pp. 211-230:
Springer Berlin Heidelberg, 2012.
[18] K. D. Tong. S, “Support Vector Machine Active Learning with Applications
to Text Classification,” Journal of Machine Learning Research, pp. 45-66,
2001.
[19] N. C. T. S. Furey, et al., “Support vector machine classification and
validation of cancer tissue samples using microarray expression data,” vol.
16, pp. 906-914, 2000.
[20] J. Z. J. Zhai et al., “Realization of stress detection using psychophysiological
signals for improvement of human-computer interactions,” Proceedings.
IEEE SoutheastCon, 2005., pp. 415-420, 2005.
[21] A. De Santos Sierra et al., “A stress-detection system based on physiological
signals and fuzzy logic,” IEEE Transactions on Industrial Electronics, vol.
58, no. 10, pp. 4857-4865, 2011.
[22] a. D. S. Sierra, et al., “Two Stress Detection Schemes Based on Physiological
Signals for Real-Time Applications,” Intelligent Information Hiding and
Multimedia Signal Processing (IIH-MSP), 2010 Sixth International
Conference on, pp. 1-4, 2010.
[23] C. K. Feng-Tso Sun, et al., “Activity-Aware Mental Stress Detection Using
Physiological Sensors,” Institute for Computer Sciences, Social Informatics
and Telecommunications Engineering, pp. 211-230, 2012.
39
[24] J. Allen, “Photoplethysmography and its application in clinical physiological
measurement,” Physiol Meas, vol. 28, no. 3, pp. R1-39, Mar, 2007.
[25] S. A. b. S. Noh, “Galvanic Skin Response,” Final Year Project - UniKL BMI,
15-July, 2015.
[26] A. Mega, “2560: http://Arduino. cc/en,” Main/ArduinoBoardMega2560.
[27] Nokia5110, "PCD 8544, 48 x 84 pixels matrix LCD controller/driver.
Philips”
[28] C. W. Sheng, “Embedded System For Stress-Detection Based On
Physiological Signals And Fuzzy Logic”, Universiti Teknologi Malaysia,
Final Year Project Thesis, 2014.