Stamina, a Coffee Monitoring System
Total Page:16
File Type:pdf, Size:1020Kb
Stamina, a coffee monitoring system Alexandra Rouhana 1, Lorenzo Scutigliani 2, and Quentin McGaw 3 1 Electrical and electronic engineering, Imperial College London [email protected] 2 Electrical and electronic engineering, Imperial College London [email protected] 3 Electrical and electronic engineering, Imperial College London [email protected] 28 March 2016 Abstract. Coffee drinking allows to reduce tiredness and is widely used in our society. In particular, the caffeine contained in coffee influences the quality of sleep of coffee drinkers. However, since each person reacts differently to caffeine, there is no rule of thumb to determine the optimal coffee intake schedule in order to maximise performance during the day while ensuring high quality sleep at night. Stamina is a solution providing this missing information to the coffee drinker, by monitoring and analysing the activity of the user over several days. It uses the sensors of both an Android smartphone and smartwatch to analyse the activity of the users, such as when they wake up, go to sleep or drink coffee. A remote server stores these data and analyses them with a clustering machine learning technique to provide suggestions to the users through their mobile devices about their daily coffee consumption. Keywords: Caffeine, Sleep quality, Activity recognition, Smartwatch, Affinity propagation, Clustering 1 Introduction ● The selection process of a clustering algorithm adapted for the detection of Today’s economy faces an increasing demand for patterns between multiple days, in order to products improving one’s well-being and maximising determine various predictions according to physical and intellectual performance [6]. The aim of the predicted type of day. this project named Stamina is to improve users' health ● The detection of daily activities with the and performance by tackling a habit at the heart of their mobile application Staminapp through the daily lives: coffee drinking. Stamina is a system which smartwatch sensors and the GPS capabilities monitors and correlates coffee intakes, sleep patterns of the smartphone. These activities can be and daily activities to output to the end users whether sleeping, waking up, drinking coffee, or not they could drink a cup of coffee to optimise their performing a physical activity or entering sleep and activities. Stamina tracks the activities of its coffee zones (a radius of 40 meters around users through a mobile application analysing the data the user’s favourite coffee shop or place). collected from the smartwatch’s sensors and the ● The development of a secured webserver and smartphone’s GPS localisation. The mobile database communicating with Staminapp. application, called Staminapp, is compatible with smartwatches and smartphones with Android This report first summarises the related work done in operating systems 5.0 or higher. the coffee/sleep management area. Then, the facts and hypotheses Stamina is based on are stated. The design of Stamina is divided into three parts: the Afterwards the designed system is explored by Android mobile application, the webserver and describing its different components and justifying all database, and the back-end machine learning design choices. Finally, the experimental procedure program. This report explores the following topics: used to test Stamina is summarised and the obtained results are discussed together with their associated issues. 2 Related work of each of the previously stated similar existing products. Note also that Sen.se and UP coffee require In the past decade, a lot of research focused on extra devices, whereas Stamina focused on providing merging smartphone and smartwatch sensors data to a solution using only an Android smartphone and detect the users’ daily habits [1] [2] [3]. Classification smartwatch, hence being more affordable. algorithms such as the Support Vector Machines have been widely used to differentiate many real life activities from the smartwatch accelerometer and gyroscope sensors’ data [4] [5]. Physical activities such as running, biking, walking, seating, and standing or even more complex activities such as drinking coffee can be detected through wearable device sensors [5]. Although the activity detection implemented in Stamina is relatively simple and does not include any classification algorithm (see part 4.3), it is definitely possible to enhance Stamina by implementing machine learning techniques for activity recognition. Table 1: Features proposed by existing similar However, this project focused on correlating coffee products intake with daily habits and sleeping patterns using machine learning. In particular, very little published research exists today in this domain. 3 Facts and Hypotheses Three similar products exist on the market: UPCofee Before describing Stamina any further, it is important to by Jawbone, Sen.se [10] and Caffeine Timezone 2 [8]. understand the underlying facts and hypotheses used Only UPCoffee [9] uses analytics but no information on to develop the project. There are mainly four medical the algorithms used is currently available. Caffeine facts Stamina is based on. First, each individual reacts Timezone 2 has been developed by Frank E. Ritter and differently to caffeine [18][22]. This highlights the need Kuo-Chuan (Martin) Yeh from Pennsylvania State for a personalised coffee monitoring system such as University [8]. This mobile application defines sleep Stamina. Secondly, the consumption of coffee (with zones in which the user will be able to sleep, and active caffeine) negatively influences the sleep of the user zones where the user is stimulated by coffee. Caffeine [18][19][20][21], suggesting that coffee should only be timezone 2 does not monitor sleeping patterns or drunk after determining whether or not the sleep is activities automatically. The caffeine absorption and compromised. Drinking coffee before a physical activity elimination models underlying the application are open apparently enhances the physical performance of the source. The sleep zone and the active zone thresholds person [18], which appears as a good thing. Drinking can be modified manually by the user. Caffeine levels coffee is also considered healthy [23], as long as it are calculated each second and stored in a SQLite does not deteriorate the sleep quality. database. The evolution of vascular caffeine levels of the user is plotted each time the application is Concerning the assumptions, there are also four of launched. According to the pharmacodynamics model them. First, it is assumed the sleep quality mainly used in Caffeine Timezone 2, caffeine elimination depends on the consumption of coffee and not on other follows a nonlinear exponential equation shown below factors such as stress or drugs. Second, the users are in equation (1) [8]. The caffeine calculations in Stamina assumed not to be sleeping or having poor sleep is based on a similar equation. quality if they are moving while sleeping. This assumption allows to determine a sleeping quality 푡 (1) : 퐶(푡) = 퐶 푒푥푝(− ), percentage which is needed for this project. Days with 0 푇 similar wake up times and sleep durations are assumed to have similar physical activity times (if any) where 퐶0 and 푇 corresponds respectively to the average caffeine quantity in a cup of coffee and to the and sleep times. Finally, an obvious but necessary caffeine elimination half-life. assumption is that the users are expected to wear their smartwatch most of the time and to always drink with The following table (Table 1) summarises the features the hand on which their smartwatch is attached. This allows Staminapp to detect the user's’ activities at all ● Physical activity movement time, including the coffee drinking action. The smartwatch’s linear acceleration reaches a high threshold on any of the three axes more than four times in 10 minutes. 4 System design The threshold was experimentally found to −2 be 90푐푚. 푠 . As explained in the introduction, Stamina is divided into ● Drinking movement three parts: the mobile front-end side, the remote The smartwatch’s linear acceleration and server and database, and the machine learning gyroscope data during the last 10 minutes program. Each part is described, justified and contain a similar pattern within a margin of evaluated in the following sections. error according to a experimentally predefined drinking model with a trial and error method. ● Coffee shop 4.1 Mobile part: Staminapp The smartphone’s GPS coordinates are The front-end consists of Staminapp, an Android contained in a circular area with radius 40m application deployed on both smartphone and centered around the GPS location of the smartwatch. It is developed using Android Studio 2.0 coffee place. This area is called a coffee with Java 7 because of the familiarity with Android zone; This event is triggered each 3 hours if development. It is compatible with Android operating the user is in the same coffee place and is system 5.0 and higher, which fully support Android not sleeping. smartwatches. The mobile part has two objectives, the first is to detect and confirm real life activities of the Regarding the physical activity and drinking movement user, and the second is to exchange this information detections, these are notified to the user who has to with the remote server to obtain useful information and confirm them through interactive notifications, since suggestions related to the user’s coffee consumption. these could simply be other unrelated events such as drinking water. 4.1.1 Detecting and uploading real life activities The mobile application uses the GPS capabilities of the The linear acceleration is chosen to be used in most of smartphone as well as the linear acceleration and the cases as it is straightforward to understand and to gyroscope integrated sensors of the smartwatch to interpret its data. This type of sensor is similar to an detect movements associated to the user’s real life accelerometer except that constant forces such as activities, according to the following conditions: gravity are not present in the 3 dimensional data.