/Sleep-Sensors-Analytics

Tracking movement, ambient light levels, and temperature/humidity for better quality sleep.

Primary LanguagePythonMIT LicenseMIT

bed-science

Collecting and analyzing data to improve restedness level from sleep.

Overview

Problem

I've been having poor quality sleep and wake up feeling unrested with "adequate hours" of sleep.

Target Measures

  • Movement Level: Objective measure of overall amount of movement during sleep (higher = more movement).
  • Restedness Level: Subjective measure of how rested I feel after waking up (higher = more rested).

Hypotheses

  • Lower movement level correlates with increased restedness level.
  • Movement level will be lower with lower ambient light levels.
  • Movement level will be lower with temperatures in the low 60's Fahrenheit.
  • Movement level will be lower with decreased amount of caffeine consumption.
  • Movement level will be lower with longer time between consumption and sleep time.
  • Higher duration of sleep will correlate with higher restedness level.

Data Sources

  • Accelerometer: Tracks x/y/z accelerator and x/y/z angular velocity
  • Photoresistor: Track ambient light levels
  • Temperature Sensor: Tracks temperature in celsius
  • Humidity Sensor: Tracks relative humidity

Getting Started

These instructions will get a copy of the project up and running on your local machine.

Prerequisites

Instructions for installing these software are listed in the next section: Installing. These are the software packages needed to run:

  • Arduino IDE
  • i2cdevlib
  • Processing
  • Python 2.7

These Python packages are also needed:

  • Tkinter
  • numpy
  • pandas
  • matplotlib

From a hardware perspective, the following are needed:

  • Arduino board: The Arduino Uno is a good option
  • Breadboard: Something like this
  • MPU 6050: Accelerometer available for purchase from Amazon and more information from Arduino
  • DHT22: Temperature/humidity sensor available for purchase from Amazon or Adafruit
  • Photoresistor: Any type should do. This one from Adafruit will work
  • Male-to-male ribbon cable: Something like this

Installing

Download the latest version of the Arduino IDE here.

Download the latest version of i2cdevlib here, following the instructions provided in the README.

Download the latest version of Processing here.

If your computer does not already have Python 2.7 installed, download it here.

By default, Python should come with pip (a package manager). Use it to install the following dependencies by opening the Terminal/command line and entering the commands as follows, each line as a separate command (make sure to capitalize Tkinter):

pip install Tkinter
pip install numpy
pip install pandas
pip install matplotlib

Usage

Basic

Built With

  • Arduino - A hardware/software board to collect sensor data
  • i2cdevlib - Library for interfacing with MPU6050 accelerometer
  • SoftwareSerial - (Built in) Arduino library for serial communication
  • Processing - A sketchbook for visual arts with simple Arduino integration
  • Python - A programming language used here to create exploratory data graphs
  • Tkinter - Python library for graphical user interfaces (GUI)
  • Numpy - Python library for mathematical and matrix operations
  • Pandas - Python library for data manipulation
  • Matplotlib - Python library for graphing data

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

  • B_E_N: For his tutorial on connecting Arduino to Processing
  • Elaine Laguerta: For her tutorial on saving Arduino data to a CSV file using Processing