Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
abhishake_jamwal
Published © CERN-OHL

Temperature based fan speed control

Speed of fan is linearly controlled in temperature range between 30°C and 50°C using optocoupler and triac. Fan turn off below 30°C

IntermediateFull instructions provided775
Temperature based fan speed control

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
bta16(triac)
×1
mosfet(moc3020)
×1
LM35(TEMPERATURE SENSOR)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×1
4n25 mosfet
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PCB, For DMB-4775
PCB, For DMB-4775

Story

Read more

Schematics

CIRCUIT DIAGRAM

lm 35 sensor with arduino

circuit diagram for connecting arduino with triac

zero detection circuit

arduino with triac gate

Code

code

C/C++
#define triacPulse 10
#define SW 7
#define ZVC 2  //we can declare onlly pin 2 or 3 here because these both have interrupt read ability
int tempmax=50;
int tempmin=30;

int x = 0;
void setup()
{  Serial.begin(115200);
   pinMode(ZVC, INPUT_PULLUP);
   pinMode(A0, INPUT);
   pinMode(triacPulse, OUTPUT);
   pinMode(11,INPUT);
   pinMode(12,INPUT);
   pinMode(13,INPUT);
}
float temp()
  {  int val = analogRead(A0);
     float temp1 = ( val/1023.0)*500;
     return temp1;
   }
void pulse()
{ delayMicroseconds(x); // read AD0
  digitalWrite(triacPulse, HIGH);
  delayMicroseconds(50);  //delay 50 uSec on output pulse to turn on triac
  digitalWrite(triacPulse, LOW);
}
void pulse_for_min()
{ delayMicroseconds(7200); // read AD0
  digitalWrite(triacPulse, HIGH);
  delayMicroseconds(50);  //delay 50 uSec on output pulse to turn on triac
  digitalWrite(triacPulse, LOW);
}
void pulse_for_full()
{ delayMicroseconds(200); // read AD0
  digitalWrite(triacPulse, HIGH);
  delayMicroseconds(50);  //delay 50 uSec on output pulse to turn on triac
  digitalWrite(triacPulse, LOW);
}
void loop() {
  float temperature=temp(); 
  bool full_on = digitalRead(11);
  bool full_off = digitalRead(13);
  bool automatic = digitalRead(12);
    if(automatic==HIGH && full_on==LOW && full_off==LOW)
       {    if((temp >= tempmin) && (temp <= tempmax)) 
               {  // if temperature is higher than minimum temp & less than maximum temperature
                 int x = map(temp(), tempmin, tempmax,7200 ,200 );
                 Serial.println(digitalRead(ZVC));
                 attachInterrupt(0, pulse, FALLING); // attach Interrupt at PIN2
               }
           if(temp>=tempmax)
             pulse_for_full();
           if(temp<=tempmax)
              pulse_for_min();  
       }      
   if(automatic==LOW && full_on==HIGH && full_off==LOW)
        pulse_for_full();
   if(automatic==LOW && full_on==LOW && full_off==HIGH)
         pulse_for_min();

}

Credits

abhishake_jamwal

abhishake_jamwal

1 project • 0 followers

Comments