/*///================================================================
{Goals}----------------------------------------------------------
Tempteraure & Humidity Control With Fresh Air Recirulation
Input: Buttons Needed: (Set) (Up) (Down)
Input: Sensors Type: GY-213V-HDC1080
Outputs: 2 Relays Dispaly:128x64
Display Info 1306 Screen with Current Temp/Humit and Set Temp/Humit
Voltages: (Heater Element= ) (Heater Fan= ) (Relay #1 For Heater ) (Relay #2 For Humidifier )
lighting and time reset
Time In Days/Hour/Mins With Battery
CO2 Sensor
{Links}----------------------------------------------------------
WOKWI
https://wokwi.com/
Link for Pixle Letter/Numbers: https://www.dafont.com/ / https://www.dafont.com/bitmap.php
Link for Pixle Icon Maker: https://www.photopea.com/
Link for Pixle Icon Conviter: https://javl.github.io/image2cpp/
Link for Pixle Animator: https://animator.wokwi.com/
Link for How to Icon Maker: https://www.youtube.com/watch?v=HVHVkKt-ldc
{Pin-Outs}-------------------------------------------------------
LDC Arduino
VCC - 3.3V
GND - GND
SCL - A5
SDA - A4
{Learning}-------------------------------------------------------
- You create objects from classes.
- Objects and instances are essentially the same thing.
- Each object/instance has its own unique data, even though they are based on the same class.
*///=================================================================
//===================================================================
//-------{ Libaries }----------------------------
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// #include "ClosedCube_HDC1080.h"
#include <DHT.h>
//-------{ define }------------------------------ "Creating a symbolic name for a value or a piece of code"
// Screen
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define SCREEN_I2C_ADDRESS 0x3C
#define OLED_RESET_PIN -1
// Temp & Hum Sensorr
#define DHTPIN 2
#define DHTTYPE DHT22
//{ Create objects/instances }----------------------
// sensors
DHT dht(DHTPIN, DHTTYPE); // Create a DHT object named 'dht'
// screens
Adafruit_SSD1306 screen(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET_PIN); // Create a Display object named 'screen'
//===================================================================
void setup() {
dht.begin();
screen.begin(SSD1306_SWITCHCAPVCC, SCREEN_I2C_ADDRESS);
float t = dht.readTemperature();
float h = dht.readHumidity();
// -----{ Display Code Static }-----
/*
Notes:
Size @1 = 8:Tall 5:Wide Pixles
Size #2 =
Res = 128 x 64
*/
//{ Screen Display }--------------
// Text Size & Color
screen.clearDisplay();
screen.setTextSize(1);
screen.setTextColor(WHITE);
screen.display();
// Tital Screen
screen.setCursor(0, 0);
screen.print("Hydroponic Capsule #1");
screen.display();
// Temperature Display
screen.setCursor(0, 16);
screen.print("Temperature:");
screen.display();
// Humidity Display
screen.setCursor(0, 26);
screen.print("Humidity:");
screen.display();
// Co2 Display
screen.setCursor(0, 36);
screen.print("Co2 ppm:");
screen.display();
// Lighting Display
screen.setCursor(0, 46);
screen.print("Lighting:");
screen.display();
// Timer Display
screen.setCursor(0, 56);
screen.print("Time:");
screen.display();
/*
//{ Sensor Info }--------------
// If the sensor reading is missing
if(isnan(h) || isnan(t))
{
screen.setCursor(80, 16 );
screen.display();
screen.setCursor(80, 16 );
screen.print("N/A");
screen.display();
return;
}
//{ Sensor Reading }--------------
// Displaying Temp & Humit Reading
screen.setCursor(80, 16);
screen.setTextSize(1);
screen.print(t);
screen.print((char)247);
screen.print("C");
screen.display();
screen.setCursor(80, 26);
screen.setTextSize(1);
screen.print(h);
screen.print("%");
screen.display();
*/
}
void loop() {
delay(1000); //Delay 2 seconds
float t = dht.readTemperature();
float h = dht.readHumidity();
//{ Sensor Info }--------------
// If the sensor reading is missing
if(isnan(h) || isnan(t))
{
screen.setCursor(80, 16 );
screen.print("N/A");
screen.display();
screen.setCursor(80, 26 );
screen.print("N/A");
screen.display();
return;
}
//{ Sensor Reading }--------------
// Displaying Temp & Humit Reading
if (!isnan(h) && !isnan(t))
{
screen.setCursor(80, 16);
screen.setTextSize(1);
screen.print(t);
screen.print((char)247); // Degree symbol
screen.print("C");
screen.display();
screen.setCursor(80, 26);
screen.setTextSize(1);
screen.print(h);
screen.print("%");
screen.display();
return;
}
}