Temperature controlled fan speed using LM35


Does anyone have a simple sketch and schematic for the above, or at least point me in the right direction.

It is to control the internal cabinet temperature, of my CNC control cabinet, by varying the speed of the dc fan, ie, the fan goes faster the hotter the internal temp gets, having a set-point for coming ON and OFF. I would also like to programme a ATtiny 85 to save the Arduino for something else.

Having an LCD temp indicator would also be nice, but not necessary, but good as a project.

I found a schematic on the internet once but i did not bookmark it, now i cannot remember were it is.



I have a sketch but it is quite large (222 lines of code), I use a 7-seg display + bargraph to indicate temperature and speed.

Here is an idé what you have to do:

  1. First you should make a function that reads the temperature. You will find a lot of examples.
    e.g. Arduino Playground - LM35HigherResolution

  2. Then you can use the Arduino PID-library to get a output value of 0-255. The temperatur from the function is the input.
    Use the output value to control a PWM signal with analogWrite.
    Arduino Playground - HomePage

3.Adjust the PWM Frequency to >20Khz.

  1. Use a Mosfet (or DC-DC SSR) to control your fan.


Many thanks olaf, but a bit to far advanced for me, this is my first ever project, i can read schematics and make ocbs etc, but arduino language is very alien at the moment, i just really want a schematic and a list of parts, i will worry about the sketch later.



Well the LM35's easy: it has a signal wire which you use on an analog pin. The LM35's other 2 wires are just power.

Then for the fan, you'll need a transistor to switch it, and a resistor on the base. The motor itself will need a diode in parallel. This tutorial shows a typical setup to drive a motor. The characteristics of the transistor will depend on the fan.

Use a PWM pin to drive the transistor base, then you can vary the speed of the fan. You could even try without PID- some simple rules might work, eg if deltaT (the diff between set point and actual) is more than 20, go fast, if it's between 10-20 go medium and if it's less than 10, go slow. Bit of trial and error but will be easy to code and reduces complexity for your early project.