Prevent scalding by hot tea

Made by menghui hu

After using boiling water to make a cup of hot tea, I sometimes got scalded because of me being too hurry to drink it. Or sometimes I am just too busy to notice the hot temperature of the hot tea. This IOT is designed to help me noticing, if the tea is too hot to drink. Components required: RGB Led, switch, temperature sensor.

0

Goal: The light change from red to blue as temperature go low, indicating the water is drinkable.

The prototype show that when temperature goes up the light goes red.

0
const int RED_LED_PIN = A2;
const int GREEN_LED_PIN = A1;
const int BLUE_LED_PIN = A0;
int temperaturePin = A5;
int inputPin = D1;
int val = 0;
int state = 1;
int tempHigh = 28;
int tempLow = 24;

int greenIntensity = 0;
int blueIntensity = 0;


void setup() {


    pinMode(RED_LED_PIN, OUTPUT);
    pinMode(GREEN_LED_PIN, OUTPUT);
    pinMode(BLUE_LED_PIN, OUTPUT);

    pinMode(temperaturePin, INPUT);
    pinMode(inputPin, INPUT);

    Serial.begin(9600);
}

void loop() {
    val = digitalRead(inputPin);
    double temperature = (analogRead(temperaturePin) * 3.3) / 4095;
    temperature = (temperature - 0.5) * 100;
    Serial.println(temperature);
    int adjRed = (int) (255 - redVal(temperature));
    int adjBlue = (int) (255 - blueVal(temperature));
    if (val == LOW) {
        state = !state;
        delay(250);

    }

    if (!state) {
        adjRed = 255;
        adjBlue = 255;
    }


    analogWrite(GREEN_LED_PIN, 255);

    analogWrite(BLUE_LED_PIN, adjBlue);
    analogWrite(RED_LED_PIN, adjRed);

    Serial.println("red: " + String(adjRed));
    Serial.println("blue: " + String(adjBlue));
    Serial.println(state);

}



double redVal(double temp){
    if (temp >= tempHigh){
        return 255;
    } else if (temp <= tempLow){
        return 0;
    }
    double mulFactor = (256/(tempHigh - tempLow));
    double retVal = mulFactor*(temp - tempLow);
    if (retVal > 0){
        retVal = retVal - 1;
    }

    return retVal;
}

double blueVal(double temp){

    double retVal = redVal(temp); 
    retVal = 255 - retVal;
    return retVal;
}
Click to Expand
x
Share this Project


About

After using boiling water to make a cup of hot tea, I sometimes got scalded because of me being too hurry to drink it. Or sometimes I am just too busy to notice the hot temperature of the hot tea. This IOT is designed to help me noticing, if the tea is too hot to drink.
Components required: RGB Led, switch, temperature sensor.

Created

January 26th, 2017