Sleep Away

Made by Christian Baca

Found in Home Hack

My goal is to create an IoT product that senses the temperature of a room and has the ability to turn on a fan to keep the room at a consistent comfortable temperature.

0

Problem Statement 

 I currently live alone in Pittsburgh, but I lived with my best friend, Ariel, for the past few years in Albuquerque. She has suffered from insomnia since she was 14. She is now 25 and has more natural sleep patters, but still can be woken up or kept awake throughout the night by quiet noises, movement, temperature change, etc. The appliance I am designing is a temperature sensor that will start a fan if the temperature rises above a specified ‘comfortable’ temperature. Ariel would greatly benefit from this appliance because temperature would be one less annoyance that would wake her up or keep her awake at night. She could ideally sleep through the night with a comfortable temperature decided by her. I choose to design this IoT appliance for Ariel because I have seen how difficult it is for her to function efficiently after having a horrible night of sleep. 

0

Goal

The goal for this appliance is that it will sense the temperature of Ariel’s bedroom and once it rises above a specific temperature that Ariel will decide is the threshold for when her room gets to hot to sleep comfortably, a fan will automatically turn on to cool the room down. 

0

Process

Description: Macintosh HD:Users:christianbaca:Downloads:IMG_4078.JPG

The basics needed for this appliance to work are a temperature sensor and a fan. Since attaching a fan would be above my current skill set, the components used are a temperature sensor, a LED, and a piezo buzzer. The LED and piezo buzzer go off when the fan would start in the real scenario.

For the code, I started with the sample code in the tutorials for the temperature sensor and the LED. In the beginning, I was completely lost on the coding aspect of this project. I went to office hours and Joseph explained to me that there can only be one void setup and one void loop for an entire code. After office hours, I was able to condense my code into one void setup and one void loop and write the simple code to have the LED and piezo buzzer turn on when the temperature was above 73 degrees.

0

Outcome 

The fact that the code made the breadboard do what it was supposed to do was a huge success for me. This hack is far from complete. Future steps for completion are to hook it up to a fan instead of the outputs being an LED and a buzzer. Furthermore, it would be beneficial for the temperature sensor to continue sensing the temperature in the room and once it drops below a specified temperature, the fan would turn back off. 


Bill of Materials:

Breadboard

Particle Microcontroller

Jumper Wires

DS18B20 Temperature Sensor

4.7 kOhm Resistor

10 kOhm Resistor

Piezo Buzzer 

LED


The code, circuit diagram, and link to the video of the breadboard in action are shown below.  


0
//3 This #include statement was automatically added by the Particle IDE.
#include "OneWire.h"

#include "spark-dallas-temperature.h"

//#include <OneWire.h>

int ledPin = D1;
int speakerPin = D2;


// Data wire is plugged into port 0 on the Arduino
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire( D0 );

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature dallas(&oneWire);

// Create a variable that will store the temperature value
double temperature = 0.0;
double temperatureF = 0.0;


void setup(void) {
 Serial.begin(9600);
 // Register a Particle variable here
 Particle.variable("temperature", &temperature, DOUBLE);
 Particle.variable("temperatureF", &temperatureF, DOUBLE);

 // setup the library
 dallas.begin();

pinMode(ledPin, OUTPUT);

pinMode(speakerPin, OUTPUT);

}



void loop(void) {

  // Request temperature conversion

  dallas.requestTemperatures();

  // get the temperature in Celcius
  float tempC = dallas.getTempCByIndex(0);
  // convert to double
  temperature = (double)tempC;

  // convert to Fahrenheit
  float tempF = DallasTemperature::toFahrenheit( tempC );
  // convert to double
  temperatureF = (double)tempF;

  Serial.println(temperature);

int temperatureHOT = 73;

if(temperatureF > temperatureHOT) {

    digitalWrite(ledPin, HIGH);

    digitalWrite(speakerPin, HIGH);
    delay(100);
    digitalWrite(speakerPin, LOW);

}else{
  digitalWrite(ledPin, LOW);
  digitalWrite(speakerPin, LOW);
}

 delay(3000); //just here to slow down the output so it is easier to read
}
Click to Expand
0

Reflection

Dealing with circuits and code is far from a normal activity for me, I found myself lost for the majority of the project. It is also one of those subject where if you get stuck, there is a chance you will not be able to solve the problem on your own, which is frustrating and hinders the completion of the project in a timely manner. Once Joseph explained more about the code to me, I had a breakthrough. Having my circuit work after fixing my own code was exciting. I'm looking forward to more breakthroughs and have a goal of learning how to troubleshoot my own circuit and code problems in the future. 

x
Share this Project

Found In
Courses

49-713 Designing for the Internet of Things

· 26 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

My goal is to create an IoT product that senses the temperature of a room and has the ability to turn on a fan to keep the room at a consistent comfortable temperature.

Created

February 1st, 2017