arduino nano pin configuration

Automatic Temperature-Controlled Fan Using Arduino

INTRODUCTION :

In the day and age we now live in with technology all around, automation like arduino nano pin configuration is a key factor to adding comfort and convenience into our everyday lives. Imagine if you didn’t have to take the time to manually adjust your electric fan every time your room temperature changes. This is especially useful when daytime temperatures are very warm, and nights can be very cool. Using a few electronic components you can automate a regular fan to turn on and off depending on the temperature in the room. In this project, you will turn a regular fan into a temperature controlled fan with the help of Arduino Uno, an LM35 temperature sensor and a relay.

We’ve discussed various projects such as a basic automatic fan, an IoT based speed controller, and smartphones controlled fans for fans enthusiasts who want to explore different kinds of applications. These are great stepping stones to understand temperature based controls.

Overview: A Disk Fan is something all of us can build to help stay cool.

To do this project, we will interface the LM35 sensor with an Arduino Uno to measure the ambient temperature, and through relay to control the fan. Next, we’ll upload a conditional code to the Arduino to be able to automate fan operation based on the temperature read.

Components Required

  • Arduino Uno or Arduino Nano
  • USB Cable for programming
  • LM35 Temperature Sensor
  • 5V Single-Channel Relay
  • Jumper Wires
  • Breadboard

Now we need to be able to turn anything on or off, e.g. AC Fan (or another device to be controlled).

Arduino Nano: Compact and Efficient

The Arduino Uno is often used, but its compact size and functional versatility make the Arduino Nano a good alternative. The Arduino Nano has a total of 30pins of which we can use several for input and output. The Nano includes:

Analog Input Pins (A0 to A7) which you can use for appropriate sensors (like the LM35).

For interfacing devices like relays we have digital I/O pins (D0–D13).

External components can be supplied using Power Pins like 5V, 3.3V, GND and Vin.

For I2C Communication, i.e connecting various peripherals, key pins like A4 (SDA) and A5 (SCL) are there.

This is LM35 Temperature Sensor Overview.

The LM35 sensor is just a low cost, highly accurate analog temperature sensor. It is a simple way to measure temperature, producing an output voltage in direct linear proportion to degrees Celsius of temperature. The sensor has three pins:

VCC: Powered by a power supply from 4V to 32V.

GND: The ground pin.

OUT: Analog output proportional to the temperature.

For every 1°C increase in temperature, the output voltage increases by 10mV, which then can easily be read by the analog pins of the Arduino.

Relay Module Overview

The 5V single channel relay is an important component that allows the high power AC loads (fan, motors) to be controlled using a low power control signal from the Arduino. Here’s an overview of the relay’s connections:

VCC: Power supply for the module.

GND: Common ground.

IN: The Arduino’s control signal, (in this case attached to a digital output pin).

COM: For the relay, common connection.

NC (Normally Closed): Having inactive relay, it maintains the closed circuit with COM.

NO (Normally Open): Relay activated establishes a connection with COM.

Circuit Diagram

For this project circuit for this project, we are going to connect an Arduino Nano, the LM35 sensor and the relay module. The connections are straightforward:

LM35 sensor:

VCC to 5V pin on Arduino,

GND to GND pin,

OUT to A0 pin.

Relay:

VCC to 5V pin,

GND to GND pin,

IN to D2 on the Arduino.

Configuration of Arduino Nano Pins.

Despite a compact pin configuration, the Nano has all the necessary connections. Digital pins (D0 – D13), for controlling things such as relays, and analog pins (A0 – A7), for reading values from sensors. 5V, 3.3V, GND and other key power pins on the Nano power connected components smoothly.

How the System Works

Ambient temperature is measured using an LM35 sensor in the project. The sensor then reads the analog output from the sensor and sends the number to Arduino’s analog pin (A0) which then turns the output to a temperature reading in degrees Celsius. This reading is compared by Arduino against a predefined threshold, for example 40°C.

When the temperature surpasses 40°C, the Arduino activates a signal to the relay which then powers the fan. The Arduino turns off the relay, and thus the fan, if the temperature falls lower than 40°C in order to avoid wasting of energy.

Code Explanation

Here’s a detailed breakdown of the code used in the project:

const int lm35_pin = A0;   // Analog pin for LM35 output const int relay_pin = 2;   // Digital pin for relay control void setup() {   Serial.begin(9600);        // Start serial communication   pinMode(relay_pin, OUTPUT); // Set relay pin as an output   digitalWrite(relay_pin, LOW); // Ensure relay is initially off } void loop() {   int temp_adc_val;   float temp_val;   // Read the LM35 sensor value   temp_adc_val = analogRead(lm35_pin);     temp_val = (temp_adc_val * 4.88); // Convert ADC value to voltage   temp_val = (temp_val / 10);       // Calculate temperature in Celsius   // Print temperature value to the Serial Monitor   Serial.print(“Temperature = “);   Serial.print(temp_val);   Serial.println(” °C”);   // Control fan based on temperature   if (temp_val >= 40) {     Serial.println(“Fan on”);     digitalWrite(relay_pin, HIGH);   } else {     Serial.println(“Fan off”);     digitalWrite(relay_pin, LOW);   }   delay(1000);  // Delay before next reading }

The code does constant temperature measurement and controls the fan accordingly for a certain temperature threshold.

Demonstration and Conclusion

When LM35 temperature increases more than 40°C, then the relay turns on the fan for cooling. At that point, the fan stops turning. In addition to automating a basic fan, this project provides energy efficient fan operation by minimizing the time that the fan operates unnecessarily.

Adding Arduino Nano to your projects gives you a low footprint yet a powerful board. Arduino Nano pin configuration helps effortlessly sensing devices, displays and relays for varied different purposes.

We also hope this project motivates you to learn some more automation projects using Arduino!

        
//Temperature Controlled Fan using Arduino and Lm35 Code 
//by ElectroGlobal const int lm35_pin = A0; 
// LM35 output pin const int relay_pin = 2; 
// Relay control pin (change to the appropriate pin)
void setup() { Serial.begin(9600);
pinMode(relay_pin, OUTPUT); 
// Set the relay pin as an output 
digitalWrite(relay_pin, LOW); 
// Turn off the relay (fan) } 
void loop() 
{ int temp_adc_val;
float temp_val;
temp_adc_val = analogRead(lm35_pin); 
// Read temperature
temp_val = (temp_adc_val * 4.88); 
// Convert ADC value to equivalent voltage temp_val = (temp_val / 10); 
// LM35 gives an output of 10mV/°C
Serial.print("Temperature = "); Serial.print(temp_val);
Serial.println(" Degree Celsius"); 
if (temp_val < 40) { Serial.println("Fan off"); digitalWrite(relay_pin, LOW); 
// Turn off the relay (fan) } 
else { Serial.println("Fan on"); digitalWrite(relay_pin, HIGH); 
// Turn on the relay (fan) } }
        
    
7 Powerful Reasons to Choose Ni Metal Hydride Batteries Over Others

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp
My Cart
Wishlist
Recently Viewed
Categories
Wait! before you leave…
Get 30% off for your first order
CODE30OFFCopy to clipboard
Use above code to get 30% off for your first order when checkout