Wednesday

FYP2 WEEK 9

 Activity: Complete the coding for FYP 2

Objective: 

  • To complete the DHT22 coding for the project
  • To test the coding and troubleshoot the program if there is any problem

#include <Wire.h>
#include "DHT.h"
#include <LiquidCrystal_I2C.h>

#define DHTPIN 12
#define DHTTYPE DHT22

LiquidCrystal_I2C lcd (0x27, 20, 4);      //I2C address 0x27, 20 column and 4 row
DHT dht(DHTPIN,DHTTYPE);

int temp_sensor_pin = A0;                 //The output pin of LM35
int ref_pin = A1;
int fan_pin = 9;
int waterpump_pin = 10; 
int heater_pin = 5;
int red_led = 6;
int green_led = 7;
int blue_led = 8;
int buzzer_pin = 11;
int fan_speed;
int ref_value_min = 0;
int ref_value_max = 50;
int max_temp_limit;
int min_temp_limit;


void setup ()
{
  Serial.begin(9600);
  dht.begin();
  lcd.init();
  lcd.backlight();
  lcd.setCursor(6,0);
  lcd.print("AUTOMATIC");
  lcd.setCursor(0,1);
  lcd.print("COOLING ROOF SYSTEM");
  lcd.setCursor(10,2);
  lcd.print("BY");
  lcd.setCursor(8,3);
  lcd.print("EIZLAN");
  delay(1500);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Ref.Temp:");
  lcd.setCursor(0,1);
  lcd.print("Cur.Temp:");
  pinMode(red_led,OUTPUT);
  pinMode(green_led,OUTPUT);
  pinMode(blue_led,OUTPUT);
  analogWrite(fan_pin, fan_speed);
  analogWrite(waterpump_pin, fan_speed);
}

void loop()
{
  int ref_value;
  float temperature = dht.readTemperature();
  ref_value = analogRead(ref_pin);
  ref_value = map(ref_value, 0, 1023, 0, 100);
  max_temp_limit = ref_value+5;
  min_temp_limit = ref_value-5;
  lcd.setCursor(10,0);
  lcd.print(ref_value);                             //Print refference temperature
  lcd.print(" ");
  lcd.print((char)223);   
  lcd.print("C");
  lcd.setCursor(10,1);
  lcd.print(temperature);                           //Print temperature
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");
  Serial.print("Temperature: ");
  Serial.println(temperature);
  if (temperature > max_temp_limit)
  {
    lcd.setCursor(0,2);
    lcd.print("HIGH TEMPERATURE");
    lcd.setCursor(0,3);
    lcd.print("FAN & WP TURN ON");

    if(fan_speed<150) fan_speed +=20;
    analogWrite(fan_pin, fan_speed);
    analogWrite(waterpump_pin, fan_speed);
    digitalWrite(heater_pin, LOW);
    digitalWrite(red_led,HIGH);
    delay(100);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,LOW);
    digitalWrite(blue_led,LOW);
    tone(buzzer_pin,1245,1000);
  }

  else if (temperature < min_temp_limit)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Ref.Temp:");
    lcd.setCursor(0,1);
    lcd.print("Cur.Temp:");
    lcd.setCursor(10,0);
    lcd.print(ref_value);                             //Print refference temperature
    lcd.print(" ");
    lcd.print((char)223);   
    lcd.print("C");
    lcd.setCursor(10,1);
    lcd.print(temperature);                           //Print temperature
    lcd.print(" ");
    lcd.print((char)223);
    lcd.print("C");

    lcd.setCursor(0,2);
    lcd.print("LOW TEMPERATURE");
    lcd.setCursor(0,3);
    lcd.print("HEATER TURN ON");

   if(fan_speed<150) fan_speed +=20;
    digitalWrite(fan_pin, LOW);
    digitalWrite(waterpump_pin, LOW);
    analogWrite(heater_pin, fan_speed);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,LOW);
    digitalWrite(blue_led,HIGH);
  }

  else if((temperature <max_temp_limit) && (temperature > min_temp_limit))
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Ref.Temp:");
    lcd.setCursor(0,1);
    lcd.print("Cur.Temp:");
    lcd.setCursor(10,0);
    lcd.print(ref_value);                             //Print refference temperature
    lcd.print(" ");
    lcd.print((char)223);   
    lcd.print("C");
    lcd.setCursor(10,1);
    lcd.print(temperature);                           //Print temperature
    lcd.print(" ");
    lcd.print((char)223);
    lcd.print("C");

    lcd.setCursor(0,2);
    lcd.print("TEMPERATURE IS");
    lcd.setCursor(0,3);
    lcd.print("WITHIN LIMIT");
    
    if(fan_speed<150) fan_speed +=20;
    analogWrite(fan_pin, fan_speed); 
    digitalWrite(waterpump_pin, LOW);
    digitalWrite(heater_pin, LOW);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,HIGH);
    digitalWrite(blue_led,LOW);
    }
  delay(1000);                            //1s delay 
}

FYP2 WEEK 8

 Activity: Testing the voltage for the fan, LM35 and DHT22

Objective:

  • To test the voltage for the output devices and the temperature sensor.
For this testing, I want to see if the output devices and both the temperature sensor have the required voltage.




Type

