Arduino UNO Based Temperature
Arduino UNO Based Temperature
Group #:
Members:
Circuit Documentation
Summary
This circuit is designed to monitor temperature using a DHT11 sensor and control an output based
on the temperature readings. When the temperature reaches 36 degrees Celsius, the output is
turned on, and when it drops to 34 degrees Celsius, the output is turned off. The status of the output
and the current temperature are displayed on a 16x2 LCD. The circuit is powered by an Arduino
UNO, which also controls the LCD and the relay module that acts as the output. The LCD's contrast is
set via a voltage divider.
Component List
Arduino UNO
16X2 LCD
• A liquid crystal display capable of displaying 16 characters per line across 2 lines.
• It has a backlight and can be used to display alphanumeric characters.
• An electromechanical switch that can be controlled with a low voltage signal from the
Arduino.
• It has one normally open (N.O.), one normally closed (N.C.), and one common (COM)
terminal.
DHT11
Wiring Details
Arduino UNO
• 3.3V to 16X2 LCD backlight anode (A).
• 5V to 1 Channel 5V Relay Module VCC+ and DHT11 5V.
• GND to 1 Channel 5V Relay Module VCC- (GND), DHT11 GND, and 16X2 LCD backlight
cathode (K).
• D13 to 1 Channel 5V Relay Module IN.
• D12 to 16X2 LCD RS.
• D11 to 16X2 LCD E.
• D7 to DHT11 Signal (S).
• D5 to 16X2 LCD D4.
• D4 to 16X2 LCD D5.
• D3 to 16X2 LCD D6.
• D2 to 16X2 LCD D7.
16X2 LCD
DHT11
#include <DHT.h>
#include <LiquidCrystal.h>
#define DHTPIN 7 // Define the pin connected to the DHT11 data pin
#define DHTTYPE DHT11 // Specify the type of DHT sensor
#define OUTPUT_PIN 13 // Define the pin connected to the Relay Module input
void setup() {
pinMode(OUTPUT_PIN, OUTPUT); // Set the relay control pin as output
lcd.begin(16, 2); // Set up the LCD's number of columns and rows
dht.begin(); // Start the DHT sensor
}
void loop() {
float temp = dht.readTemperature(); // Read temperature in Celsius
if (isnan(temp)) { // Check if the reading failed
lcd.clear(); // Clear the LCD
lcd.setCursor(0, 0); // Set the cursor to the top-left position
lcd.print("Error reading"); // Print an error message
lcd.setCursor(0, 1); // Move to the second line
lcd.print("temperature"); // Continue the error message
return; // Skip the rest of the loop
}
lcd.clear(); // Clear the LCD for fresh data
lcd.setCursor(0, 0); // Set the cursor to the top-left position
lcd.print("Temp: "); // Print "Temp: "
lcd.print(temp); // Print the temperature value
lcd.print(" C"); // Print the Celsius symbol
if (temp >= 36) { // If the temperature is high enough
digitalWrite(OUTPUT_PIN, HIGH); // Turn on the relay
lcd.setCursor(0, 1); // Move to the second line
lcd.print("Status: ON "); // Print the status
} else if (temp <= 34) { // If the temperature is low enough
digitalWrite(OUTPUT_PIN, LOW); // Turn off the relay
lcd.setCursor(0, 1); // Move to the second line
lcd.print("Status: OFF"); // Print the status
}
delay(2000); // Wait for 2 seconds before the next reading
This
} code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the DHT11
sensor and the 16x2 LCD, reads the temperature, and controls the relay module based on the
temperature readings. It also handles the display of temperature and status information on the LCD.