Smartphone Sensors to Measure Individual Sleeping Pattern:
Experimental Study
Doaa Alamoudi
1a
, Ian Nabney
2b
and Esther Crawley
3c
1
School of Computer Science, University of Bristol, Bristol, U.K.
2
School of Computer Science, Electrical and Electronic Engineering, and Engineering Mathematics,
University of Bristol, Bristol, U.K.
3
Child Health, Bristol Medical School, University of Bristol, Bristol, U.K.
Keywords: Mobile Phone, Mobile Applications, Health Apps, Insomnia, Mental Health, Sleep Monitoring, Depression,
Anxiety, Sleep Disorder, Lack of Sleep, Digital Phenotyping, Mobile Sensing, Smartphone Sensors,
Sleep Detector, Digital Health.
Abstract: The wide spread of using smartphone sensors to measure several health parameters such as collecting and
tracking individual activities, sleeping patterns and data, enables doctors to provide personalised treatment.
This paper discussed the use of smartphone sensors to track insomnia. The SleepTracker app was developed
to test the ability to track an individual’s day to day sleeping pattern based on screen on/off events, its accuracy
evaluated and further improved on.
1
INTRODUCTION
Sleep is a natural state of mind and body, about one-
quarter to one-third of the human lifespan. Before the
1950s, sleep was considered a passive practice as a
result of a reduction in some vital force (Rama et al.,
2005). Physiologically, sleep is the complicated
process of repair and renewal for the body and mind.
While scientists do not have a conclusive explanation
for why humans need sleep, sleep is thought to be
valuable in some physiological operations including
the mental processing of experiences and the
consolidation of memories. It is therefore clear that
sleep is essential, not just for humans but for nearly
all creatures.
According to Deloitte's seventh annual mobile
consumer survey, around 79% of young adults check
their phones before going to sleep (Dewa et al., 2019).
A further 26% of the survey respondents answer
messages even after falling asleep at night while 89%
of respondents use their phones within five to thirty
minutes after they wake up(Dewa et al., 2019).
Technology may be a useful medium to detect
sleeping patterns, and mental health deterioration
a
https://orcid.org/0000-0001-6406-9742
b
https://orcid.org/0000-0001-7382-2855
c
https://orcid.org/0000-0002-2521-0747
before serious adverse events occur (Lin YH et al.,
2019). This research contributes to the development
of a mobile app that can be used to collect passive
data and scalable at a public health intervention level.
The app will be used to detect sleeping patterns and
their relationship with anxiety and depression,
especially among university students aged between
18 - 25 years.
2
RESEARCH PROBLEM
In November 2020, of the UK population are more
likely to experience some form of depression and or
anxiety, young adults age 16 29 years are found to
be the highest; at about 31% and 29% respectively
(Coronavirus, 2020). In 2014, 19.7% of people in the
UK aged 16 and over showed symptoms of anxiety or
depression - a 1.5% increase from 2013. This
percentage was higher among females (22.5%) than
males (16.8%).
When a systematic review was conducted to
understand the impact of sleep quantity, quality, and
regularity on mental health, the study found that sleep
206
Alamoudi, D., Nabney, I. and Crawley, E.
Smartphone Sensors to Measure Individual Sleeping Pattern: Experimental Study.
DOI: 10.5220/0011895100003414
In Proceedings of the 16th International Joint Conference on Biomedical Engineering Systems and Technologies (BIOSTEC 2023) - Volume 1: BIODEVICES, pages 206-210
ISBN: 978-989-758-631-6; ISSN: 2184-4305
Copyright
c
2023 by SCITEPRESS Science and Technology Publications, Lda. Under CC license (CC BY-NC-ND 4.0)
has healing abilities and a great effect on diverse
mental health problems such as depression, bipolar
disorder, anxiety, and suicide. According to Walker
(2017), sleep deprivation has also impact on
emotional moods among healthy individuals
(Matthew Walker, 2017).
3
OUTLINES OF OBJECTIVES
The overarching aim is to test the feasibility of
SleepTracker app to monitor and indirectly estimates
sleeping patterns in young people. The app will detect
changes in sleeping pattern that offer the opportunity
to provide advice on improving sleep or signpost to
early interventions for anxiety and depression.
4
INNOVATION
Previous studies by Z. Chen et al.(Ben-Zeev et al.
2015) and Min JK et al.(Min JK et al., 2014) had used
multiple sensors in smartphones to understand
sleeping patterns. However, the combined phone
usage and usage of these smart phone sensors such as
light, microphone, accelerometer can drain the smart
phone’s battery life.
Several other studies used the screen on/off events
to track sleeping pattern. Lin’s study of individuals’
sleeping pattern based on a defined sleeping time
window between 10.00 pm to 10.00 am disregarded
the variation of sleeping time according to different
individual’s preferences(Lin YH et al., 2019).
In another similar study, an app called
“iSenseSleep” was developed using the same screen
on/off events(Ciman and Wac, 2019). By considering
the longest time period where the phone is unused as
the sleeping time, this app estimates and predicts the
individual’s sleeping pattern by collecting data over
two days. This may not reflect the reality of the
changes of individual’s sleeping pattern according to
any changes in circumstances.
Having identified the shortcomings in other
studies and a possibility where individual may not
touch the phone even when they are awake, it is
therefore imperative to focus on the accuracy of the
sleep duration and patterns.
We implemented an algorithm to test the
feasibility of detecting individuals’ sleep duration
unobtrusively and compare it with their sleep diaries,
using the screen on/off event. With the result of 178
minutes of absolute mean difference, this algorithm
was further revised and improved with added light
and accelerometer sensors in the smart phones. This
revised algorithm results to an absolute mean
difference of 70 mins; an improved accuracy for the
purpose of understanding sleeping pattern and detect
insomnia.
5
TASK ANALYSIS
We had held a virtual focus group of 7 young adults;
with the intent of discussing the feasibility of
developing a “sleep tracking” app that runs in the
background without user intervention and the
frequencies of users’ phone usage before and after
bedtime.
The group indicated their preference for a user-
friendly app that is non-user intervention and does not
intrude their privacy such as the use of the phone’s
microphone or video camera. They are inclined
towards such desired app that runs in the background
that helps them understand their sleeping patterns and
mental health.
As for phone usage, most of the focus group
members checked their phones before getting up from
bed in the morning. They gave a mixed response of
waking up to phone alarms and on their own.
6
METHODOLOGY
We ran two field tests to ensure and improve on the
accuracy of the SleepTracker app in detecting users’
sleeping patterns.
The first field test was conducted over a 6-night
period. It collects data from seven participants and
calculated the sleep duration using an algorithm based
on the screen on/off events.
With improved algorithm and additional
movement and light sensors, the second field test was
conducted over a 7-night period, collecting data and
calculate individuals’ sleeping pattern from a fresh set
of six participants.
6.1 Field Test One
By calculating the time spent for mobile phone usage
and estimating daily sleeping hours, we developed the
SleepTracker app to estimate individual’s sleeping
pattern.
Due to the individuals’ different sleeping time
windows, the app defines a diurnal rhythm for which
the users record their sleeping window (i.e., the times
that they normally sleep). The app enables users to
Smartphone Sensors to Measure Individual Sleeping Pattern: Experimental Study
207
specify the earliest time they will sleep and the latest
time they wake up. By the app being activated and
running in the background only during the users’
indicated sleeping time windows, it helps to reduce
the phone’s daily battery usage.
The algorithm was based on estimating the time
spent using the phone during the sleeping time
window. It then calculates the total time spent using
the phone during this window. As example, if the
user selects to sleep after 10 pm and wake-up before 8
am, the app stores all the screen on/off status and
calculates how long the user uses the phone within
these hours (Figure 1) in a firebase database. The
algorithm records daily total sleep duration at the end
of the daily sleeping time window.
Figure1: Field test 1- Algorithm of SleepTracker App.
6.1.1 Recruitment and Sampling
We managed to recruit 9 young adults (5 females and
4 males) with an age range between 19 and 22 years
old. Before these users were asked to use the app for
one week, a step-by-step instruction manual for
downloading, installing, and using the app was given
to them; after obtaining their signed consent form.
6.1.2 Results
While this study was designed to track individual
sleep duration, this field test one resulted to a
noticeable variation between the app’s recorded sleep
duration and the participants’ diaries. For example, a
particular user recorded in his sleeping diary a total of
10-hour sleep (between 11.00pm and 9.00am);
whereas the planned sleeping time window entered in
the app was a 9-hour sleep between 11.00pm to
8.00am. In this instance, when the app is deactivated
at 8.00am as per planned sleeping time window, the
participant is still asleep. Any screen on/off events
after 8.00am were never recorded.
Using absolute mean formula (Figure 2), the
overall absolute time difference between the sleep
diary and the app raised the issue of accuracy and that
had led us to further improve the algorithm in the
subsequent field test two.
Figure 2: Absolute mean differences among the participants.
6.2 Field Test Two
The SleepTracker app, developed and deployed in
field test one, was upgraded. The upgrades include a
revised and improved algorithm, and the inclusion of
additional two built-in device sensors that are:
Ambient light sensor: To detect usage of light
during normal sleeping hours.
Accelerometer sensors: to detect the use of
the phone during normal sleeping hours.
The revised and improved algorithm included
collection of the data from the above two said sensors
as variables for a more accurate calculation of results.
This improved algorithm was designed to determine
whether the utilisation of the additional two sensors
would improve the measurement of sleep duration.
The sleep duration is calculated by considering
the longest non usage period of the phone. The app
activates at the start of the sleeping time window and
commences collecting screen on/off events that
indicate phone usages of 5 minutes or longer. Any
phone usage that is less than 5 minutes is considered
to be part of the sleep duration. Marking the end of
the sleep duration, the app shall recognise the screen
on event, on or after the planned wake up time of the
sleeping time window. The longest period between
screen off and screen on in the next day is considered
as the sleep duration (Figure 3).
Figure 3: Field test 2- Algorithm of SleepTracker App.
BIODEVICES 2023 - 16th International Conference on Biomedical Electronics and Devices
208
6.2.1 Recruitment and Sampling
Of 16 new young adults invited to participate in our
study, 9 had signed up and of which, only 6
participants (2 female and 4 male) completed. The
participants’ age range between 18 and 25.
Prior to a video demonstration and link for the app
download, installation and usage, the participants
gave a signed consent form to allow us to collect and
analyse the data that is collected over a consecutive
trial period of 7 nights. In addition to the collected
data, the participants were required to provide us with
their sleep diary at the end of the trial period.
6.2.2 Results
Apart from the app, data relating to the participants’
sleep duration were collected from their submitted
sleep diaries to establish whether they were awake
during the sleep time window without using the
phone or woke up in the morning and not touching the
phone. This data are used to compare and analyse
with the data collected by the app.
As compared to the absolute mean difference of
178 minutes in field test one, field test two showed
better accuracy in the tracking sleeping pattern with
an absolute mean difference of 70 minutes (Figure 4).
This pave way for the next phase of this study;
tracking sleep disturbances and provide signposts as
early detection of insomnia.
Figure 4: Absolute mean differences among the participants.
Figure 5 shows data sample collected from the
devices’ sensors of light, accelerometer, and screen
on/off. Despite no activities in the device movement
sensor and screen on/off sensor, a noticeable trend is
the light level meters that keeps changing during the
sleeping time window.
Figure 5: Sample of participants’ data containing the light,
accelerometer, and screen on/off events to measure sleeping
pattern.
7
DISCUSSION
Through recording the screen on activity on or after
the wake-up time, as per entry plan by the user, and
any phone usage activity of more than 5 minutes, the
improvised algorithm in SleepTracker app produces
better accuracy in calculating sleep duration. The
algorithm calculates and recognises app activation in
the background at the commencement of the user
sleeping time window or the start time of long non-
usage period and the screen on event the following
morning as the overall sleep duration; before
deducting any phone activity of more than 5 minutes.
The only possible drawback could be a situation
where the user continues sleeping after waking up and
uses the phone for more than 5 minutes.
A brief comparison table was drawn up against
previous studies done by Z. Chen et al., Min JK et al.,
Lin and iSenseSleep. Critical variables were
identified and compared against SleepTracker app
(Figure 6). From the comparable table, we draw
significance to the sustainability of battery life,
adaptable individual sleep duration, period of trials
and tests and the accuracy of the SleepTracker app.
While higher accuracy results were shown from
an absolute mean improved from 178 minutes to 70
minutes, the accelerometer sensor had shown positive
indicators of furthering the SleepTracker app’s
accuracy.
Smartphone Sensors to Measure Individual Sleeping Pattern: Experimental Study
209
In order to help users detect insomnia and provide
early intervention, this app can be further developed
to detect sleep disturbances that occur during the
sleeping time window by the usage of in built screen
on/off and accelerometer sensors.
Z. Chen et al.
Min JK et al.
Lin's
M.Ciman et al.
SleepTracker
Accelerometer Sensor Y
Y
N N N
Light Sensor Y Y N N N
Screen on/off Y Y Y Y Y
Battery N Y N N N
Microphone Y Y N N N
Sleep Timing Window Defined by the
app
N N Y N N
Study Period (days) 7 3
0
14 2 7
Accuracy, Absolute Mean Test (minutes) 42 49 83 17 7
0
Legend:
Y Yes
N No
Figure 6: Comparison Table of Sleep Pattern Studies.
8
EXPECTED OUTCOMES
In this study, we implemented an algorithm in field
test one and improved this algorithm in the
subsequent field test two. While the aim of this study
was to calculate sleep duration using the screen on/off
events, we upgraded the app by utilising additional in-
built mobile phone sensors such as accelerometer and
light that collected data relating to an individual’s
sleeping pattern.
The collected data from field test two showed
better results of accurate absolute mean differences
measurement, pointing to us that movement sensors
can better help track sleeping patterns. In the
foreseeable future, we plan to use screen on/off and
accelerometer sensors better help in our further study
to track insomnia and provide early intervention if
depression or anxiety is detected.
9
STAGE OF THE RESEARCH
This current stage of this research is centered on the
accuracy of the SleepTracker app in monitoring sleep
patterns and durations. The next phase of this
research shall be the study to measure sleep
disturbances and its impact on mental health.
In the following phase, over a period of 2 months
and a larger group of participants, we aim to conduct
observational study to test the acceptability of the
SleepTracker app and track symptoms of insomnia,
depression, and anxiety. The app shall be used to
collect data on the frequencies of nocturnal phone
usages that are above five minutes and movements
during the users’ planned sleeping hours at night.
ACKNOWLEDGEMENTS
I would like to acknowledge and give my warmest
thanks to my supervisors who made this work
possible. Their guidance and advice carried me
through all the stages of writing this research.
REFERENCES
Coronavirus and the social impacts on Great Britain -
Office for National Statistics. https://www.ons.gov.
uk/peoplepopulationan dcommunity/healthandsocialcare
/healthandwellbeing/bulletins/coronavirusandthesociali
mpactsongreatbritain/11december2020. Accessed Janua
ry 9, 2023.
Matthew Walker. Why We Sleep. New York: Simon &
Schuster;
2017.https://www.getstoryshots.com/books/why-we-
sleep-summary. Accessed February 24, 2020.
Ben-Zeev D, Scherer EA, Wang R, Xie H. Next-Generation
psychiatric assessment: using smartphone sensors to
monitor behavior and mental health. Psychiatr Rehabil
J. 2015;38(3):218-226. doi:10.1037/prj0000130
Min JK, Doryab A, Wiese J, Amini S, Zimmerman J, Hong
JI. Toss “N” turn: Smartphone as sleep and sleep quality
detector. Conf Hum Factors Comput Syst - Proc.
2014;(April):477-486. doi:10.1145/2556288.2557220
Lin YH, Wong BY, Lin SH, Chiu YC, Pan YC, Lee YH.
Development of a mobile application (App) to delineate
“digital chronotype” and the effects of delayed
chronotype by bedtime smartphone use. J Psychiatr
Res. 2019;110(July 2018):9-15. doi:10.1016/j.
jpsychires.2018.12.012
Ciman M, Wac K. Smartphones as Sleep Duration Sensors:
Validation of the iSenseSleep Algorithm. JMIR
mHealth uHealth. 2019;7(5). doi:10.2196/11930
Rama AN, Cho SC, Kushida CA. Normal human sleep.
Sleep A Compr Handb. 2005;(1999):3-10. doi:10.
1002/0471751723.ch1
Dewa LH, Lavelle M, Pickles K, et al. Young adults’
perceptions of using wearables, social media and other
technologies to detect worsening mental health: A
qualitative study. PLoS One. 2019;14(9):1-14. doi:10.
1371/journal.pone.0222655.
BIODEVICES 2023 - 16th International Conference on Biomedical Electronics and Devices
210