WhatToWear (New)

Made by Haorong Ou

Found in Home Hack

I don't know why my original one crushed and I can't open the original page to edit

0

Intention

This project is to detect the temperature outside and send you a message every morning to tell you what to wear before you leave the house. The time I set is 7:30 in the morning but when to send message can be adjusted to user's need. At the same time, the user can be informed by the color of LED light and press the button to get information right now.

0

Context

Have you tried to wear a heavy coat in a super warm day in winter for rushing the schedule without checking the weather report? Would you struggle to figure out what to wear in this rapid-change weather day? Do not want to waste your time to change your clothes only when you step outside your house? Now WhatToWear can help you sense the outside temperature  and send a message to you suggesting the weather ouside and what to wear.

0

Process

Components: Temperature sensor, LED light, button

It works in three ways to fit different needs. User will receive message every morning before they go out, they can press the button to get the information right now and the LED light will inform the information by different color.

0
#include "OneWire.h"

#include "spark-dallas-temperature.h"

#include <math.h>

OneWire oneWire( D0 );

DallasTemperature dallas( &oneWire );

double temperature = 0.0;
double temperatureF = 0.0;
int currenttime = 0;
int currentmin = 0;
int buttonPin = D1;
int redPin = A0;
int greenPin = D2;
int bluePin = D3;
int photoResistorCheckTime = 60000;
int lastPhotoResistorReport;

void setup()
{

    Particle.variable( "temperature", &temperature, DOUBLE );
    Particle.variable( "temperatureF", &temperatureF, DOUBLE );
    Particle.variable( "time", &currenttime, INT );
    Particle.variable( "min",&currentmin, INT );

    pinMode( redPin, OUTPUT);
    pinMode( greenPin, OUTPUT);
    pinMode( bluePin, OUTPUT);


    pinMode( buttonPin, INPUT_PULLUP );


    dallas.begin();

    Serial.begin( 9600 );

    lastPhotoResistorReport = millis();

}

void loop()
{

      int buttonState = digitalRead( buttonPin );

      dallas.requestTemperatures();

      sin( 23423 );


      float tempC = dallas.getTempCByIndex(0);

      temperature = (double)tempC;
      Time.zone(-5);
      currenttime = Time.hour();
      currentmin = Time.minute();


      float tempF = DallasTemperature::toFahrenheit( tempC );

      temperatureF = (double)tempF;


      Serial.print( "Temp in C = ");
      Serial.print( tempC );
      Serial.print( "\t\t F = ");
      Serial.println( tempF );
      Serial.print( currenttime );
      Serial.print( currentmin );


      if( temperature <= 5 ){
        digitalWrite( redPin, 0 );
        digitalWrite( greenPin, 255 );
        digitalWrite( bluePin, 255 );
      }
      if( temperature > 5 and temperature <= 20 ){
        digitalWrite( redPin, 255 );
        digitalWrite( greenPin, 0 );
        digitalWrite( bluePin, 255 );
      }
      if( temperature >20 ){
        digitalWrite( redPin, 255 );
        digitalWrite( greenPin, 255 );
        digitalWrite( bluePin, 0 );
      }

      if( currenttime == 7 and currentmin == 30 ){
        if( (millis() - lastPhotoResistorReport) >= photoResistorCheckTime ){
          lastPhotoResistorReport = millis();
          if ( temperature <= 5 ) Particle.publish( "temperaturelevel", "Cold", PRIVATE );
          if ( temperature > 5 and temperature <= 20 ) Particle.publish("temperaturelevel", "Cool", PRIVATE );
          if ( temperature > 20 ) Particle.publish( "temperaturelevel", "Warm", PRIVATE );
        };
      };

      if( buttonState == LOW ){
        if ( temperature <= 5 ) Particle.publish( "temperaturelevel", "Cold", PRIVATE );
        if ( temperature > 5 and temperature <= 20 ) Particle.publish("temperaturelevel", "Cool", PRIVATE );
        if ( temperature > 20 ) Particle.publish( "temperaturelevel", "Warm", PRIVATE );
      };
}
Click to Expand
0

Reflection

I build my first IoT device in this assignment, it's interesting to combine circuit and code together. I think this product can help us with our daily life because I am actually  bothered by the weather when I am in the warm house. One thing I would like to spend more time on is to understand about how the circuit work, since sometimes I just follow some instruction to build the physical part.

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.


Focused on
About

I don't know why my original one crushed and I can't open the original page to edit

Created

February 2nd, 2017