» Electronics » Arduino »Thermostat for fan

Thermostat for fan



The fans used to cool the electronics come in two forms. Some are miniature, they are sent directly to the cooled components, others are larger, they drive air through the entire space of the housing. It is best when both types of fans are used together. Often, fans of the second type are constantly "threshing" at full power, even if this is not necessary. From this, the bearing wears out faster, and too much noise interferes with the user. The simplest contact thermostat can turn the fan on and off, while the bearing resource is consumed only when the engine is running, but sharply appearing and disappearing noise can be even more annoying. A more sophisticated thermostat - for example, proposed by the author Instructables under the nickname AntoBesline - controls the frequency of rotation of the fan motor with a PWM and maintains it necessary and sufficient to achieve the set temperature. It is advisable to drive air through the housing space from the bottom up, and place the temperature sensor from above. You can also install filters to prevent dust from entering the enclosure, but they will reduce performance.

A temperature and humidity sensor of the DHT11 type is suitable just for the thermostat controlling a second type fan, since it measures the temperature of air, and not of any surface. Its support is provided by two libraries laid out here and here. If you need to equip a fan of the first type with a thermostat, you will have to use another sensor that measures the surface temperature of the component to be cooled. The program then will have to be redone, and the libraries will need others, because the sensor may differ in both the interface and the structure of the data transmitted to it.

Using the following illustration, the wizard shows what PWM is, most readers know this already. Due to the fact that the output transistor is always either completely closed or completely open, very low power is always allocated on it. As you know, power is equal to the product of current and voltage, and here, with the transistor closed, the current is very small, and with the open transistor, the voltage drop across it is small. One of the two factors is always small, which means that their product is also small. Almost all the power in the PWM controller goes to the load, not to the transistor.

Thermostat for fan


The master draws up a thermostat diagram:



Arduino it is powered by a 5-volt source, the fan - from a 12-volt.If you use a 5-volt fan, you can do with one source with sufficient load capacity, feeding Arduino through a simple LC filter. A diode connected in parallel with the fan in the opposite direction is needed if the engine is a collector motor (as in some modern USB fans). When using a computer fan with a Hall sensor and electronic winding control, this diode is optional.

The text of the program compiled by the wizard is quite short, it is given below:

#include "DHT.h"
#define dht_apin A1
#include

Liquid Crystal lcd (7,6,5,4,3,2);
DHT dht (dht_apin, DHT11);
int fan = 11;
int led = 8;
int temp;
int tempMin = 30;
int tempMax = 60;
int fanSpeed;
int fanLCD;
void setup ()
{
   pinMode (fan, OUTPUT);
   pinMode (led, OUTPUT);
   lcd.begin (16, 2);
   dht.begin ();
   lcd.print ("Room Temp Based");
   lcd.setCursor (0, 1);
   lcd.print ("Fan speed Ctrl");
   delay (3000);
   lcd.clear ();
}
void loop ()
{
    float temperat;
    temperature = dht.readTemperature ();
    temp = temperat; // store the temperature value in temp variable
   Serial.print (temp);
   if (temp  = tempMin) && (temp <= tempMax)) // if temperature is higher than minimum temp
   {
       fanSpeed ​​= temp; // map (temp, tempMin, tempMax, 0, 100); // the actual speed of fan // map (temp, tempMin, tempMax, 32, 255);
       fanSpeed ​​= 1.5 * fanSpeed;
       fanLCD = map (temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100
       analogWrite (fan, fanSpeed); // spin the fan at the fanSpeed ​​speed
   }
      if (temp> tempMax) // if temp is higher than tempMax
     {
     digitalWrite (led, HIGH); // turn on led
     }
   else // else turn of led
     {
     digitalWrite (led, LOW);
     }
      lcd.print ("TEMP:");
   lcd.print (temp); // display the temperature
   lcd.print ("C");
   lcd.setCursor (0,1); // move cursor to next line
   lcd.print ("FANS:");
   lcd.print (fanLCD); // display the fan speed
   lcd.print ("%");
   delay (200);
   lcd.clear ();
 }


Also, a sketch can be downloaded as a file here. The unknown extension will have to be changed to ino.

The following photos show the assembly of the prototype device on a breadboard type board:









