The project involves making a simple cooling fan for a laptop but this time will be automatic by using Arduino and coding.
When the temperature gets too high, the fan automatically turns on to cool the laptop down.
This project aims to keep laptops from overheating, especially during heavy use and can be easily carried around due to its portable design.
SOFTWARE
Simulation Software
Arduino Software
COMPONENTS
Thinking about what components make this function and idea (DHT Sensor, DC Fan, Switch, LCD)
I was searching how to connect these components with an Arduino board.
Coding:
Thinking about how I can make the code to perform the idea🤔.
If I turn on the laptop fan, I need to detect if the temperature is hot or not.
If it is hot the fan will automatically turn on and the temperature and humidity will display on the LCD.
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHTTYPE DHT11 // DHT11 sensor type
#define DHTPIN 2 // Pin where the DHT sensor is connected
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
int LED = 3;
int Relay = 4;
int Switch = 5;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin(); // Initialize DHT sensor
pinMode(LED, OUTPUT);
pinMode(Relay, OUTPUT);
pinMode(Switch, INPUT_PULLUP);
}
void loop() {
int Switch_Read = digitalRead(Switch);
if (Switch_Read == LOW) {
float humidity = dht.readHumidity();
float temp = dht.readTemperature();
Serial.print("Humidity (%): "); // Just for check
Serial.println(humidity);
delay(1000);
Serial.print("temperature (%): ");
Serial.println(temp);
delay(1000);
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Temp = ");
lcd.setCursor(7, 0);
lcd.print(temp);
lcd.setCursor(0, 1);
lcd.print("Humd = ");
lcd.setCursor(7, 1);
lcd.print(humidity);
if (temp > 20) {
digitalWrite(LED, HIGH);
digitalWrite(Relay, HIGH);
} else {
digitalWrite(LED, LOW);
digitalWrite(Relay, LOW);
}
} else {
digitalWrite(LED, LOW);
digitalWrite(Relay, LOW);
}
}
First, testing each component to make sure that all works well.
Arduino --> connecting the 5-volt and GND from Arduino to positive and negative lines on the breadboard.
DHT Sensor --> Connect 3 pins of the DHT with the +ve, and -ve lines in the breadboard and PIN 2 in Arduino.
Relay --> Connect the V IN, GND with the +ve, and -ve lines in the breadboard, IN PIN to PIN 5 in Arduino, NO PIN to the +ve of the adaptor, and COM to the +ve of the fan.
Fan --> Connect its +ve to COM in Relay, and the other one to the -ve line.
Switch --> Connect any terminal to PIN 5 and the other one to the -ve line.
Next, connected the Arduino Jake to the laptop, and from Arduino IDE I chose the correct port and then uploaded the code on Arduino.
First, when I uploaded the code the ON/OFF Switch did not work.
Solution
To troubleshoot, I used the Serial Monitor to print something inside the if condition to see if it was being executed. It turned out that the condition wasn't being met. After reviewing the code, I realized that I had forgotten to store the switch reading in a separate variable.
This week, I learned how to connect many components with Arduino, making code Text to make the code of the project and I will use this in my final project.
This week I searched to learn more things about Arduino and this playlist was very helpful.