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
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 pin2const int buzzerPin = 8; // connects the piezo buzzer to a digital pin3const float baselineTemp = 25.0; // the base temperature to compare with what the sensor detects
On the setup:
1Serial.begin(9600); // opens a serial port2// sets the LEDs (connected to pins 2, 3, 4) as output3for(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 output2int sensorVal = analogRead(sensorPin);34// outputs the sensor value on the Serial Monitor for checking5Serial.print("Sensor Value: ");6Serial.print(sensorVal);78float voltage = (sensorVal/1024.0) * 5.0; // converts the ADC reading to voltage910// outputs the voltage reading on the Serial Monitor for checking11Serial.print(", volts: ");12Serial.print(voltage);1314// converts the voltage to temperature in degrees Celcius15float temperature = (voltage - 0.5) * 100;1617// outputs the temperature on the Serial Monitor for checking18Serial.print(" , degrees C: ");19Serial.print(temperature);2021// will be used to print the status on the Serial Monitor22String tempStatus = "";
Determining the temperature:
1// determines if drink is COLD2if(temperature < baselineTemp) {3 // if temp is less than 25 C, turn the blue LED on4 digitalWrite(2, HIGH); // blue5 digitalWrite(3, LOW); // yellow6 digitalWrite(4, LOW); // red78 tempStatus = "COLD :("; // sets the status to print on later910 // turns the buzzer on11 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 sound14}15// determines if drink is WARM and getting cold16else if(temperature >= baselineTemp && temperature < baselineTemp + 3){17 // if temp is 25 C to 27 C, turn the yellow LED on18 digitalWrite(2, LOW); // blue19 digitalWrite(3, HIGH); // yellow20 digitalWrite(4, LOW); // red2122 tempStatus = "Still WARM but GETTING COLD!"; // sets the status to print on later2324 // turns the buzzer on25 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 sound28}29// determines if drink is still HOT30else if(temperature >= baselineTemp + 3 && temperature < baselineTemp + 8){31 // if temp is greater than 27 C but less than 35 C, turn the red LED on32 // I need to set a cap at 35 C because the temp reads very high when there's no subject to test on33 digitalWrite(2, LOW); // blue34 digitalWrite(3, LOW); // yellow35 digitalWrite(4, HIGH); // red3637 tempStatus = "Still HOT :)"; // sets the status to print on later38}39// if there is no mug present on the pressure plate, do nothing40else{41 digitalWrite(2, LOW); // blue42 digitalWrite(3, LOW); // yellow43 digitalWrite(4, LOW); // red4445 tempStatus = "Missing subject"; // sets the status to print on later46}4748// prints the status of the temperature49Serial.println(" , Status: " + tempStatus);5051// three-second gap for each check52delay(3000);
Breadboard View
Schematics
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:
- Illustration by Thierry Fousse from Icons8