Project Gallery
Overall view of the project showing the front face (LCD Display and Buttons) as well as the top face which contains the LED tracking and phone placement.
Product Explanation
This project is a sleep regulator device to help me keep track of the steps needed for a good sleep. It features a phone box area to keep my phone for the night, temperature and humidity tracking, as well as sleep and wake buttons to ensure optimal sleeping conditions. The system provides feedback through an LCD screen and LED strip, celebrating when all conditions for a good sleep are met.
Product Images
Image from a diagonal point of view to show proportion and scale
Image showing the buttons of the project, Sleep and Awake, which allow a user to indicate when they go to sleep and wake up.
Image showing the LCD display of the device on start up
Image showing the devices functionality when a phone is placed, with a celebration message indicated on the LED.
Product Demonstration
Final Video showing the demonstration of the product. Upon opening, the box displays a "Sleep Regulator" message and the user can instantly see data on the humidity and temperature of their surrounding room. When the phone is placed, the device displays a success message and logs this internally. When the user finally presses the sleep button, the optimal conditions are met (for this demo only) and a green light is turned on the top where the tracking LED is (shown below) and a success message is shown. The device was aimed to be easy to use and represent the concept of "Physical memory" where by nowadays digital devices have been overused for sleep tracking with little success. For the purposes of this demo, the optimal temperature was 65 degrees Farenheit and Humidity reading was 35%. The time between placing the phone and going to sleep optimally was only set to a few seconds.
Additional Viewing: This video shows the tracking mechanism which couldn't be seen in the earlier video.
Process Images
Testing out final integration in box, taping parts to correct placements and ensuring proper signal sending. After this point, I had to rewire the Neo LED strip as to tape it to the correct place on the top face, it was too far off.
Final wiring of project before placing top part of box on.
Initial wiring of Force Sensitive Resistor and LCD Display. After this point and testing the resistor out, I realized a proximity sensor would be much more accurate and easier to detect if a phone was placed.
Testing out the Proximity sensor with a testing RGB LED and the LCD display to indicate the success message.
Discussion
Response to comments: One critique that I received was that the student stated " I liked the concept you mentioned of having “physical memory” - making an intangible concept into something tangible and concrete. I think this idea is a solid manifestation of this concept". I agree with this position as this was one of the goals of my project, to make this device be more physically interactive in ways that a phone can't through sleep and wake buttons. I'm happy that this intention was expressed through the final result of my project. Another critique I received was that "In considering the different patterns of sleep and people's personal tendencies, how can you create a new UI that allows the user to more accurately track their personal sleep. Or maybe some way of setting habits and preferences that the data keeps track of?" This is a very valid point to bring up, especially as the current version of the project serves more as a tracker but how do we extend this to be an enforcer of good habits. An approach that could be taken is to add another LCD display which keeps track of how many days habits have been kept and how many habits were checked (ie. 5/6 - No Temperature), so the user can see which habits to focus more on.
Self Critique: I'm fairly happy with how my project came out given the constraints I had. In terms of the design, I believe I definitely could have created a much more efficient and interactive design, perhaps with an enclosure for a phone and a smaller box in general. I believe the current larger box uses a lot of unneeded space and it could be more compact. I also believe I could have added much more features and interaction in general. For example, reminders through sound or light if a users phone isn't placed or to go to bed would definitely aid the user experience. However, given my time constraints due to outside circumstances I feel I did a great job of putting the project together. I'm very happy with how much it actually aids a user and the utility it provides. The ease of functionality was something I also hoped to achieve for something as important as sleep.
What you learned about your own abilities and/or limitation: I actually found many new insights about my own abilities and interests throughout this project. Most of the hurdles were purely hardware based, either with ensuring strong soldered connections or integrating all the sensors in 1 environment. This wasn't too much of a challenge though but moreso somehting that I realized came along with large-scale Arduino projects. I actually found the coding portion of the project fairly easy, which will definitely prove to be useful later on for larger projects. One new insight I discovered was I loved the physical designing part, where I would not only figure out where each feature would be placed on the box but how the box would look and feel. This unlocked a new passion for me which I definitely would like to explore in the future whether through exploration into Product Design or Design Principles.
Next steps. In terms of a future iteration, I would plan to change the overall structure of the device, perhaps making it a smaller box or a different shape, but overall more compact. Additionally, I would like there to be a way to immediately export the data being collected into a computer file format. I believe this way users will be much more compelled to actually use the device knowing that it can be transferred over as well. Something along the lines of connecting to a iPhone app which collects all the data or sending over through a USB flash drive. I was also thinking about adding a keypad for users to input how well they slept (on a scale from 1-10). This way, we can track important user meta data like sleep conditions and also how well they slept to now create personalized recommendations through the LCD display on what the optimal environmnet really is.
Technical Information
Code
/* Sleep Regulator
This project creates a device that helps establish healthy sleep habits by
1. Detecting when a phone is placed on the top of the box
2. Tracking the surrounding room temperature and humidity
3. Tracking when the user goes to sleep or wakes up through buttons on the front face of the box
4. Providing interactive feedback through an LCD interface and an LED strip which shows how long the user has been following their optimal sleep conditions
Pin Mapping:
BUTTONPIN = 2 //Button to indicate sleeping time
BUTTONPIN2 = 4 //Button to indicate awake time
ledPin = 3 //LED output for testing
sensorPin = A0 //IR proximity sensor for phone detection
PINNEO = 7 //RGB LED strip
LCD Screen Used (0x27)
AHT Temperature/Humidity Sensor
Libraries Used:
- Wire.h (IC2)
- Adafruit_AHTX0 (Temperature/Humidity Sensor Tracking)
- PoluluLedStrip.h (RGB Led strip)
- LiquidCrystal_I2C (LCD Display)
Released under MIT License
*/
#include <Wire.h>
#include <Adafruit_AHTX0.h>
#include <PololuLedStrip.h>
Adafruit_AHTX0 aht;
const int BUTTONPIN = 2;
const int BUTTONPIN2 = 4;
bool isOn;
bool isTemp;
bool isSleep;
bool isAwake;
bool isHumid;
bool bingo;
unsigned long interval = 120000;
unsigned long previousMillis = 0;
unsigned long sleepingTime = 0;
unsigned long awakeTime = 0;
bool phonePlaced = false;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C screen(0x27, 16, 2);
int x = 123;
//Constants:
const int ledPin = 3; //pin 3 has PWM funtion
const int sensorPin = A0; //pin A0 to read analog input
//Variables:
int value; //save analog value
#define PINNEO 7
PololuLedStrip<PINNEO> ledStrip;
rgb_color green = rgb_color(0, 255, 0);
const int NUMLEDS = 8; // number of LEDs in the strip
rgb_color colors[NUMLEDS];
void setup(){
pinMode(BUTTONPIN, INPUT_PULLUP); //Set Button 1 as an input
pinMode(BUTTONPIN2, INPUT_PULLUP); //Set Button 2 as an input
pinMode(sensorPin, INPUT); //Set IR sensor as an input
pinMode(ledPin, OUTPUT); //Set pin 3 as output
Serial.begin(9600); //Begin serial communication
screen.init(); //Screen Setup
screen.backlight();
screen.home();
screen.print("Sleep Regulator!");
delay(3000);
screen.clear();
for(int j = 0; j < NUMLEDS; j++) { //reset LED to no color
colors[j] = rgb_color(0, 0, 0);
}
ledStrip.write(colors, NUMLEDS);
if (!aht.begin()) { //Humidity Sensor Setup
Serial.println("Could not find AHT sensor!");
}
Serial.println("AHT sensor initialized");
}
void loop(){
int proxValue; //Phone Sensor
proxValue = analogRead(sensorPin);
Serial.print("Proximity value: ");
Serial.println(proxValue);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval && isOn) {
//Phone been in box for 2 minutes
screen.clear();
screen.home();
screen.print("Time to Sleep!");
delay(8000);
screen.clear();
}
int buttonState; //Buttons
buttonState = digitalRead(BUTTONPIN);
int buttonState2;
buttonState2 = digitalRead(BUTTONPIN2);
if (buttonState == LOW && (isSleep == false)) { //Asleep
analogWrite(ledPin,200);
isSleep = true;
sleepingTime = millis();
screen.clear();
screen.home();
screen.print("Time to Sleep!");
delay(3000);
screen.clear();
}
if (buttonState2 == LOW && (isAwake == false)) { //Awake
analogWrite(ledPin,200);
isAwake = true;
awakeTime = millis();
Serial.print("Awake");
delay(5000);
}
sensors_event_t humidity, temp; //Humidity/Temp
aht.getEvent(&humidity, &temp);
Serial.print("Temperature: "); Serial.print(round((temp.temperature*(9.0/5.0))+32)); Serial.println(" degrees F");
Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH");
if (proxValue > 200){ //When phone is placed!
if (!phonePlaced) {
isOn = true;
screen.clear();
screen.home();
screen.print("Phone Placed!");
screen.setCursor(0,1);
screen.print("Good Job!");
analogWrite(ledPin, 200);
previousMillis = millis();
delay(2000);
screen.clear();
phonePlaced = true;
}
}
if (round((temp.temperature*(9.0/5.0))+32) > 65) { //if temperature is at the right amount
isTemp = true;
}
if (humidity.relative_humidity > 35) { //if humidity is at the right amount
isHumid = true;
}
if (isTemp && isOn && isSleep && isHumid) {
bingo = true; //if all conditions met
//turn on neopixel led 1
colors[0] = green;
ledStrip.write(colors, NUMLEDS);
delay(1000);
screen.clear();
screen.home();
screen.print("Have a");
screen.setCursor(0,1);
screen.print("Great Sleep!");
delay(10000);
screen.clear();
}
else if (isOn == false && isSleep == true) { //If attempt to go to sleep without phone being placed
screen.clear();
screen.home();
screen.print("Phone not placed");
delay(10000);
screen.clear();
}
//Rest of Time
analogWrite(ledPin,0);
screen.setCursor(0,0);
screen.print("T: ");
screen.setCursor(4, 0);
screen.print(round((temp.temperature*(9.0/5.0))+32));
screen.setCursor(6,0);
screen.write(223);
screen.print("F");
screen.setCursor(0, 1);
screen.print("H: ");
screen.setCursor(4,1);
screen.print(round(humidity.relative_humidity));
screen.setCursor(6,1);
screen.print("%");
delay(1000); //Small delay
screen.clear();
}