Introduction: LCD Temperature Sensor With Freeze Alarm

Throughout the following steps, we'll see how to build an LCD Temperature sensor with a freeze alarm using Arduino and a few simple components. I used this source as an inspiration:

SparkFun Inventor's Kit Experiment Guide - v4.0. (n.d.). https://learn.sparkfun.com/tutorials/sparkfun-inv...kit-

experiment-guide---v40/circuit-4b-temperature-sensor.

This device allows a user to monitor the temperature in a room or garage, sounding an alarm when the temperature gets too low. This is useful in situations where you have containers with liquid that cannot freeze without bursting, giving a warning that said containers are near their limit for temperature.

Personally, I store drinks in the garage, and when we enter the coldest months of winter, I often forget to take them out of the garage. This freeze alarm on the Arduino could save me from having to clean up potentially exploding drinks! Maybe others feel the same and are ready to try this out!

The skill level of my target audience is: moderate to advanced.

Supplies

Components required:

Arduino Uno Board * 1

USB Cable * 1

16X2 LCD Screen LCD1602 Module (with pin header) *1

Potentiometer 10K * 1

DHT11 Temperature and Humidity Module * 1

Buzzer (active) * 1

Breadboard * 1

Jumper Wires

Optional Components:

9V1A Power supply * 1

9V Battery with Snap-on connector clip * 1

Tools required: None

Step 1: Schematic

Arduino:

*Arduino 9V Power via Power supply, USB or 9V Battery adapter

LCD:

Screen GND > GND Rail

Screen VCC > 5V Rail

Screen V0 > Potentiometer

Screen RS > Arduino Pin 13

Screen RW > GND Rail

Screen E > Arduino Pin 12

Screen D4 > Arduino Pin 11

Screen D5 > Arduino Pin 10

Screen D6 > Arduino Pin 9

Screen D7 > Arduino Pin 8

Screen A > 5V Rail

Screen K > GND Rail

Potentiometer:

+ > 5V Rail

- > GND Rail

D > Screen V0

Buzzer:

+ > Arduino Pin 7

- > GND Rail

DHT11 Temperature Sensor:

D > Arduino Pin 7

+ > 5V Rail

- > GND Rail

This schematic was designed with Tinkercad.

Step 2: Uploading Code to Arduino

Connect your Arduino via USB cable to your PC. The Arduino Create website (https://create.arduino.cc/) is a fast and easy way to write, test and upload code to your Arduino. To get started with Arduino Create, follow their existing tutorials to get quickly connected to your Arduino Uno. Once you have become comfortable with the Arduino Web editor, use it to upload the code below to your Arduino Uno.

It can also be found at this link: https://create.arduino.cc/editor/jcmatlon502/fe9f804d-b94c-4687-8fb4-aa6be933e6d8/preview

The following source was also used for inspiration and guidance in creating the code:

Brainy-Bits. (2020, October 29). How to use the DHT11 Temperature and Humidity Sensor with an Arduino!

Brainy. https://www.brainy-bits.com/post/how-to-use-the-d...

/*
  Temperature Sensor with Freeze Alarm

  The LCD will display readings from a temperature sensor in degrees Celsius and Fahrenheit.
  The temperature sensor will read the temperature every 1 second
  
  When the temperature gets to 32 degrees F or lower, sound the buzzer will sound chirp until the temperature gets back above 32 degrees
  While the buzzer is chirping, the temperature will get re-measured every ~1/2 a second
  
  This code uses the DHT11 temperature sensor and library. 
*/

// include the EduIntro library
#include <EduIntro.h>                       // the EduIntro library conatins commands for reading values from the Temperature Sensor
DHT11 dht11(D7);                            // tell the Arduino what pins are connected to the Temperature Sensor 'D7' 

// include the LiquidCrystal library
#include <LiquidCrystal.h>                  // the liquid crystal library contains commands for printing to the display
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);    // tell the Arduino what pins are connected to the display
int buzzer = 6;                             // the pin of the active buzzer is 6
int degreesC = 999;                         // temperature C readings are integers - setting to an extreme number to troubleshoot if its not working
int degreesF = 999;                         // temperature F readings are float but can also be returned as integer - setting to an extreme number to troubleshoot if its not working

void setup() {
  lcd.begin(16, 2);                         // tell the lcd library that we are using a display that is 16 characters wide and 2 characters high
  lcd.clear();                              // clear the display
  pinMode(buzzer,OUTPUT);                   // tell the arduino what pins are connected to the buzzer
}

void loop() {

  dht11.update();                           // Refresh the data getting pulled from the dht11 temperature sensor

  degreesC = dht11.readCelsius();     	    // Reading the temperature in Celsius degrees and store in the C variable
  degreesF = dht11.readFahrenheit();  	    // Reading the temperature in Fahrenheit degrees and store in the F variable

  lcd.clear();                              // clear the LCD
  lcd.setCursor(0, 0);                      // set the cursor to the top left position
  lcd.print("Degrees C: ");                 // print a label for the data
  lcd.print(degreesC);                      // print the degrees Celsius
  lcd.setCursor(0, 1);                      // set the cursor to the lower left position
  lcd.print("Degrees F: ");                 // Print a label for the data
  lcd.print(degreesF);                      // print the degrees Fahrenheit
  
  unsigned char i;                          // setting a counter variable for how many times the buzzer sounds each loop
  while(degreesF < 33)                      // if the temperature drops below 33 degrees F (32 degrees is freezing) then make the buzzer sound
  {
    // output buzzer sound
    for(i=0;i<10;i++)
    {
      digitalWrite(buzzer,HIGH);
      delay(20);//wait for 2ms
      digitalWrite(buzzer,LOW);
      delay(20);//wait for 2ms
      delay(100);
    }
    // after buzzer sounds for ~half a second
    dht11.update();                         // refresh the data from the temperature sensor
    degreesF = dht11.readFahrenheit();      
  }
  delay(1000);                              //delay for 1 second between each reading (this makes the display less noisy)
}<br>

Step 3: Connecting the LCD Screen

Connect the LCD and potentiometer as shown in the schematic to verify that the LCD is functioning properly. You may have to turn the potentiometer to the left and the right to adjust the contrast in order to see text. If the LCD is connected and operating correctly, it should appear the same way as in the included image.

Step 4: Adding the Temperature Sensor

Connect the temperature sensor as shown in the schematic and in the included image. If everything is connected correctly, the temperature will be displayed in C and F instead of simply a zero as shown in the picture.

Step 5: Adding Extender Wires

Optionally, in order to be able to test the DHT11 Temperature sensor in locations other than the Arduino Uno, we'll add extensions to our jumper wires. The temperatures should be displayed the same way as the previous step, but now you have the option of putting the sensor in different environments away from your Arduino Uno.

Note: Although there are 5 wires used as extensions in the images, only three are required as indicated in the schematics. This is only because I want to re-use these extension wires for other future projects and keep them together. Two of the pins are not connected on either end.

Step 6: Adding the Buzzer

The last step is to add the buzzer (active) as shown in the schematic. Make sure you have the positive pin of the buzzer connected to pin 7 on the Arduino Uno, as it only works one way. You may have to put the buzzer on the breadboard diagonally to fit correctly. Once this step is done, your project is complete! Put the temperature sensor somewhere 32 degrees F or below, and watch the buzzer sound when it drops below freezing!

Step 7: Testing It Out

Congratulations, you've made it to the end! Now try putting the temperature sensor somewhere below freezing and wait for the buzzer when it drops below freezing. Check out our video demonstration included!