Modern gadgets and dwellings require efficient temperature regulation.
It prolongs gadget life and keeps things pleasant.
One useful example of this technology is a temperature-controlled fan.
Depending on the ambient temperature, it automatically modifies its pace.
This maintains temperature while lowering noise and energy consumption.
Here IC LM35 sensor is used to measure the temperature.
A 5V single channel relay module will activate an air conditioning fan to cool the space when the temperature rises too high.
The practical uses of Arduino are demonstrated by this project.
Developing intelligent temperature control systems is a breeze using the widely used and user friendly Arduino microcontroller.
Connecting sensors and devices is made easier by it.
Coding with Explanation:
#include <SoftwareSerial.h>
const int tempPin = A0; // Analog pin for temperature sensor
const int relayPin = 2; // Digital pin for relay
const int thresholdTemp = 30; // Temperature threshold in degrees Celsius
void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
}
void loop() {
int sensorValue = analogRead(tempPin);
float temperature = (sensorValue / 1023.0) * 5.0 * 100.0; // Convert sensor value to temperature
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" degrees Celsius");
if (temperature >= thresholdTemp) {
digitalWrite(relayPin, HIGH); // Activate relay
Serial.println("Fan turned on");
} else {
digitalWrite(relayPin, LOW); // Deactivate relay
Serial.println("Fan turned off");
}
delay(1000); // Delay for 1 second
}
Explanation:
- #include: The SoftwareSerial library, which is used for serial communication, is included on this line.
- But because it is not needed in the present code, it is eliminated.
- The temperature sensor is linked to the Arduinos analog pin A0, as indicated by the line that establishes the constant tempPin with the value A0.
- const int relayPin = 2; the relay is linked to the Arduinos digital pin 2 according to this line that defines a constant relayPin with the value 2.
- const int thresholdTemp = 30; the temperature threshold in degrees Celsius is defined as a constant in this line, with the value 30.
- The fan will activate as soon as the temperature rise over this threshold.
- Serial.begin(9600); data transmission and reception via the serial monitor are made possible by this line, which starts the serial communication at a baud rate of 9600.
- pinMode(relayPin, OUTPUT); the relayPin is configured as an output pin in this line, and it will be used to control the relay.
- The line that reads the analog value from the tempPin and puts it in the sensorValue variable is int sensorValue = analogRead(tempPin);
- This line changes the analogue value to a temperature value in degrees Celsius: float temperature = (sensorValue / 1023.0) * 5.0 * 100.0;
- The LM35 sensor is assumed to provide a voltage between 0 and 5 volts, which is equivalent to a temperature range of 0 to 100 degrees Celsius in the calculation.
- The line “Temperature: ” is sent to the serial monitor via Serial.print(“Temperature: “);”
- Serial.print(temperature); the temperature value that has been computed is printed to the serial monitor in this line.
- {…} otherwise {…};: if (temperature >= thresholdTemp) The temperature is checked to see if it is higher than or equal to the thresholdTemp using this conditional expression.
- RelayPin is set to HIGH by the digitalWrite(relayPin, HIGH); line, which triggers the relay if the temperature rises beyond the threshold.
- A message stating that the fan is turned on is printed by the Serial.println(“Fan turned on”); line.
- The digitalWrite(relayPin, LOW); line deactivates the relay by setting the relayPin to LOW if the temperature drops below the threshold.
- The fan is switched off, as indicated by the message printed in the Serial.println(“Fan turned off”); line.
- delay(1000); before the loop repeats, this line adds a 1000 milliseconds (1 second) delay, enabling a little break between temperature measurements and fan control.
Circuit Working:
Parts List:
Component | Quantity |
---|---|
Arduino UNO board | 1 |
IC 7809 voltage regulator | 1 |
IC LM35 temperature sensor | 1 |
5V single channel relay | 1 |
220V AC fan | 1 |
The circuit for the temperature-controlled fan is rather simple.
Three pins make up the LM35 sensor: VCC, GND and analog output pin.
The Arduino 5V pin will be linked to the VCC pin.
The analog output pin will be linked to the Arduinos A0 pin, and the GND pin will be connected to the GND pin.
The IC 7809 is used to control the 5V output from the Arduino to 3.3V so that the LM35 temperature sensor may be powered.
A voltage that is proportionate to the temperature is produced by the LM35 sensor.
The analog input pin on the Arduino reads this voltage.
A predetermined threshold is compared with the measured temperature by the Arduino.
An electromagnetic relay with a single switching channel and a 5V control voltage is known as a 5V relay.
Relays of this kind are frequently used in a variety of electrical and electronic circuits to control loads or high power devices with low power signals, usually from microcontrollers or other digital control sources.
This relay is turned on when the temperature rises over the threshold.
To cool the surroundings, the 220V AC fan is connected to the power supply via the activated relay.
The Arduino activates the relay to turn on the AC fan “ON” when the temperature reading from the LM35 rises beyond the predetermined threshold, in this case 30 degrees Celsius.
A cooling mechanism is provided by this operation to keep the temperature within the intended range.
When the temperature stays below the threshold in the second case, the Arduino does not send any signal to the relay, which keeps the fan “OFF.”
By automating the fan to only run when necessary, energy is saved and a comfortable temperature is maintained in the room.
How to Build:
To build a DIY Temperature-Controlled Fan with Arduino following are the steps to follow:
- Gather all the components as mentioned in the above circuit diagram.
- Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
- Connect IC LM35 temperature sensor VCC pin to the 5V pin on the Arduino.
- Connect IC LM35 temperature sensor Vout to the A0 pin on the Arduino.
- Connect the GND pin of the IC LM35 temperature sensor to the GND pin on the Arduino.
- Connect 5V Single Channel Relay signal pin to pin 2 on the Arduino.
- Connect 5V Single Channel Relay COM pin to 5V pin on the Arduino
- Connect 5V Single Channel Relay GND pin to GND pin on the Arduino
- Connect 220V AC FAN one wire to 220V AC, other wire to COM pin on the 5V Single Channel Relay.
- Connect NO pin of 5V Single Channel Relay to 220V AC.
Conclusion:
This project shows how Arduino may be used in a real-world setting for automated control.
A comfortable temperature may be maintained in a variety of settings by using the temperature-controlled fan system.
The temperature threshold and other functionality, including temperature logging and fan speed control, may be added to the code by modifying it.
Leave a Reply