Automated Bathroom Heater

It's brrrrrr-tastic!

Made by Stefanie Owens

Created: January 27th, 2015

0

This project was designed to activate my bathroom heater remotely when I wake up in the morning. 

My bathroom is FREEZING and made of solid tile, so it's especially chilly in winter mornings!

Using a Force Sensitive Resistor (FSR), when my head lifts off of my pillow, it activates the temperature sensor (TMP36) in the bathroom to read the temperature.  If the temperature is below 65 degrees Fahrenheit, then the bathroom heater is turned on.

*Note:  For demonstration purposes, I made the threshold temperature 85 degrees so that the "heater" would for sure turn on, as you can see in the code below.  I simulated the heater by using a blinking LED which only blinks once the "heater" has been activated.  If actually implemented, the blinking LED would still be present to give the status of the heater as being on or off.  

0

Contents of Project: 

- Spark Microcontroller

- Breadboard

- Jumper Wires

- A 1kΩ Resistor

- A 10kΩ Resistor

- A Force Sensitive Resistor (FSR)

- A single color LED (Light Emitting Diode)

A capacitor

- A TMP36 Temperature Sensor

Process Documentation: 

The biggest challenge I encountered was understanding how to trigger the bathroom temperature function from the actual pressure sensor.  This was quickly resolved with using "&&" in my if statement.  For example:   "if( temperatureF < 85 && pillowReading < 500 )"  --- it was simple enough, but it wasn't clicking for me at first.  Originally, I had written a separate pillow function and bathroom function but was having trouble calling one to activate on the other.  The final results can be seen in the code below.  

For circuitry and code examples, I used the Sensor Tutorials published by Daragh Byrne in the Google Drive folder for the IoT 2015 class, combining elements and information I learned from both the FSR and Temperature Sensor tutorial.  I went through about 4 iterations to get the project working, and combined code samples I had found in Google Drive with the logic tips found the Office Hours Powerpoint from Friday, January 23rd.

An example of the circuitry used is shown below: 

0

The code:

0
// system that will sense when my head has lifted off of my pillow, check the bathroom for
// a temperature reading, and turn the heater on if it's below 65 degrees F

// define which pins I'm going to use here
int pillowPin = A0;
int pillowReading = 0;
int ledPin = D0;
int tempPin = A1;

//and the starting temps for the temperature sensor
double temperature = 0.0;
double temperatureF = 0.0;

void setup ()
{
  pinMode (ledPin, OUTPUT);
  pinMode (tempPin, INPUT);
  pinMode (pillowPin, INPUT);

//libraries to use
  Spark.variable("force", &pillowReading, INT);
  Spark.variable("temperature", &temperature, DOUBLE);
  Spark.variable("temperatureF", &temperatureF, DOUBLE);
}

void loop ()
  {
    //has to check the bathroom over and over
    bathroomtemp();
  }

void blinkLED()
  {
    digitalWrite(ledPin, HIGH);
    delay (1000);
    digitalWrite(ledPin, LOW);
    delay (1000);
  }

void bathroomtemp()
  {
    //Read the PILLOW SENSOR
    //read pressure sensor, low pressure turns on bathroom temperature sensor
    pillowReading = analogRead(pillowPin);

    //BATHROOM TEMP SENSOR
    //bathroom heater only turns on if bathroom is below 65 degrees Fahrenheit
    int reading = analogRead(tempPin);
        //this calculates the voltage from the sensor reading
        double voltage = (reading * 3.3 / 4095.0);

        //then calculate the temperature and update the static variable
        temperature = (voltage - 0.5) * 100;

        //then this converts the temp to Fahrenheit
        temperatureF = ((temperature * 9.0) / 5.0) + 32.0;

    if( temperatureF < 85 && pillowReading < 500 ){
      // turn on the heater
      blinkLED();
    }
    else{
      // leave the heater off
      digitalWrite(ledPin, LOW);
    }
  }
Click to Expand
0

You can see above that the system also updated cloud variables to give updates on the temperature as well as the impact of force being impressed upon the FSR.  

0

Next Steps

Moving forward, the obvious next step would be to write the code necessary to actually activate a bathroom heater in my home. At this point, I'm not sure how this interface would work, and it would probably depend on the particular model of heater. With that additional hardware implemented, I would also add a function to shut the system off after I manually turn the heater off in the bathroom (since the temperature will eventually fall below the threshold again, and I won't be returning to bed to activate the pressure sensor).   


* The bathroom image above was sourced from http://bit.ly/1LfkY5H

x