Introduction: Sky Control V1 - Temperature and Humidity Controller With Relays

This intructable will teach you how to make very cheap Sky Control module (temperature and humidity controller). All the parts cost below 10$.

The module is based on Arduino Uno. It uses a DHT22 sensor to measure temperature and humidity. The results are displayed on LCD Screen and pre-sets can be changed by using buttons. By using 2 relays you are able to connect any humidifier and heating element up to 2.5 kW. In this project devices connected to relays should have separate power source (even for 5V heating plate and humidifier that I’m using in my terrarium). In next project I will add Dust Sensor for controlling Air Pollution

Shopping List

1. Arduino uno

2. DHT22 sensor - https://tinyurl.com/lm7pgqa

3. LCD Keypad Shield - https://tinyurl.com/lcd-keypad

4. 2-channel 5v relay Module - https://tinyurl.com/2-channel-relay

Optional

1. Arudiono Screw Shield – to make this easier to connect - https://tinyurl.com/screw-shield

2. Heating plate - https://tinyurl.com/kqu9ra5

3. USB ultrasonic nebulizer - https://tinyurl.com/msc7svv

Step 1: Wiring

Connect everything as shown on schematics (Fritizng file and parts available to download below)

I’m not showing LCD wiring as it slides on top of Arduino.

Remember to put 4.7 kohm resistor between 5V and SIG nodes od DHT22. You can buy DHT sensors with built in resistor, if so you don’t need external one.

To connect anything to relay – power source goes to COM1 and COM2 in relay and devices that should be turned on and off to NO1 and NO2 (NO – Normally Open).

I'm using Screw Shield - so i do not have to solder anything

Step 2: The Code - It Looks Bad on the Site, But Grab Attached File

/*Sky Control - Temperature and humidity sensor with relays made by ArkadiuszO2 v1
* Please read comments * Shopping list includes: * 1. Arduino Uno * 2. DHT22 sensor * 3. 2 channel relay - 5V * 4. DFRobot LCD Keypad Shield * * In V2 i will add Air quality sensor based on Sharp's GP2Y1010AU0F */
#include <LiquidCrystal.h>
#include <DFR_key.h>
#include <DHT.h>
//Starting values after boot up, you can change them
int temp = 25;
int hum = 50;
//For DHT22 (AM2023)
#define DHTPIN 15
#define DHTTYPE DHT22
const int relay1 =  18;
const int relay2 =  19;
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 
DFR_Key keypad;
int localKey = 0;
String keyString = "";
int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT 0
#define btnUP 1 #define btnDOWN 2 #define btnLEFT 3 #define btnSELECT 4 #define btnNONE 5

int read_LCD_buttons(){
adc_key_in = analogRead(0); if (adc_key_in > 1000) return btnNONE; if (adc_key_in < 50) return btnRIGHT; if (adc_key_in < 250) return btnUP; if (adc_key_in < 450) return btnDOWN; if (adc_key_in < 650) return btnLEFT; if (adc_key_in < 850) return btnSELECT; } void setup() { pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Sky control v1"); lcd.setCursor(0, 1); lcd.print("Instr on Select"); delay(2500); Serial.begin(9600); dht.begin(); delay(1000); lcd.clear(); //Sample rate (default 10 ms) keypad.setRate(10); digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH);}

void loop() {

float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(t) || isnan(h)) { //checking sensor operation lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Sensor broken!!"); delay(10000); } else { //You can change values (step) after each button press, default is 1'C for step and 5% humidity lcd_key = read_LCD_buttons(); switch (lcd_key){ case btnLEFT:{ temp = temp +1; break; } case btnRIGHT:{ temp = temp - 1; break; } case btnUP:{ hum = hum + 5; break; } case btnDOWN:{ hum = hum - 5; break; } case btnSELECT:{ lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Hum Up/Down +-5%"); lcd.setCursor(0, 1); lcd.print("Temp L/R +-1"); lcd.print((char)223); lcd.print("C"); delay (5000); break; } } lcd.setCursor(0, 0); lcd.print("Hum: "); lcd.print(h); lcd.print("%"); lcd.print("("); lcd.print(hum); lcd.print("%)"); lcd.setCursor(0, 1); lcd.print("Tem: "); lcd.print(t); lcd.print((char)223); lcd.print("("); lcd.print(temp); lcd.print((char)223); lcd.print(")");

//adding this so the humidifier will not be powering on and off constantly (humidifier will exceed upper limit by 10% - IF YOU NEED EXACT VALUES COMMENT THIS SECTION AND UNCOMMENT NEXT !! 

int H = hum + 10;
if(h < hum ) digitalWrite(relay1, LOW); else if (h >= H) digitalWrite(relay1, HIGH);

/* <- UNCOMMENT THIS IF YOU NEED EXACT VALUES BUT COMMENT 5 LINES ABOVE if(h < hum ) digitalWrite(relay1, LOW); else digitalWrite(relay1, HIGH); */

if(t < temp ) digitalWrite(relay2, LOW); else digitalWrite(relay2, HIGH);

}

}

Step 3: Operation

Upon pressing Select you will see basic operation instruction

Up/Down changes preset humidity by +- 5%

Left/Right changes preset temperature by +-1 °C

In the code you will find that humidifier will exceed preset limit by 10% - this is done so it will not be powering it on and off constantly, so ie. you have set 50% target humidity - the relay will power on the humidifier when reading will reach 49% and power it down when it reaches 60%. You can change that by modifying the code.