Arduino Projects

BIO TANK

Here's a breakdown of the code:



}/* * 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!