49713 Designing for the Internet of Things
· 25 members
A hands-on introductory course exploring the Internet of Things and connected product experiences.
A wifi-connected temperature sensor that tells you when your water is boiling.
I designed this product for my husband, Carlos, who loves to drink tea but finds the process of making it somewhat inconvenient. We don't have a tea kettle in our house so he makes tea by boiling water in a saucepan on the stove. The process usually unfolds in the following steps:
Considering this problem, I set out to create an IoT device that would eliminate the need to keep checking the pot, the possibility that the water would begin to boil without Carlos' knowledge, and the resulting waste in water and energy.
They say “a watched pot never boils.” This product will eliminate this conundrum by sensing when water has reached a boiling point using a waterproof temperature sensor placed into the pot and alerting the user using a piezo buzzer. Once the user reaches the pot, they will be able to turn the alert on off using a switch.
This IoT product will allow users to focus on other tasks while their water boils and will allow people to know when the water is boiling. This will save time, water from evaporation, and electricity / gas. Additionally, this project could be adapted for other uses in the kitchen like cooking things on the stove or brewing beer.
This was the first IoT project I attempted on my own. I found the experience challenging but rewarding when I was able to get components working.
Below are the components I used for input, output, and sensing (full bill of parts included below). I originally planned to use a button as the input, but after adding it to my circuit I quickly released that I needed a switch that could stay in place without someone pressing it.
I built the circuit component by component, first building the code, then the accompanying physical circuit, and finally checking the serial monitor data to confirm that that piece of the project was working as planned. I did this first for the DS18B20 temperature sensor, then for the Piezo Buzzer, and finally for the SPDT.
Challenges
Learnings
In this project, I was able to complete the prototype nearly as planned. The major difference was that I was not able to have the piezo buzzer play a song and instead had it play a simple alert.
Potential next steps:
Bill of parts:
//Sources:
//switchPin - http://diotlabs.daraghbyrne.me/5-getting-input/switches/
//temperature - http://diotlabs.daraghbyrne.me/3-working-with-sensors/DS18B20/
//speakerPin - http://diotlabs.daraghbyrne.me/6-controlling-outputs/piezo/
#include "OneWire.h"
#include "spark-dallas-temperature.h"
// 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(D1 );
// 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;
int speakerPin = D2;
int switchPin = D0;
// create an array for the notes in the melody:
//C4,G3,G3,A3,G3,0,B3,C4
int melody[] = {1908,2551,2551,2273,2551,0,2024,1908};
// create an array for the duration of notes.
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {4,8,8,4,4,4,4,4 };
void setup()
{
// Register a Particle Core variable here
Particle.variable("temperature", &temperature, DOUBLE);
Particle.variable("temperatureF", &temperatureF, DOUBLE);
// setup the library
dallas.begin();
Serial.begin(9600);
pinMode( switchPin , INPUT_PULLUP);
pinMode( speakerPin, OUTPUT );
playNotes();
}
void loop()
{
int buttonState = digitalRead( switchPin );
if( buttonState == LOW ) {
// Request temperature conversion (traditional)
dallas.requestTemperatures();
sin( 23423 );
// 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;
// Print out
Serial.print( "Temp in C = ");
Serial.print( tempC );
Serial.print( "\t\t F = ");
Serial.println( tempF );
delay(5000);
if ( tempF > 200) {
playNotes();
Serial.println("The water is boiling! ");
Particle.publish("The water is boiling!", PRIVATE);
}
else{
Serial.println("Water is not ready! ");
Particle.publish("Water is not ready!", PRIVATE);
}
}
else {}
}
void playNotes()
{
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(speakerPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(speakerPin);
}
}
Click to Expand
Given that this was my first project, I felt happy with the product that I created. While the project was difficult for me, it was exciting to see that a small circuit board could have so many applications and solve common problems. Building this product opened my eyes to the fact that many of the IoT products we buy, despite their polished and well-designed exteriors, are ultimately a mix of inputs, outputs, and sensors. This project made me curious as to other potential applications for sensors in my day-to-day life.
In completing this project, I felt limited by two things: 1) my inability to parse out portions of more complex open source code (e.g. how I was unable to incorporate a song and instead opted for a tune with a few notes) and 2) my limited knowledge of ways to control and manage loops and sending information to the cloud.
I am excited to work on these limitations in future projects so that I can become more comfortable with them and build upon the skills I've developed thus far.
A hands-on introductory course exploring the Internet of Things and connected product experiences.
A wifi-connected temperature sensor that tells you when your water is boiling.
January 23rd, 2018