Diana Khalipina
Published © GPL3+

Sleeping Phases Determination

This health kit helps to get continuously the data about quality and overall duration of the sleep and to determine the sleeping phases.

IntermediateFull instructions provided4 hours12,678
Sleeping Phases Determination

Things used in this project

Hardware components

HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×2
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Photo resistor
Photo resistor
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2
Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Sketch for the wiring

Wiring of arduino and breadboard

Android app for sleeping phases determination

Schematics

Construction of mobile app. part 1

Construction of mobile app. part 2

Construction of mobile app. part 3

Construction of mobile app. part 4

Construction of mobile app. part 5

Construction of mobile app. part 6

Working app. part 1

Working app. part 2

Working app. part 3

Code

Code for arduino

Arduino
#include <SoftwareSerial.h>
#include <cactus_io_AM2302.h>

#define AM2302_PIN 7

const int pinPhoto = A0;
int raw = 0;
const int inputPin = 6;
AM2302 dht(AM2302_PIN);
const int ledPin = 13;


SoftwareSerial Bluetooth(9, 8);

void setup() {
  Bluetooth.begin(9600);
  Serial.begin(9600);
  dht.begin();
  pinMode( pinPhoto, INPUT );
  pinMode(inputPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int value = digitalRead(inputPin);
  dht.readHumidity();
  dht.readTemperature();
  raw = analogRead(pinPhoto);
  
  if (isnan(dht.humidity) || isnan(dht.temperature_C)) {
    return;
  }

  if (value == HIGH)
  {
    
    digitalWrite(ledPin, HIGH);
    Serial.print("wake");Serial.print("  ");Serial.print(raw); Serial.print(" "); Serial.print(dht.temperature_C); Serial.print(" "); Serial.println(dht.humidity);

    Bluetooth.print("wake"); Bluetooth.print("  "); Bluetooth.print(raw); Bluetooth.print("  "); Bluetooth.print(dht.temperature_C); Bluetooth.print("  "); Bluetooth.print(dht.humidity);Bluetooth.println("  ");
    
  }
  else
  {
    Serial.print("sleep");Serial.print(" ");Serial.print(raw); Serial.print(" "); Serial.print(dht.temperature_C); Serial.print(" "); Serial.println(dht.humidity);

     Bluetooth.print("sleep"); Bluetooth.print("  ");Bluetooth.print(raw); Bluetooth.print("  "); Bluetooth.print(dht.temperature_C); Bluetooth.print("  "); Bluetooth.print(dht.humidity);Bluetooth.println("  ");
    
    digitalWrite(ledPin, LOW);
  }

  delay(1500);
}

Code for arduino

This code will allow you to make your arduino board work and connect it with an app

Credits

Diana Khalipina

Diana Khalipina

22 projects • 93 followers
Integrating Web Accessibility in Healthcare Tech | Web Developer & Bioengineering Specialist in Paris | MSc in Biomedical Engineering

Comments