Arduino Projects
BIO TANK
Here's a breakdown of the code:
It includes necessary libraries for controlling a LiquidCrystal display, reading temperature and humidity from DHT sensor, and reading temperature from a DallasTemperature sensor.
It defines pin numbers for the relay, DHT sensor, and DallasTemperature sensor.
In the setup() function:
Serial communication is initiated at a baud rate of 9600.
The relay pin is configured as an output.
Initialization of DHT and DallasTemperature sensors.
Initialization of the LiquidCrystal display.
In the loop() function:
The LiquidCrystal display is cleared and initial headings are printed.
The DallasTemperature sensor reads the water temperature.
If the water temperature is below 75°F, the relay pin is set high (assuming it controls a heating device), otherwise it's set low.
Temperature and humidity readings from the DHT sensor are obtained.
If all readings are valid, they are displayed on the LCD and printed to the serial monitor.
Each set of readings is displayed for 2 seconds before being cleared.
}/* * Project: BioTank Habitat * Author: Douglas Fessler * Date: February 18, 2024 * Description: Arduino sketch to monitor and control conditions in a bio tank habitat using sensors and a relay. */
#include <LiquidCrystal.h>#include <DHT.h>#include <OneWire.h>#include <DallasTemperature.h>
#define RELAY_PIN 3#define DHTPIN 2#define DHTTYPE DHT11
#define ONE_WIRE_BUS 6OneWire oneWire(ONE_WIRE_BUS);DallasTemperature sensors(&oneWire);DHT dht(DHTPIN, DHTTYPE);LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() { Serial.begin(9600); pinMode(RELAY_PIN, OUTPUT); dht.begin(); sensors.begin(); lcd.begin(16, 2);}
void loop() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("BIO TANK HABITAT"); lcd.setCursor(0, 1); lcd.print(" CONDITIONS");
delay(2000);
sensors.requestTemperatures(); float WatertempC = sensors.getTempCByIndex(0); float WatertempF = (WatertempC * 9.0 / 5.0) + 32.0;
if (WatertempF < 75.0) { digitalWrite(RELAY_PIN, HIGH); } else { digitalWrite(RELAY_PIN, LOW); }
float humi = dht.readHumidity(); float tempC = dht.readTemperature(); float tempF = dht.readTemperature(true);
if (isnan(humi) || isnan(tempC) || isnan(tempF)) { Serial.println("Failed to read from DHT sensor!"); } else { lcd.clear(); lcd.setCursor(0, 0); lcd.print("BIO TANK HABITAT"); lcd.setCursor(0, 1); lcd.print("Air Temp: "); lcd.print(tempF); lcd.print(" F ");
delay(2000);
lcd.clear(); lcd.setCursor(0, 0); lcd.print("BIO TANK HABITAT"); lcd.setCursor(0, 1); lcd.print("H2O Temp: "); lcd.print(WatertempF); lcd.print(" F ");
delay(2000);
lcd.clear(); lcd.setCursor(0, 0); lcd.print("BIO TANK HABITAT"); lcd.setCursor(0, 1); lcd.print("Humidity: "); lcd.print(humi); lcd.print("%");
delay(2000);
Serial.print("Temperature: "); Serial.print(tempC); Serial.print("°C ~ "); Serial.print(tempF); Serial.print("°F | "); Serial.print("Humidity: "); Serial.print(humi); Serial.print("% | "); Serial.print("Water Temp: "); Serial.print(WatertempC); Serial.print("°C ~ "); Serial.println(WatertempF); }}
Donate
If you've enjoyed exploring my Arduino projects and want to see more amazing creations, your support can make a big difference! By contributing, you're helping me continue to innovate and bring even more exciting projects to life. Together, we can explore the endless possibilities of DIY electronics! Don't forget to like, subscribe, and follow for updates on the latest developments. Thank you for being a part of this journey!
Click here to make a difference with your donation today!