top of page
Writer's pictureSanskruti Ashtikar

Temperature Controlled Fan Using 8051 Microcontroller

Introduction


In this article, we will explore the design and implementation of a temperature-controlled fan using the 8051 microcontroller. This project is particularly useful in applications where temperature regulation is critical, such as in electronic devices, industrial equipment, or home appliances. The system will automatically adjust the fan speed based on the surrounding temperature, ensuring optimal cooling efficiency and energy conservation.


Components Required


  • 8051 Microcontroller (e.g., AT89S52)

  • LM35 Temperature Sensor

  • 16x2 LCD Display

  • DC Fan

  • Motor Driver (L293D)

  • Resistors

  • Capacitors

  • Crystal Oscillator (11.0592 MHz)

  • Voltage Regulator (7805)

  • Breadboard and connecting wires

  • Power supply


Circuit Diagram


(Note: Insert a clear and labeled circuit diagram here.)


Working Principle


The LM35 temperature sensor senses the ambient temperature and converts it to an analog voltage. The 8051 microcontroller reads this analog voltage, converts it to a digital value using its internal ADC (Analog-to-Digital Converter), and then displays the temperature on the LCD. Based on the temperature reading, the microcontroller adjusts the speed of the fan by controlling the motor driver.


Detailed Circuit Explanation


  1. Power Supply:

  2. The 7805 voltage regulator is used to provide a stable 5V power supply to the 8051 microcontroller and other components.

  3. Temperature Sensor (LM35):

  4. The LM35 sensor outputs an analog voltage proportional to the temperature. This voltage is fed into one of the ADC channels of the 8051 microcontroller.

  5. Microcontroller (8051):

  6. The microcontroller reads the analog voltage from the LM35 sensor, converts it to a digital value, and processes it to determine the temperature.

  7. The microcontroller then adjusts the PWM (Pulse Width Modulation) signal sent to the motor driver to control the fan speed.

  8. Motor Driver (L293D):

  9. The L293D motor driver is used to drive the DC fan. The motor driver receives PWM signals from the microcontroller and adjusts the fan speed accordingly.

  10. LCD Display:

  11. The 16x2 LCD is used to display the current temperature. It is connected to the microcontroller in 4-bit mode to save I/O pins.


Software Implementation


The software for this project involves reading the temperature from the LM35 sensor, converting the analog signal to a digital value, displaying the temperature on the LCD, and controlling the fan speed based on the temperature.


#include <reg51.h>
#include <lcd.h>
#include <adc.h>
// Define pins
sbit FAN = P2^0;
// Function prototypes
void init();
void displayTemperature(unsigned int temp);
void controlFanSpeed(unsigned int temp);
void main() {
    unsigned int temperature;
    
    init();
    lcd_init();
    adc_init();
    
    while (1) {
        temperature = adc_read(0);  // Read temperature from ADC channel 0
        displayTemperature(temperature);
        controlFanSpeed(temperature);
        delay(500);  // Update every 500ms
    }
}
void init() {
    FAN = 0;
}
void displayTemperature(unsigned int temp) {
    unsigned char tempStr[16];
    float temperature = (temp * 5.0 / 1023.0) * 100;  // Convert ADC value to temperature
    sprintf(tempStr, "Temp: %.2f C", temperature);
    lcd_clear();
    lcd_print(tempStr);
}
void controlFanSpeed(unsigned int temp) {
    if (temp < 200) {
        FAN = 0;  // Turn off fan
    } else if (temp < 400) {
        FAN = 1;  // Low speed
    } else if (temp < 600) {
        FAN = 2;  // Medium speed
    } else {
        FAN = 3;  // High speed
    }
}

Explanation of the Code


  1. Initialization:

  2. The init function initializes the microcontroller by setting up the necessary ports.

  3. The lcd_init and adc_init functions initialize the LCD and ADC, respectively.

  4. Main Loop:

  5. The main loop continuously reads the temperature from the ADC channel, displays it on the LCD, and adjusts the fan speed based on the temperature.

  6. Temperature Display:

  7. The displayTemperature function converts the ADC value to a temperature and displays it on the LCD.

  8. Fan Speed Control:

  9. The controlFanSpeed function adjusts the fan speed based on the temperature. This is done using simple conditional statements to determine the speed level.


Conclusion


This project demonstrates the use of an 8051 microcontroller to build a temperature-controlled fan system. The system can be further enhanced by incorporating more advanced features such as variable fan speed control using PWM, more accurate temperature sensors, or even remote monitoring capabilities. By understanding the basic principles and implementation details, you can easily customize and expand this project to suit your specific needs.


Want us to guide you through your project or make the project for you?






Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 


0 views0 comments

Related Posts

See All

Comments


bottom of page