Having assembled a prototype, the master tests it. The temperature is displayed in degrees Celsius, the actual voltage value on the fan - as a percentage of the maximum.







It remains to assemble the circuit by soldering and make the thermostat part of that homemadewhich he will cool.
8
8
6

Add a comment

    • smilesmilesxaxaokdontknowyahoonea
      bossscratchfoolyesyes-yesaggressivesecret
      sorrydancedance2dance3pardonhelpdrinks
      stopfriendsgoodgoodgoodwhistleswoontongue
      smokeclappingcraydeclarederisivedon-t_mentiondownload
      heatirefullaugh1mdameetingmoskingnegative
      not_ipopcornpunishreadscarescaressearch
      tauntthank_youthisto_clueumnikacuteagree
      badbeeeblack_eyeblum3blushboastboredom
      censoredpleasantrysecret2threatenvictoryyusun_bespectacled
      shokrespektlolprevedwelcomekrutoyya_za
      ya_dobryihelperne_huliganne_othodifludbanclose
10 comments
Author
Well, at the lower end of the range, hysteresis can be implemented. Having slightly modified the program. And in the rest of the range, where the fan still rotates, only the speed changes, it is possible without hysteresis.
Quote: tormozedison
Hysteresis is needed with a sharp on-off load. With a smooth adjustment of the PWM, as here, it is useless.

I do not agree, hysteresis is needed precisely on the on / off logic. For example, a fan, even at the lowest speed, turns on at> 30 degrees, and turns off at <30. But if you imagine that the temperature is around 30 degrees, the fan turns on at low speeds, after which the temperature immediately drops to 29, the fan stops. In short, it turns out "jerking off" on / off fan. Just hysteresis saves from this, for example, turn on when the temperature is> 30, and turn off when <25. If this is not done, then there is no point in Arduino at all, since there are KY-028 and analogs that allow you to use a smooth increase in speed, and just turn on / off, and only the absence of hysteresis does not make these modules ideal.
Author
Hysteresis is needed with a sharp on-off load. With a smooth adjustment of the PWM, as here, it is useless.

I know about KU208 from the late eighties. I learned about KY-028 from you, thanks for the tip.

It is not necessary to connect a display to this thermostat. Instead of UNO, take a cheap clone with the same features. And it will be economically justified.
2Dem do not insult those (and you know that I am PROFI, in electronics, you just do not want to admit it).
I decided to reset all dislikes on your kamens to my homemade products. Today is my lucky day and holiday.
I'm starting to zero out your dislikes ... And can you withdraw your insults?
Quote: Ivan_Pokhmelev
Quote: R555
The moron doesn't even spell the name KU208 correctly.
But he correctly spells the name of the temperature sensor KY-028. What does the KU208 have to do with it?

Firstly, thanks for quoting the message, I was very funny to see that the "know-it-all" does not know such basic things. Secondly, I gave KY-028 as an example, it’s worth adding a power switch and we get a more efficient thermostat. And effective in every sense. If I’m not mistaken, there is also no hysteresis at the minimum temperature. Namely, this should be done first of all, otherwise there is no reason to use Arduino at all. Inefficient use of materials, roughly speaking, in Chinese Nano with 16k memory, ventilation control in the boiler room is based on temperature and humidity, leakage protection throughout the house (6 sensors), smart DHW circulation, flushing of the osmosis membrane, and the display of the whole this information is displayed 1602. And using Uno to start the fan is rational only if this is a lesson for beginners, but this “home-made” as no lesson at all, there are much better lessons. Then what is its meaning?
Why useless? Of course, this is not a product, but a layout, there are errors in the scheme, but the idea has a right to exist. And what screen are you talking about?
I would not be so categorical: the device, in addition to the regulation itself, also displays the temperature, which can be useful. But the name is wrong, it’s not a thermostat, but layout temperature-dependent fan speed control.
Quote: R555
The moron doesn't even spell the name KU208 correctly.
But he correctly spells the name of the temperature sensor KY-028. What does the KU208 have to do with it?
For example, for KY-028 did not hear? It's nonsense to use UNO for such a useless craft. The screen is not needed at all in such an implementation. All this garbage is like the first and most important unsuccessful work of a schoolboy, since everything that could be done wrong is exactly what was done.
Another microscope-nail-hammer! nea

We advise you to read:

Hand it for the smartphone ...