Automatic Temperature Controller using Micro-Controller
Automatic Temperature Controller using Micro-Controller
The main objective of the project is to control the temperature of a certain environment
by making use of PID control using Arduino microcontroller. The goal is to ensure that the
temperature stays within a certain specified limit as required by the user. The basic working
principle of the project is- if the temperature rises, the temperature is to be lowered and if the
temperature decreases, the temperature is to be increased. So the temperature sensor reads the
temperature of the plant, sends the analog value to the arduino board which then compares it to
the set range. If the temperature is higher, the fan is turned on and if the temperature is lower, the
heater is turned on. The sensor can be programmed to measure temperature after a set time
interval as per the requirement.
Page 1
use basic programming structures, variables and functions. These are then converted into a C++
program.
Heater or Fan: These are the devices which are to be turned on or off as per the requirement.
When the temperature is low the circuit containing the heater is activated, and when the
temperature is high, the circuit containing the fan is activated.
Page 2
THEORETICAL BACKGROUND
Nowadays, the humankind is moving towards the new technologies by replacing the
manual operations to automatic controlled devices. One of the basic requirements of the people
during hot weather is a cooling fan. But, the speed of the fan can be controlled by manual
operation using a manual switch namely fan regulator or dimmer. By turning the dimmer, the fan
speed can be altered. It can be used in some places like where the temperature is high during the
morning though the temperature falls down radically at night time. The users do not understand
the difference in temperature. So to overcome the difficulty in controlling the speed of the fan
here, a solution is to vary the speed according to temperature. This concept is particularly
applicable for the areas like where temperature changes radically during day and night time. This
project will convert the manual fan into automatic fans. The automatic fans will change its speed
according to the temperature in the room. This article discusses about temperature controlled fan
block diagram, working of each block and properties.
The proposed system temperature controlled fan using microcontroller is used to control
the speed of the fan according to the temperature and specify the temperature in the display. The
required components are: Microcontroller (AT89C51), Temperature sensor (LM35), motor,
motor driver (L293D), Seven Segment Display, ADC (ADC0808), Power supply, and
Operational amplifier.
Page 3
The various components used in the project are as follows:
LM35 is a very low cost and easily available sensor. The main advantage of LM35 is
that it is linear i.e. 10mv/°C which means for every degree rise in temperature the output
of LM35 will rise by 10mv. So if the output of LM35 is 220mv/0.22V the temperature
Page 4
will be 22°C. So if room temperature is 32°C then the output of LM35 will be 320mv i.e.
0.32V.
LM35 can also be directly connected to Arduino. The output of LM35 temperature can
also be given to comparator circuit and can be used for over temperature indication or by
using a simple relay can be used as a temperature controller.
In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these
ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports.
Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s
are written to these port pins, they are pulled high by the internal pull-ups and can be used
as inputs. These ports are also bit addressable and so their bits can also be accessed
individually.
Page 5
Port P0 and P2 are also used to provide low byte and high byte addresses,
respectively, when connected to an external memory. Port 3 has multiplexed pins for
special functions like serial communication, hardware interrupts, timer inputs and
read/write operation from external memory. AT89C51 has an inbuilt UART for serial
communication. It can be programmed to operate at different baud rates. Including
two timers & hardware interrupts, it has a total of six interrupts.
Page 6
Pin Description:
Pin Function Name
No
1 8 bit input/output port (P1) pins P1.0
2 P1.1
3 P1.2
4 P1.3
5 P1.4
6 P1.5
7 P1.6
8 P1.7
9 Reset pin; Active high Reset
10 Input (receiver) for serial RxD 8 bit P3.0
communication input/output
11 Output (transmitter) for serial TxD port (P3) pins P3.1
communication
12 External interrupt 1 Int0 P3.2
13 External interrupt 2 Int1 P3.3
14 Timer1 external input T0 P3.4
15 Timer2 external input T1 P3.5
16 Write to external data memory Write P3.6
17 Read from external data memory Read P3.7
18 Quartz crystal oscillator (up to 24 MHz) Crystal 2
19 Crystal 1
20 Ground (0V) Ground
21 8 bit input/output port (P2) pins P2.0/ A8
22 / P2.1/ A9
23 High-order address bits when interfacing with external memory P2.2/ A10
24 P2.3/ A11
25 P2.4/ A12
26 P2.5/ A13
27 P2.6/ A14
28 P2.7/ A15
29 Program store enable; Read from external program memory PSEN
30 Address Latch Enable ALE
Program pulse input during Flash programming Prog
31 External Access Enable; Vcc for internal program executions EA
Programming enable voltage; 12V (during Flash programming) Vpp
32 8 bit input/output port (P0) pins P0.7/ AD7
33 P0.6/ AD6
34 Low-order address bits when interfacing with external memory P0.5/ AD5
35 P0.4/ AD4
36 P0.3/ AD3
37 P0.2/ AD2
38 P0.1/ AD1
39 P0.0/ AD0
40 Supply voltage; 5V (up to 6.6V) Vcc
Page 7
Analog-to-Digital Converter (ADC0808)
ADC0808 is a converter which has 8 analog inputs and 8 digital outputs.
ADC0808 allows us to monitor up to 8 different transducers using only a single chip.
This eliminates the need for external zero and full scale adjustments.
ADC0808 is a monolithic CMOS device, offers high speed, high accuracy, minimal
temperature dependence, excellent long-term accuracy and repeatability and consumes
minimal power. These features make this device ideally suited to applications from
process and machine control to consumer and automotive applications. The pin diagram
of ADC0808 is shown in figure below:
Features:
Page 8
Generally, the ADC0808 input which is to be changed over to digital form can be
selected by using three address lines A, B, C which are pins 23, 24 and 25. The step size
is chosen dependent upon set reference value. Step size is the change in analog input to
cause a unit change in the output of ADC. ADC0808 needs an external clock to operate
unlike ADC0804 which has an internal clock.
Application of ADC0808:
The ADC0808 has got many applications; here we have given some application on
ADC:
From the below circuit the clock, start and EOC pins are connected to
microcontroller. Generally, we have 8 inputs; here we are using only 4 inputs for the
operation.
LM35 temperature sensor is using which is connected to fist 4 inputs of the analog to
digital convertor IC. The sensor has got 3 pins i.e., VCC, GND and output pins,
when the sensor heated the voltage at output increases.
The address lines A, B, C are connected to microcontroller for the commands. In this
the interrupt follows the low to high operation.
When the start pin is held high no conversion begins, but when the start pin is low
the conversion will start within 8 clock periods.
The point when the conversion is completed the EOC pin goes low to indicate the
finish of conversion and data ready to be picked up.
The output enable (OE) is then raised high. This enables the TRI-STATE outputs,
allowing the data to be read.
A 7-segment display is a one kind of electronic display used for displaying the
decimal numerals. The applications of these displays mainly include electronic meters,
digital clocks, and various electronic devices for displaying the information in the
form of numerical. But these displays uses hex code for displaying alphanumeric code.
Figure 1 shows a seven segment LED display. As indicated by the diode equivalent
circuit on the left, each segment is an individual LED. This is a Common Cathode
(CC) display. All of the cathodes (or negative terminals) of the segment LEDs are
connected together.
Page 9
To turn on a segment, you set its associated pin to HIGH (figure 2).
In a Common Anode (CA) seven segment display (figure 3) the anodes (positive
terminals) of all of the segments are connected together.
To turn on a segment, you set its associated pin to LOW. The resistors in the above
figures limit the current through each segment to no more than the specified maximum
forward current (If).
Ground Pins - 4
Input Pins - 4
Output Pins - 4
Enable pins - 2
Voltage Pins – 2
Motor Driver ICs are primarily used in autonomous robotics only. Also most
microprocessors operate at low voltages and require a small amount of current to
operate while the motors require a relatively higher voltages and current . Thus current
cannot be supplied to the motors from the microprocessor. This is the primary need for
the motor driver IC.
The L293D IC receives signals from the microprocessor and transmits the relative
signal to the motors. It has two voltage pins, one of which is used to draw current for
the working of the L293D and the other is used to apply voltage to the motors. The
L293D switches it output signal according to the input received from the
microprocessor. For Example: If the microprocessor sends a 1(digital high) to the
Input Pin of L293D, then the L293D transmits a 1(digital high) to the motor from its
Output Pin. An important thing to note is that the L293D simply transmits the signal it
receives. It does not change the signal in any case.
The L293D is a 16 pin IC, with eight pins, on each side, dedicated to the
controlling of a motor. There are 2 INPUT pins, 2 OUTPUT pins and 1 ENABLE pin
for each motor. L293D consist of two H-bridge. H-bridge is the simplest circuit for
controlling a low current rated motor.
Page 11
In the above diagram we can see that,
Working Mechanism
Now depending upon the values of the Input and Enable the motors will rotate in
either clockwise or anticlockwise direction with full speed (when Enable is HIGH) or
with less speed (when Enable is provided with PWM).
Let us assume for Left Motor when Enable is HIGH and Input 1 and Input 2 are HIGH
and LOW respectively then the motor will move in clockwise direction.
Page 12
So the behaviour of the motor depending on the input conditions will be as follows :
INPUT 1 INPUT 2 ENABLE 1,2 Result
0 0 1 Stop
0 1 1 Anti-clockwise rotation
1 0 1 Clockwise rotation
1 1 1 Stop
0 1 50% duty cycle Anti-clockwise rotation with half speed
1 0 50% duty cycle Clockwise rotation with half speed
Page 13
TECHNOLOGICAL DETAILS
All the modules used in the given block diagram are integrated. The fan speed can be
monitored by the variation of temperature. Basic concept of this project is to getting the
temperature, displaying the temperature and temperature change is reflected as vary in fan’s
speed. Here temperature sensor used in the project is LM35 and the o/p of this sensor is given to
analog to digital converter. The complete working is allowed or not can be decided by external
interrupts.
Temperature sensor LM35 is interfaced with the 8051 microcontroller’s analog pin
because, temperature sensor changes temperature into voltage. Here temperature sensor should
be interfaced correctly to the microcontroller in order to get correct reading. The speed of the fan
can be decided by the temperature examine by the microcontroller.
Microcontroller controls the DC fan using the IC L293D motor control. This IC L293D is
a dual H-bridge motor driver used to control the speed and direction of DC motor. It also offers
isolation between microcontroller and motor. Motor speed can be controlled by using the pulse
width modulation (PWM) technique.
Page 14
The proposed system is also provided with auto or manual switch which gives the option
to user to control the speed of fan. When the button is pressed, the speed can controlled by
manually that means user can control the fan speed manually. An LED can also be connected at
RC1 to demonstrate the status of auto or manual switch. If light emitting diode is blinking, it
means the fan control is manual.
So finally we can conclude that, when the power supply is given to the entire circuit then
the microcontroller reads the surrounding temperature of fan. The analog value of the
temperature is given by the sensor and applied to the ADC pin of microcontroller. The value of
analog is changed to the digital by the microcontroller internally. If the temperature is superior to
the threshold value, then microcontroller sends a signal to the controller to turn ON the motor.
Thus fan starts rotating.
When the temperature surpasses 35 ᵒ C then fan should run at max speed.
When the temperature drops below 15 ᵒ C then fan should be at min speed.
The fan speed should be change according to the ranges of temperature from 15 ᵒ C to 35 ᵒC,
Auto-manual switch should be built-in which would give user the freedom to control the speed
of fan on manual or auto.
The applications of the temperature controlled fan includes where the consumption of
power has to be controlled such as firms, institutes, organizations, home appliance, in computers
to cool the processor. Furthermore this project can be enhanced by interfacing it with air
conditioners.
Page 15
APPLICATIONS
Temperature Controlled DC Fan can be used to control the temperature of devices, rooms,
electronic components etc. by monitoring the temperature.
Can be extended to PWM based output, where the speed of the fan can be varied according
to the duty cycle of the PWM signal.
The circuit can be used in CPU to reduce the heat.
There can also be applications in the field of home automation, wherein a room can be
remotely controlled and its temperature monitored.
The chemical industries, food storage houses and the medicine storage facilities can also
put this technology to use to maintain the temperature of the rooms where critical products
are stored.
Page 16
ADVANTAGES &
DISADVANTAGES
Advantages
This technology will enable any person to maintain the temperature of a particular place
automatically without any manual changes.
It is very cost efficient and easy to implement as the components are easily available in
any electronics store.
We can also program the chip to maintain a certain temperature at all times, so it can be
used in fairly any condition.
Upon total completion of the project, we will also be able to control the temperature
remotely from our cell phones using an application.
Disadvantages
The temperature range of the temperature sensor currently being used is quite low, and
hence the technology cannot be used in an industrial environment.
The setup currently in use is quite fragile in context to current and voltage ratings.
Currently, the required temperature has to be preset and there is no option for the user to
change it later on.
There is no option of controlling the temperature remotely.
Page 17
FUTURE SCOPES
We plan to implement other peripherals as well such as a smoke detector and alarm kit
with connection to the sprinkler system.
Also we plan to implement a Bluetooth or a Wi-Fi module in the project and develop an
android application to control the whole system, so as to make the project more user-
friendly and controllable.
We also plan on implementation of an industrial grade temperature sensor so as to
increase the temperature sensing range.
Further we will replace the AT89C51 microcontroller with the Arduino Uno
microcontroller board which will increase the efficiency of the project and also enable us
to implement the bluetooth module
Page 18
CONCLUSION
This circuit is very simple and easy to build. This paper elaborates the design and
construction of fan speed control system to control the room temperature. The temperature
sensor was carefully chosen to gauge the room temperature. Moreover, the fan speed will
increase automatically if the temperature room is increased. As conclusion, the system which
was designed in this work will perform very well, for any temperature change and can be
classified as automatic control.
But there are numerous further changes to be made to whole circuitry to make the project
more efficient and user friendly. We furthermore plan to implement several more components in
the project to make it more autonomous and having many more options.
Page 19
REFERENCES
Vaibhav Bhatia and Pawan Whig, “A Secured Dual Tone Multifrequency Based Smart
Elevator Control System," International Journal of Research in Engineering and Advanced
Technology, Volume 1, Issue 4, Aug-Sept,2013.
F. Luo, X. Zhao, and Y. Xu, "A new hybrid elevator group control system scheduling
strategy based on particle swarm simulated annealing optimization algorithm", Intelligent
Control and Automation (WCICA), 2010, pp.5121-5124.
IEEE Vehicle Power and Propulsion, Sept. 3-5 Harbin, China, 2008, pp. 1-6. I.
Panagopoulos, C. Pavlatos and G. Papakonstantinou, "An Embedded Microprocessor for
Intelligent Control," Journal of Intelligent and Robotic Systems. Springer Netherlands, vol.
42, 2005, pp. 179-211.
Page 20