HOME>BLOG>
Creating A Cold Coffee Alarm Device using Arduino

Creating A Cold Coffee Alarm Device using Arduino

How I created an alarm device to detect if a hot beverage is getting cold using Arduino

DIY
Internet of Things, Maker Culture
December 30th, 2016 · 2 min read
Creating A Cold Coffee Alarm Device using Arduino

I created an alarm device that will determine the temperature of your coffee (or tea), and shows you the status if it’s still HOT, WARM, or COLD with LEDs (red, yellow, and blue respectively), trigger a warning alarm if it is getting cold and will buzz continuously when it eventually gets cold.

The Working Prototype

Arduino Cold Coffee Alarm Device Prototype

Status: HOT

When your coffee is still hot, the red LED is on and the device will stay silent.

Status: WARM

When you are neglecting your coffee for a while and it gets warm, the yellow LED is on and the device will trigger a warning alarm to get your attention.

Status: COLD

When you have failed to do the simple task of drinking your coffee while it’s still hot, the blue LED turns on and you will hear a continuous buzz to again remind you of your failure and neglect. Time to brew another batch of hot coffee.

The Parts

The device uses a temperature sensor TMP36 to determine your drink’s temperature, a pressure plate for the device to determine if there is a cup of coffee present, a piezo buzzer for the sound alarm, and 3 LEDs to show you the status of your drink.

The Pressure Plate

The device will only operate (check status and execute alarm) if you put your mug on it. I got the parts from a kids science toy and a board game. Partly a challenge to think about designing the plate with what I currently have at home, and make sure that it will be steady enough not to spill the drink all over my workbench. It’s a makeshift switch that will close the circuit whenever some weight is added on the pressure plate. Works best for ceramic mugs.

The Buzzer

Also got this piezo from the kids science toy I used for the pressure plate. There’s a limitation from Arduino where the volume cannot be configured, hence the need to cover it up because it’s too loud.

The Sensor

Initially a challenge to ensure that the sensor touches the mug placed on the pressure plate. It needs to be flexible and not so wiggly so I braided the wires.

The Code

I initialized 3 constants for this sketch:

1const int sensorPin = A0; // connects the temperature sensor to an analog pin
2const int buzzerPin = 8; // connects the piezo buzzer to a digital pin
3const float baselineTemp = 25.0; // the base temperature to compare with what the sensor detects

On the setup:

1Serial.begin(9600); // opens a serial port
2// sets the LEDs (connected to pins 2, 3, 4) as output
3for(int pinNumber = 2; pinNumber < 5; pinNumber++){
4 pinMode(pinNumber, OUTPUT);
5 digitalWrite(pinNumber, LOW);
6}
7pinMode(buzzerPin, OUTPUT); // sets the buzzer pin as an output

On the initial part loop:

1// determines the value of the sensor, this will be used to compute the voltage output
2int sensorVal = analogRead(sensorPin);
3
4// outputs the sensor value on the Serial Monitor for checking
5Serial.print("Sensor Value: ");
6Serial.print(sensorVal);
7
8float voltage = (sensorVal/1024.0) * 5.0; // converts the ADC reading to voltage
9
10// outputs the voltage reading on the Serial Monitor for checking
11Serial.print(", volts: ");
12Serial.print(voltage);
13
14// converts the voltage to temperature in degrees Celcius
15float temperature = (voltage - 0.5) * 100;
16
17// outputs the temperature on the Serial Monitor for checking
18Serial.print(" , degrees C: ");
19Serial.print(temperature);
20
21// will be used to print the status on the Serial Monitor
22String tempStatus = "";

Determining the temperature:

1// determines if drink is COLD
2if(temperature < baselineTemp) {
3 // if temp is less than 25 C, turn the blue LED on
4 digitalWrite(2, HIGH); // blue
5 digitalWrite(3, LOW); // yellow
6 digitalWrite(4, LOW); // red
7
8 tempStatus = "COLD :("; // sets the status to print on later
9
10 // turns the buzzer on
11 digitalWrite(buzzerPin, HIGH);
12 tone(buzzerPin, 1024, 3000); // (pin, frequency, duration)
13 // the duration is the same as the delay time for the loop to mimic continuous buzzing sound
14}
15// determines if drink is WARM and getting cold
16else if(temperature >= baselineTemp && temperature < baselineTemp + 3){
17 // if temp is 25 C to 27 C, turn the yellow LED on
18 digitalWrite(2, LOW); // blue
19 digitalWrite(3, HIGH); // yellow
20 digitalWrite(4, LOW); // red
21
22 tempStatus = "Still WARM but GETTING COLD!"; // sets the status to print on later
23
24 // turns the buzzer on
25 digitalWrite(buzzerPin, HIGH);
26 tone(buzzerPin, 1024, 1000); // (pin, frequency, duration)
27 // the duration is less than the delay time to mimic a warning alarm sound
28}
29// determines if drink is still HOT
30else if(temperature >= baselineTemp + 3 && temperature < baselineTemp + 8){
31 // if temp is greater than 27 C but less than 35 C, turn the red LED on
32 // I need to set a cap at 35 C because the temp reads very high when there's no subject to test on
33 digitalWrite(2, LOW); // blue
34 digitalWrite(3, LOW); // yellow
35 digitalWrite(4, HIGH); // red
36
37 tempStatus = "Still HOT :)"; // sets the status to print on later
38}
39// if there is no mug present on the pressure plate, do nothing
40else{
41 digitalWrite(2, LOW); // blue
42 digitalWrite(3, LOW); // yellow
43 digitalWrite(4, LOW); // red
44
45 tempStatus = "Missing subject"; // sets the status to print on later
46}
47
48// prints the status of the temperature
49Serial.println(" , Status: " + tempStatus);
50
51// three-second gap for each check
52delay(3000);

Breadboard View

Arduino Cold Coffee Alarm Device Breadboard View
Breadboard view created using the Fritzing app

Schematics

Arduino Cold Coffee Alarm Device Schematics View
Schematics created using the Fritzing app

Total time spent for this project: 3 hours (including the time spent figuring out the design with the available resources)

That’s it! Let me know on the comments section below if you see points of improvement on this project or if you created your own. :) Enjoy your cup of hot coffee.


Related post:

Credits:


There's more to read!

guideCybersecurity, Web Development

Free HTTPS support for Github Pages with Kloudsec

•  2 min read
learningInternet of Things, Maker Culture

Arduino: Getting Started

•  2 min read
Everything Else.
HomeBlogProjects
Works
WebsitesLanding PagesPrintSoftware
Link to $https://github.com/gianfayeLink to $https://www.linkedin.com/gianfaye/Link to $https://twitter.com/gianfayeLink to $https://stackexchange.com/users/2642726/gian-faye?tab=accountsLink to $mailto:contact@gianfaye.com

© 2022 Gian Faye Paguirigan

PrivacyTerms of UseRSS