Thursday, 5 October 2017

Temperature Controlled DC Fan using Microcontroller

A Temperature Controlled DC Fan is a system which automatically turns on a DC Fan when the ambient temperature increases above a certain limit.
Generally, electronic devices produce more heat. So this heat should be reduced in order to protect the device. There are many ways to reduce this heat. One way is to switch on the fan spontaneously.
This article describes two such circuits that automatically, switches the fan when it detects the temperature inside the device greater than its threshold value. 

Circuit 1 Temperature Controlled DC Fan using 8051

Circuit Diagram


The project works on the principle of Analog to Digital Conversion. The Analog data from the LM35 temperature sensor is given to the analog to digital converter ADC0804.
The analog output of the temperature sensor will vary at 10mV per degree Celsius.
ADC0804 is an 8-bit ADC. For a reference voltage of 5V, we’ll get a resolution of 5V/28 = 20mV. Which means, this is the minimum change in the analog value from the sensor which is recognisable by the ADC IC.
As per the changes in the temperature, the output of the ADC is generated. The digital output of the ADC is given to Microcontroller to calculate the temperature and control the fan accordingly.


Microcontroller Section
  • AT89C51 Microcontroller
  • AT89C51 Programmer Board
  • 11.0592 MHz Quartz Crystal
  • 33pF Ceramic Capacitor
  • 2 x 10KΩ Resistor
  • 10µF Electrolytic Capacitor
  • Push Button
  • 16 X 2 LCD Display
  • 10KΩ POT
Temperature Sensor Section
  • LM35
  • ADC0804
  • 10KΩ Resistor
  • 150pF Ceramic Capacitor
  • 1KΩ x 8 Resistor Pack
Load Section
  • 2N2222 NPN Transistor
  • 1N4007 Diode
  • 12V Relay
  • 1KΩ Resistor
  • Fan

Configuring ADC0804 for this Project

