Fan and temperature controller with LCD
This module was part of the rack box project — which was terminated when I moved out of my first apartment.

Reads temperature and controls a fan using a PWM output, fan and alarm set point can be adjusted and is shown on a LCD. Uses an AVR ATmega8 microcontroller.
Details
The module uses an LM35 sensor for measuring the temperature, it is a pre-calibrated IC with output voltage linearly-proportional to the Centigrade temperature. This is read directly by the internal AVR ADC, and turned into actual degrees with a simple calculation. The fan is powered by an PWM output, giving it variable speed. Set points for the fan and alarm can be adjusted and is saved to EEPROM.
When the temperature reaches the setpoint; the fan will start on speed 1. After 30 seconds the speed is increased to level 2, unless the temperature has dropped below the setpoint. If the temperature rises above the setpoint speed is set to level 3, which is the maximum. The alarm is triggered if the temperature is equal to the alarm set point for more than 30 seconds. It is possible to override the fan with the override switch, or with an external signal. When overridden the fan speed is increased by 2, meaning if 0 then 2, or if 1 or 2 then 3.
Setpoints
Two values are stored in EEPROM; fan and alarm setpoint. These are non-volatile, meaning that they are not lost if the module is without power. Setpoints are saved to the EEPROM about five minutes after they have been changed, to avoid unnecessary writes. When values are changed but not yet saved, a E is displayed in the right corner if the LCD. The setpoints is adjusted using the (on)-off-(on) switches, one degree at the time.
Original purpose
The controller was originally built for the rack box project:
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.
I/O
Inputs
- PB3 Fan set temp +
- PB4 Fan set temp -
- PB6 Alarm set temp +
- PB7 Alarm set temp -
- PB5 Override fan switch
- PC0 Temperature (Analog)
Calculations
- Temperature
Outputs
- PD0 LCD1
- PD1 LCD2
- PD2 LCD3
- PD3 LCD4
- PD6 LCD5
- PD7 LCD6
- PB0 Lifesignal (to Module stability monitoring unit 2)
- PB1 Fan
- PB2 Temp alarm (to Signal and lights controlling unit)
D-Sub 9-pin
- 0V
- +5V
- Lifesignal
- Fan
- Temp alarm
- LCD background light switch
- Override fan switch
Front panel
Switches
- (on)-off-(on), fan temp +/-
- (on)-off-(on), alarm temp +/-
- on-off, override fan
- on-off, background light LCD display
LEDs
- Green, Lifesignal
- Green with lens, fan active
- Red with lens, temp alarm
LCD Display
Below are the different messages and statuses shown on the LCD display.
1234567890123456 25C F:30C A:30C* Fan & Temp Unit! SW v.2.0 JensenCorp.no System start =)
Source code

https://github.com/thomasjsn/AVR-Fan-and-temperature-controller