This project is about my 6th grade science project. The Arduino-based liquid temperature monitor is a versatile project designed specifically for measuring the temperature of liquids. Whether you’re a hobbyist, a science enthusiast, or a homebrewer, this project offers a fun and educational way to explore sensor interfacing and real-world applications.
Functionality
- Liquid Temperature Measurement:
- The heart of this project is an Arduino microcontroller (such as the Arduino Uno or Nano) equipped with a temperature sensor DHT22 for environmental measurements and a DS18B20 as a liquid temperature sensor
- The sensor provides accurate readings of the liquid’s temperature.
- These measurements are crucial for various applications, including brewing, aquariums, and chemical processes.
- Visual Feedback:
- The liquid temperature monitor can display the temperature using LEDs or an LCD screen.
- For example, you can use different colored LEDs (blue for cold, green for optimal, and red for hot) to indicate the liquid’s temperature range.
Possible Uses
- Homebrewing and Fermentation:
- Use the liquid temperature monitor during beer brewing, wine making, or kombucha fermentation.
- Maintain precise temperatures for optimal yeast activity and flavor development.
- Aquariums and Fish Tanks:
- Monitor the water temperature in aquariums.
- Ensure that fish and aquatic plants thrive in the right temperature range.
- Chemical Reactions and Labs:
- Use the monitor in chemistry experiments or research.
- Monitor reaction temperatures to achieve desired outcomes.
- Hydroponics and Plant Growth:
- Measure nutrient solution temperatures in hydroponic systems.
- Adjust the temperature to promote healthy plant growth.
Arduino Uno
Breadboard
DHT 22 sensor
LCD 2x16 i2c
DS18B20 temperature sensor
Leds x 3
Tactile Button
Toggle switch x 2
Buzzer
18650 Battery holder
18650 Battery x 2
Cables
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
#include <OneWire.h>
#include <DallasTemperature.h>
#include “DHT.h”
int value;
#define DHTPIN 27 // Digital pin connected to the DHT sensor
#define ONE_WIRE_BUS 14
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
int StateChangeButton;
int StateCFButton;
const int ChangeButton = 17; // ChangeButton pin
const int CFButton = 12; //CFButton pin
int GreenLED = 23; // green LED pin
int BlueLED = 19; // blue LED pin
int RedLED = 25; // red LED pin
int Buz=16; // Buzzer pin
OneWire oneWire(14);
DallasTemperature sensors(&oneWire);
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x3F,16,2) for 16×2 LCD.
void setup() {
pinMode(ChangeButton, INPUT_PULLUP );
pinMode(CFButton, INPUT_PULLUP );
pinMode(GreenLED, OUTPUT); // Declare the LED as an output
pinMode(BlueLED, OUTPUT); // Declare the LED as an output
pinMode(RedLED, OUTPUT); // Declare the LED as an output
pinMode(Buz, OUTPUT); // Declare the LED as an output
Serial.begin(9600);
sensors.begin();
dht.begin();
// Initiate the LCD:
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(“Hello!!”); // Print the string “Hello World!”
lcd.setCursor(0, 1); // Set the cursor on the first column and first row.
lcd.print(“Mary Spiridaki”); // Print the string “Hello World!”
delay(2000);
lcd.clear();
}
void loop() {
// read Sensors
StateChangeButton = digitalRead(ChangeButton); // Read ChangeButton State
// Read Air Thermometer
float h = dht.readHumidity();//Reading temperature or humidity takes about 250 milliseconds!
float t = dht.readTemperature(); // Read temperature as Celsius (the default)
float f = dht.readTemperature(true); // Read temperature as Fahrenheit (isFahrenheit = true)
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F(“Failed to read from DHT sensor!”));
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
//Read Liquid Thermometer
sensors.requestTemperatures();
if ( digitalRead(CFButton) == HIGH ){
if ( StateCFButton == 0 ){
StateCFButton = 1;
}else if ( StateCFButton == 1 ){
StateCFButton = 0;
}
}
if ( StateChangeButton == LOW ){
if ( StateCFButton == 0 ){
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(“Air Temp:”); // Print the string “Hello World!”
lcd.print(t); // Print the string “Hello World!”
lcd.print(char(223));
lcd.print(“C”); // Print the string “Hello World!”
lcd.setCursor(0, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
lcd.print(” Hum:”);
lcd.print(h);
lcd.print(“% “);
lcd.print(” “);
}else if ( StateCFButton == 1 ){
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(“Air Temp: “); // Print the string “Hello World!”
lcd.print(f); // Print the string “Hello World!”
lcd.print(“F”); // Print the string “Hello World!”
lcd.setCursor(0, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
lcd.print(” Hum: “);
lcd.print(h);
lcd.print(“% “);
}
if (t>35 || h >80) {
digitalWrite(Buz, HIGH); // Turn the LED on
delay (2000);
} else {
digitalWrite(Buz, LOW);
}
if (t<22) {
digitalWrite(BlueLED, HIGH);
digitalWrite(GreenLED, LOW);
digitalWrite(RedLED, LOW);
} else if (t>30) {
digitalWrite(BlueLED, LOW);
digitalWrite(GreenLED, LOW);
digitalWrite(RedLED, HIGH);
}else {
digitalWrite(BlueLED, LOW);
digitalWrite(GreenLED, HIGH);
digitalWrite(RedLED, LOW);
}
}else {
if ( StateCFButton == 0 ){
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(“Liquid Sensor “); // Print the string “Hello World!”
lcd.setCursor(0, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
lcd.print(“Temp: “);
lcd.print(sensors.getTempCByIndex(0));
lcd.print(char(223));
lcd.print(“C”);
lcd.print(” “);
}else if ( StateCFButton == 1 ){
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print(“Liquid Sensor “); // Print the string “Hello World!”
lcd.setCursor(0, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
lcd.print(“Temp: “);
lcd.print(sensors.getTempFByIndex(0));
lcd.print(” “);
lcd.print(“F”);
lcd.print(” “);
}
if (sensors.getTempCByIndex(0)>50) {
digitalWrite(Buz, HIGH); // Turn the LED on
delay (2000);
} else {
digitalWrite(Buz, LOW);
}
if (sensors.getTempCByIndex(0)<16) {
digitalWrite(BlueLED, HIGH);
digitalWrite(GreenLED, LOW);
digitalWrite(RedLED, LOW);
} else if (sensors.getTempCByIndex(0)>27) {
digitalWrite(BlueLED, LOW);
digitalWrite(GreenLED, LOW);
digitalWrite(RedLED, HIGH);
}else {
digitalWrite(BlueLED, LOW);
digitalWrite(GreenLED, HIGH);
digitalWrite(RedLED, LOW);
}
}
delay (400);
}