The configuration of the ADC0804 is explained here. First, we need to connect the 5V regulated power supply to the Vcc pin (Pin 20). Then, connect the analog and digital ground pins (Pins 8 and 10) to the GND.
In order to use the internal clock, we need to connect a 10KΩ resistor between CLK IN (Pin 4 and CLK R (Pin 19) and then, connect a 150pF cap between pins 4 and GND to complete the oscillator circuit.
The CS pin (Pin 1) is connected to GND to enable the ADC.
In order to read the data from the ADC continuously by the microcontroller, we need to connect the RD pin (Pin 2) to the GND.
For the ADC to continuously read the analog data from the sensor, we need to short the Write pin (Pin 3) with the Interrupt pin (Pin 5).
The analog output of the sensor (LM35) is connected to the Vin+ (Pin 6) of the ADC. The negative analog input pin i.e. Vin- of the ADC is connected to the GND.
The converted digital data which is an 8-bit data will be available at DB0 to DB7 (Pins 18 to 11).

Circuit Design

The main components of the project are 8051 Microcontroller, 16×2 LCD Display, LM35 Temperature Sensor, ADC0804, Relay and Fan.
The basic connections with respect to microcontroller include clock, reset and EA. Clock consists of an 11.0592 MHz crystal and two 33pF capacitors. The reset circuit consists of a 10µF capacitor, 10KΩ resistor and a push button. The EA pin is pulled high with a 10KΩ resistor.
Now we’ll see the connections with respect to other components.
For the LCD display, a 10KΩ pot is connected to contrast adjust pin. The three control pins of the LCD are connected to the pins P3.6, GND and P3.7.
The 8 data pins of the LCD are connected to PORT1 of the microcontroller.
The basic connections with respect to ADC are explained in its configuration. The 8 digital outputs of the ADC must be connected to PORT 2 of the microcontroller.
The next component we are going to connect is LM35. Connect the data pin of the LM35 to the analog input pin i.e. Pin 6 of ADC.
Finally, we need to connect the Relay circuit consisting of resistor, transistor and relay to the PORT0 of the microcontroller with PORT 0 pulled-up externally.
Connect the input of relay i.e. base of the transistor to P0.0 pin of the microcontroller.


The aim of this project is to design a temperature controlled fan using 8051 microcontroller, in which the fan is automatically turned ON or OFF according to the temperature. The working of the project is explained here.
In this circuit, the LM35 temperature sensor will give continuous analog output corresponding to the temperature sensed by it. This analog signal is given to the ADC, which converts the analog values to digital values.
The digital output of the ADC is equivalent to sensed analog voltage.
In order to get the temperature from the sensed analog voltage, we need to perform some calculations in the programming for the microcontroller.
Once the calculations are done by the microcontroller according to the logic, the temperature is displayed on the LCD. Like this, the microcontroller will continuously monitor the temperature.
If the temperature exceeds more than 50 deg Celsius (as per the code), the microcontroller will turn on the relay to start the fan. If the temperature drops below 40 deg Celsius (as per the 

Water Level Indicator Mini Project

           The Water Level Indicator employs a simple mechanism to detect and indicate the water level in an overhead tank or any other water container.
The sensing is done by using a set of nine probes which are placed at nine different levels on the tank walls (with probe 9 to probe 1 placed in increasing order of height, common probe (i.e. a supply carrying probe) is placed at the base of the tank). The level 8 represents the “tank full” condition while level 0 represents the “tank empty” condition.
When the water-level is below the minimum detectable level (MDL), the seven segment display is arranged to show the digit 0, indicating that the tank is empty, when the water reaches level1 (but is below level2) the connection between the probes gets completed (through the conducting medium – water) and the base voltage of transistor increases.
This causes the base-emitter junction of transistor to get forward biased, this switches transistor from cut-off to conduction mode thus PIN (B7) of microcontroller is pulled to ground hence, the corresponding digit displayed by the seven segment display is 1.
The similar mechanism applies to the detection of all the other levels. When the tank is full, all input pins of microcontroller become low. This causes the display to show 8 and also in this case a buzzer sound is given, thereby indicating a “tank full” condition.
Most water level indicators are equipped to indicate and detect only a single level. The Water Level Indicator implemented here can indicate up to nine such levels and the microcontroller displays the level number on a seven segment display.
So, the circuit not only capable of cautioning a person that the water tank has been filled up to certain level, but also indicates that the water level has fallen below the minimum detectable level. This circuit is important in appliances such as the water cooler where there is a danger of motor-burnout when there is no water in the radiator used up also it can be used in fuel level indication.
In this project we show the water level indicator using eight transistors which conducts as level rises, a buzzer is also added which will automatically start as the water level becomes full, auto buzzer start with the help of microcontroller. With the help of this project we not only show the level of water on seven segment display but also indicate the water full condition using a buzzer.

Water Level Indicator Project Circuit Features:

  1. Easy installation.
  2. Low maintenance.
  3. Compact elegant design.
  4. The Automatic water level controller ensures no overflows or dry running of pump there by saves electricity and water.
  5. Avoid seepage of roofs and walls due to overflowing tanks.
  6. Fully automatic, saves man power.
  7. Consume very little energy, ideal for continuous operation.
  8. Automatic water level controller provides you the flexibility to decide for yourself the water levels for operations of pump set.
  9. Shows clear indication of water levels in the overhead tank.

Water Level Indicator Project Block Diagram

Water Level Indicator Circuit Diagram:

How to Design Water Level Indicator Project using AVR Microcontroller?

  • A constant 5v power supply is given to the microcontroller and rest of the circuit from a battery.
  • The tank has 9 conductive type sensors (other types of sensors have been mentioned earlier but in our project only conductive type are used) embedded into it and 8 wires of sensors out of 9 are connected to transistors and the 9th is connected to 5v+ supply.
  • The use of transistor is it acts as inverter (i.e. in on state gives low voltage at output and in non conducting state gives high voltage at its output), all transistors outputs are connected to PORTB of microcontroller.
  • Seven segment display is connected to PORTD. It is connected in common cathode fashion.
    The Output for the 7th level is not only shown on seven segment display but also indicated with a discontinuous buzzer sound.
  • Output for the 8th level (i.e. tank full condition) is not only shown in seven segment display but also indicated with a continuous buzzer sound.

How Water Level Indicator Project Circuit Works?

The operation of this project is very simple and can be understood easily. In our project “water level indicator” there are 3 main conditions:
  1. There is no water available in the source tank.
  2. Intermediate level i.e. either of 3rd to 7th level.
  3. There is ample amount of water available in the source tank.
So let us discuss more about these 3 conditions

CONDITION 1: Water not available

When the tank is empty there is no conductive path between any of the 8 indicating probes and the common probe (which is connected to 5v+ supply) so the transistor base emitter region will not have sufficient biasing voltage hence it remains in cut off region and the output across its collector will be Vc approximately 4.2v.
As in this case the microcontroller is used in the active low region (which means it considers 0-2 volts for HIGH and 3-5 volts for LOW) now the output of transistor which is 4.2v approximately will be considered as LOW by the microcontroller and hence the default value given by microcontroller to the seven segment display is 0 which indicates as the tank is empty.

CONDITION 2: Intermediate levels

Now as the water starts filling in the tank a conductive path is established between the sensing probes and the common probe and the corresponding transistors get sufficient biasing at their base, they starts conducting and now the outputs will be Vce (i.e. 1.2v-1.8v) approximately which is given to microcontroller.
Here the microcontroller is programmed as a priority encoder which detects the highest priority input and displays corresponding water level in the seven segment display.
In this project while the water level reaches the 7th level i.e. last but one level along with display in seven segment a discontinuous buzzer is activated which warns user that tank is going to be full soon.

CONDITION 3: Water full

When the tank becomes full, the top level probe gets the conductive path through water and the corresponding transistor gets into conduction whose output given to microcontroller with this input microcontroller not only displays the level in seven segment display but also activates the continuous buzzer by which user can understand that tank is full and can switch off the motor and save water.

Water Level Indicator Project Working Flow Chart:

Water Level Indicator Flow Chart
Flow chart gives the clear and easy understanding of the project. The process goes on as follows:
The microcontroller checks for tank full condition, if the condition is satisfied it indicates the same on display unit and also sounds a buzzer if the condition fails it checks again and this process continues and the corresponding level is indicated in the display unit.

Water Level Indicator Project Applications:

  • Automatic Water level Controller can be used in Hotels, Factories, Homes Apartments, Commercial Complexes, Drainage, etc., It can be fixed for single phase motor, Single Phase Submersibles, Three Phase motors. (For 3Æ and Single Phase Submersible Starter is necessary) and open well, Bore well and Sump. We can control two motor and two sumps and two overhead tanks by single unit.
  • Automatic water level controller will automatically START the pump set as soon as the water level falls below the predetermined level (usually 1/2 tank) and shall SWITCH OFF the pump set as soon as tank is full.
  • Fuel level indicator in vehicles.
  • Liquid level indicator in the huge containers in the companies.