Input Voltage

LM35

4 V

DHT22

4 V

Fan

5V



Tuesday

FYP2 WEEK 7

ActivityConstruct the circuit on Breadboard and testing

Objective:

·                     To construct the circuit

·                     To testing the circuit operation.

 

In this week, the student starts to construct the circuit on the breadboard.

 

Conclusion:

This can conclude the activity above has done the experiment on the circuit, but the circuit constructed were not operated perfectly 

Wednesday

FYP2 WEEK 6

Activity: Complete the coding for FYP 2

Objective: 

  • To complete the LM35 coding for the project
  • To test the coding and troubleshoot the program if there is any problem

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27,20,4);      //I2C address 0x27, 20 column and 4 row
int temp_sensor_pin = A0;                 //The output pin of LM35
int ref_pin = A1;
int fan_pin = 9;
int waterpump_pin = 10; 
int heater_pin = 5;
int red_led = 6;
int green_led = 7;
int blue_led = 8;
int buzzer_pin = 11;
int fan_speed;
int temperature;
int ref_value_min = 0;
int ref_value_max = 50;
int max_temp_limit;
int min_temp_limit;

void setup ()
{
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(6,0);
  lcd.print("AUTOMATIC");
  lcd.setCursor(0,1);
  lcd.print("COOLING ROOF SYSTEM");
  lcd.setCursor(10,2);
  lcd.print("BY");
  lcd.setCursor(8,3);
  lcd.print("EIZLAN");
  delay(1500);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Ref.Temp:");
  lcd.setCursor(0,1);
  lcd.print("Cur.Temp:");
  pinMode(red_led,OUTPUT);
  pinMode(green_led,OUTPUT);
  pinMode(blue_led,OUTPUT);
  analogWrite(fan_pin, fan_speed);
  analogWrite(waterpump_pin, fan_speed);
}

void loop()
{
  int sensor_value;
  int ref_value;

  sensor_value = analogRead(temp_sensor_pin);       //Get the sensor reading
  ref_value = analogRead(ref_pin);
  ref_value = map(ref_value, 0, 1023, 0, 100);
  temperature = sensor_value * 0.48828125;
  max_temp_limit = ref_value+5;
  min_temp_limit = ref_value-5;
  lcd.setCursor(10,0);
  lcd.print(ref_value);                             //Print refference temperature
  lcd.print("C");
  lcd.setCursor(10,1);
  lcd.print(temperature);                           //Print temperature
  Serial.print("Temperature: ");
  Serial.println(temperature);
  lcd.print("C");

  if (temperature > max_temp_limit)
  {
    lcd.setCursor(0,2);
    lcd.print("HIGH TEMPERATURE");
    lcd.setCursor(0,3);
    lcd.print("FAN & WP TURN ON");

    if(fan_speed<150) fan_speed +=20;
    analogWrite(fan_pin, fan_speed);
    analogWrite(waterpump_pin, fan_speed);
    digitalWrite(heater_pin, LOW);
    digitalWrite(red_led,HIGH);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,LOW);
    digitalWrite(blue_led,LOW);
    tone(buzzer_pin,1245,1000);
  }

  else if (temperature < min_temp_limit)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Ref.Temp:");
    lcd.setCursor(0,1);
    lcd.print("Cur.Temp:");
    lcd.setCursor(10,0);
    lcd.print(ref_value);                             //Print refference temperature
    lcd.print("C");
    lcd.setCursor(10,1);
    lcd.print(temperature);                           //Print temperature
    lcd.print("C");

    lcd.setCursor(0,2);
    lcd.print("LOW TEMPERATURE");
    lcd.setCursor(0,3);
    lcd.print("HEATER TURN ON");
    
    if(fan_speed<150) fan_speed +=20;
    digitalWrite(fan_pin, LOW);
    digitalWrite(waterpump_pin, LOW);
    analogWrite(heater_pin, fan_speed);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,LOW);
    digitalWrite(blue_led,HIGH);
  }

  else if((temperature <max_temp_limit) && (temperature > min_temp_limit))
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Ref.Temp:");
    lcd.setCursor(0,1);
    lcd.print("Cur.Temp:");
    lcd.setCursor(10,0);
    lcd.print(ref_value);                             //Print refference temperature
    lcd.print("C");
    lcd.setCursor(10,1);
    lcd.print(temperature);                           //Print temperature
    lcd.print("C");

    lcd.setCursor(0,2);
    lcd.print("TEMPERATURE IS");
    lcd.setCursor(0,3);
    lcd.print("WITHIN LIMIT");
    
    if(fan_speed<150) fan_speed +=20;
    analogWrite(fan_pin, fan_speed); 
    digitalWrite(waterpump_pin, LOW);
    digitalWrite(heater_pin, LOW);
    digitalWrite(red_led,LOW);
    digitalWrite(green_led,HIGH);
    digitalWrite(blue_led,LOW);
    }
  delay(1000);                            //1s delay 
}

FYP2 WEEK 5

 Activity: START BUYING THE COMPONENT

Objective: Starting this week, the student already listed the component that needs to buy. For most of the component such as resistor, transistor, potentiometer etc. I bought from Shoppe. The component will take some time to be delivered. For the time being, I completed my full circuit diagram for the simulation.