Fan and temperature controller with LCD

From CaveLab
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

This module was part of the rack box project — which was terminated when I moved out of my first apartment.
FTU installed in the Rack box

FTU regulates the temperature in the Rack box. The module is equipped with a LM35 temperature sensor, installed in the top of the Rack box were it's warmest. A 80x80mm fan is also mounted at the top of the box. The air intake is at the bottom and sucks air from outside the entire closet. This gives good air circulation in the Rack box. The fan is controlled using PWM, giving the fan variable speed. It's divided into three levels: 1: 1/3, 2: 2/3, 3: full. The temperature sensor is a LM35.

When actual temperature is equal to the fan temperature the fan will start on level 1, if this persists for more then 30 seconds the fan will go to level 2. If actual temperature should rise above the fan temperature the fan is set to level 3, which is the maximum. If actual temperature is equal to the alarm temperature for more then 30 seconds the alarm will be triggered. The fan can be overridden with a manual switch, or from the external input (computer). When overridden the fan level is increased by 2 levels, meaning if 0 then 2, or if 1 or 2 then 3.

Two temperatures are stored in EEPROM, fan and alarm temperature. When stored in EEPROM the unit will remember these values even trough a power loss, the values are saved about five minutes after they are changed. In this period, when the values are changed but not stored, a "E" is displayed in the right corner if the LCD display. Fan and alarm temperature can be adjusted using the (on)-off-(on) switches, one degree at the time.



  • PB3 Fan set temp +
  • PB4 Fan set temp -
  • PB6 Alarm set temp +
  • PB7 Alarm set temp -
  • PB5 Override fan switch
  • PC0 Temperature (Analog)




D-Sub 9-pin

  1. 0V
  2. +5V
  3. Lifesignal
  4. Fan
  5. Temp alarm
  6. LCD background light switch
  7. Override fan switch

Switches and LEDs


  • (on)-off-(on), fan temp +/-
  • (on)-off-(on), alarm temp +/-
  • on-off, override fan
  • on-off, background light LCD display


  • Green, Lifesignal
  • Green with lens, fan active
  • Red with lens, temp alarm

LCD Display

25C F:30C A:30C*
Fan & Temp Unit!
SW v.2.0
System start =)

Source code

Bascom-AVR source is available in a git repository:


Schematic drawing


Parts used

Qty. Part
1 × AVR ATmega8-16PU, DIL-28, 16 MHz, 23 I/Os
1 × Capacitor, aluminium electrolytic, 10 µF, 25V
1 × Capacitor, ceramic, 1 nF, 100V
1 × D-sub soldering cups, 9 pin female
1 × DIL socket, 28-pin, 7.62mm
1 × Enclosure, plastic (1591 FL), 150x80x50mm, flange
1 × LCD display, dot matrix, 16x2, LED green
1 × LED 5mm clear, Green, 2.1V, 20mA, 385mcd, 6°
1 × LED 5mm clear, Red, 2.0V, 20mA, 140mcd, 6°
1 × LED 5mm coloured clear, Green, 2.1V, 20mA, 30mcd, 10°
1 × LED holder 5mm, RTC51, black plastic
1 × LED lens 5mm, CLF 280, Green
1 × LED lens 5mm, CLF 280, Red
32 cm2 PCB, stripboard, 100x160mm, 160cm2
8 × Resistor, carbon film, 0.25W, 330 Ω, 5%
4 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
5 × Resistor, carbon film, 0.25W, 10 kΩ, 5%
18 × Straight pin header, female, Single row, 2.54mm
18 × Straight pin header, male, Single row, 2.54mm
2 × Switch, toggle, 1-pole, micro, (on)-off-(on)
2 × Switch, toggle, 1-pole, micro, on-on
1 × Temperature sensor LM35DZ, 0 to +100 °C, +-0,6 °C
3 × Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
1 × Trimmer, carbon, 10 kΩ, horizontal