Hello, I'm having a problem trying to get a TMP36 to control an IRF520.
The point of all of this to make a miniature radiator. As I've been told by my teacher, the TMP36 measures the temperature and if the temperature is below a certain centigrade the IRF520 will allow current to pass through and into a resistor which will heat up and when it reaches the desired temperature it will turn off.
What I want to happen is the TMP36 to register a temperature of 25 celsius, if lower: turn on MOSFET and if Higher: Turn MOSFET off
What I think happens is that my TMP36 us registering a temperature, but something in my code does not let the IRF520 pass current into my resistor
(Instead of the resistor I am using a little light to show if the current is flowing)
My code:
//TMP36 Pin Variables
int sensorPin = A0;
#define control 2
void setup()
{
Serial.begin(9600);
pinMode(control,OUTPUT);// define control pin as output
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
Serial.print(voltage); Serial.println(" volts");
float temperatureC = (voltage - 0.5) * 100 ;
Serial.print(temperatureC); Serial.println(" Grader C");
delay(1000);
{
if(temperatureC < 25) {
digitalWrite(control,HIGH); // turn the MOSFET Switch OFF
}
else(temperatureC > 25 ); {
digitalWrite(control,LOW); // turn the MOSFET Switch ON
}
}
}
I am positive the yellow wire doesnt short out the power. I currently don't have a IRL520 and don't have the time to order one. Is it possible to work around this problem.
In the red rectangle it seems that both the black and red wires are plugged into ground terminals.
in the yellow rectangle the yellow wire goes from - on the bottom of the breadboard to + on the top. That is not a short?
5V on the IRF520 gate should allow enough current through to light an LED WITH a 470 Ohm current limit resistor in series. Not a power resistor though. What is the value of that resistor?
Replace that orange jumper in the LED cathode circuit with a 330 or 470 Ohm resistor.
17V / 10Ω = 1.7 Amps * 17V = 28.9 Watts. Your 5W resistor will burn up! To get 5W from 10Ω would be only 7.07V. That could be done with PWM but I don't believe the IRF520 can do it without overheating and failing.
Did you get your LED circuit to work?
The point is to make it heat up so much that it will radiate heat like a radiator, although I don't want to burn it up completely. No I did not get my LED circuit to work, the LED flickers on a little but it does not light up.
Good news, the LED works, and when it gets below 25 I turn on and off over 26. But the readings from the TMP36 is going haywire, it goes from 29 celsius to 16 C. What exactly does the capacitor do and is it necessary to have it at the TMP36
slipstick:
Not quite. Take the semicolon out but put the if back in i.e.
else if(temperatureC > 25 ) {
digitalWrite(control,LOW); // turn the MOSFET Switch ON
}
Steve
Yep, My bad
I read the code from JCA34F's reply (#5) where I spotted the extra semicolon but copied it from the OP's original post and forgot to add the missing if.