Introduction: ARDUINO - SOLID STATE RELAY FAN/ventilator Control Using the W1209 Thermistor and SSR-25 DA

Picture of ARDUINO - SOLID STATE RELAY FAN/ventilator Control Using the W1209 Thermistor and SSR-25 DA

Hello world! Today i made a Ventilator / FAN controller for growing tents or rooms, the controller works pretty simple when the temperature is for example below 25.90 the Ventilator/Relay will be OFF, as soon as it become above 25.90 the ventilator/Relay will turn ON. You can set any temperature in the code you like.

Do not use LED lamps to test if your using a lamp.

Led lamps can flicker or stay on when using a solid state relay.

You could have the problem that the light is on even when the relay suppose to be off then your probably using

led lights.

Find more info at this Video.

Check the next step for the schematic, code and parts list.

Step 1: Schematic, Code, Parts List.

Picture of Schematic, Code, Parts List.

Simply wire it up like the schematic and upload the code to the arduino.

Parts list.

  1. Arduino uno
  2. SSR-25 DA Solid state relay
  3. NTC Thermistor w1209
  4. Ventilator.
  5. MM/FF/FM Jumper set kit
  6. Solderless Breadboard

Good luck!

Subscribe to my youtube channel!

Check out our website for sensors!

Follow me for more!

Below you can see the code explained.

Step 2: The Code

// which analog pin to connect

#define THERMISTORPIN A0 // resistance at 25 degrees C #define THERMISTORNOMINAL 10000 // temp. for nominal resistance (almost always 25 C) #define TEMPERATURENOMINAL 25 // how many samples to take and average, more takes longer // but is more 'smooth' #define NUMSAMPLES 5 // The beta coefficient of the thermistor (usually 3000-4000) #define BCOEFFICIENT 3950 // the value of the 'other' resistor #define SERIESRESISTOR 10000

int samples[NUMSAMPLES];

void setup(void) { Serial.begin(9600); analogReference(EXTERNAL); pinMode(7, OUTPUT); delay(3000); }

void loop(void) { uint8_t i; float average; // take N samples in a row, with a slight delay for (i=0; i< NUMSAMPLES; i++) { samples[i] = analogRead(THERMISTORPIN); delay(10); } // average all the samples out average = 0; for (i=0; i< NUMSAMPLES; i++) { average += samples[i]; } average /= NUMSAMPLES; // Serial.print("Average analog reading "); // Serial.println(average); // convert the value to resistance average = 1023 / average - 1; average = SERIESRESISTOR / average; // Serial.print("Thermistor resistance "); // Serial.println(average); float steinhart; steinhart = average / THERMISTORNOMINAL; // (R/Ro) steinhart = log(steinhart); // ln(R/Ro) steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro) steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To) steinhart = 1.0 / steinhart; // Invert steinhart -= 273.15; // convert to Celsius // steinhart = (steinhart * 9.0)/ 5.0 + 32.0; // Uncomment if you want to use fahrenheit

Serial.print("Temperature "); Serial.print(steinhart); Serial.print(" *C"); // Serial.println(" *F"); //Uncomment when using fahrenheit

if(steinhart<=25.90){ digitalWrite(7, LOW); Serial.println(" Ventilator Off"); }

if(steinhart>=25.90){ digitalWrite(7, HIGH); //switch on ventilator. Serial.println(" Ventilator On"); delay(300); } }

First we define the themistor pin, this is a analog pin and i have set A0 for this.

#define THERMISTORPIN A0 or you can set any other analog pin. A1 A2 etc.

The rest of that parts needs no changes.


in void setup(void) {

we set analogReference(EXTERNAL);

because we are using AREF, 3.3v and A0 connected together with a 10K resistance.

Then we set the pin for the relay to pinMode(7, OUTPUT); I used Digital pin 7 for the SSR-25 DA relay.

in void loop(void) {

we read the value of the THERMISTORPIN at A0

samples[i] = analogRead(THERMISTORPIN); //line 38

you do not need to change anything here unless you changed the name of the A0 pin then change it here to.


Converting to Fahrenheit

If you want to use fahrenheit instead of celcius then simply uncomment line 62 and 67

then comment line 66 so it does not print out *C to serial monitor.

//  steinhart = (steinhart * 9.0)/ 5.0 + 32.0; //line 62
//  Serial.println(" *F"); //line 67
Serial.print(" *C"); //line 66

The if statement

In the if statement we read the value from steinhart.

If the temperature is <= less then or equal to 25.90 Celsius then the relay pin will be set to low, so OFF.

if the temperature is >= more then or equal to 25.90 Celsius then the relay pin will be set to HIGH, so ON.

Change the value 25.90 to the value you need.

if(steinhart<=25.90){
digitalWrite(7, LOW); Serial.println(" Ventilator Off"); }

if(steinhart>=25.90){ digitalWrite(7, HIGH); //switch on ventilator. Serial.println(" Ventilator On"); delay(300); } }

Comments

About This Instructable

104views

3favorites

License:

Bio: Hello world! I make simple & Advanced projects for people who want to learn programming and electronics. Most of my Instructables are about arduino and the ... More »
More by vandenbrande:ARDUINO - SOLID STATE RELAY FAN/ventilator Control Using the W1209 Thermistor and SSR-25 DA Arduino - SSR-25 DA Solid State Relay and DS3231 RTC Automatic Timer Lamp Arduino & C# - RGB LED / LED STRIP CONTROL C# Application
Add instructable to: