Back to Parent

Outcome


Intention

The device will send an SMS when the tea is ready. There is a multi-colored light built in. If the tea is too hot, the light will shine red. If the tea has become too cold, it will turn blue. However, if the tea is in between at just the right temperature, the light will shine green.

Context

I live alone, but I start most mornings making a cup of tea. This daily ritual was passed on to some of my family members, so this can be used by them, as well. Often by the time I get to my tea, it is uncomfortably cold, having steeped while I worked through other parts of my morning routine.

Product

Completed code:

/*This code was largely taken from the DIoT tutorial.

Original comments were removed so existing comments could be used to highlight

added work*/

//Define RGB and alarm pins

int red = D2;//red spot = too hot

int verde = D1;//green light = just right

int bleu = A0;//blue is bold = too cold

int alarm = D5;// bring the noise

#include "OneWire.h"

#include "spark-dallas-temperature.h"

OneWire oneWire(D0 );

DallasTemperature dallas(&oneWire);

double temperature = 0.0;

double temperatureF = 0.0;

void setup()

{

Particle.variable("temperature", &temperature, DOUBLE);

Particle.variable("temperatureF", &temperatureF, DOUBLE);

/*I added the following four lines to define the RGB pins and alarm as outputs*/

pinMode(red, OUTPUT);

pinMode(verde, OUTPUT);

pinMode(bleu, OUTPUT);

pinMode(alarm, OUTPUT);

dallas.begin();

}

void loop()

{

/*The following if statements are used to create ranges for each light*/

if (retemp() > 60) // too hot

{

digitalWrite(red, LOW);

digitalWrite(bleu, HIGH);

digitalWrite(verde, HIGH);

} else if (retemp() > 40) //between 60 and 40, the Goldilocks zone

{

digitalWrite(verde, LOW);

digitalWrite(bleu, HIGH);

digitalWrite(red, HIGH);

} else { //too cold

digitalWrite(bleu, LOW);

digitalWrite(verde, HIGH);

digitalWrite(red, HIGH);

}

delay(200); // changed delay time in hopes of overloading messaging system

Particle.publish("The Tea Temperature is", retemp()); //publishes temp Data

}

/*The klaxon function sounds a beep (not a real klaxon, I know,

but I like the word) when the tea reaches a drinkable temperature*/

void klaxon()

{

if (retemp() <= 61 && retemp() >= 59)

digitalWrite(alarm, HIGH);

delay(3000);

digitalWrite(alarm, LOW);

}

/*A lot of the original code got moved here so that it could return

a temperature value as an input for the RGB LED and speaker*/

double retemp() //Returns temperature

{

dallas.requestTemperatures();

float tempC = dallas.getTempCByIndex(0);

temperature = (double)tempC;

float tempF = DallasTemperature::toFahrenheit( tempC );

temperatureF = (double)tempF;

return tempC;

}

Circuit diagram (use Fritzing or similar)

Bill of parts:

1 Breadboard

1 Particle Photon

1 RGB LED

1 Piezo Speaker

1 Covered DS18B20 temperature sensor

1 470Ω resistor

3 1kΩ resistors

A whole mess of wires

Video of completed project

https://youtu.be/3oCvpO_nwBI

https://youtu.be/kTD6nycG6_Y

Reflection

I learned the proper wiring for a DS18B20 one-wire temperature sensor after frying the uncovered one. I got most of what I expected from the device, though perhaps I would have liked to receive fewer messages or create a single applet that sends messages noting both the start and end of the comfortable drinking range.

Drop files here or click to select

You can upload files of up to 20MB using this form.