Temperature Controlled Fan with i2c LED

I have no experience with the TMP36 part. I almost exclusively use the DS18B20 digital sensor.

Buy from reputable vendors, there are many bogus ones out there.

float temp =(voltage - 0.5)* 100.0;`

This isn't the "real problem" but the LM35 doesn't have the 0.5V offset, only the LM36.

...And with some algebra done in advance you use the 0-1023 reading directly, skipping the conversion to volts. (It doesn't matter though. The Arduino doesn't mind making the calculations.)

1 Like

There's many LM35 counterfeits floating around, where did you buy yours?
Which Arduino are you using.

Mine came in with a kit.

I am trying to figure out the problem and I found out that even without any temperature sensors or wirings connected to my breadboard, and its just solely the lcd and the arduino running the lcd still reads some temperatures fluctuating around 100-200 degrees, is this normal?

If you are reading an unconnected analog input pin, yes.

Try this test program, calibrate by changing number in "calValue" variable.

/*
 LM35, TMP36 thermometer, no floats, no delays
*/
const bool t36 = false; // set false for LM35, true for TMP36
const byte numSamples = 8, // number of samples for smoothing
           aInPin = A0; // analog input pin
const int calValue = 0, // adjust for calibration, +/-0.1 degree
          hAref = 110, // analog ref voltage * 100
                       // measured with accurate DMM
          hnumSamples = numSamples * 100,
          tEnd = 3000; // update time in mS
int val,
    tempC,
    tempF;
uint32_t total,  // sum of samples
         tStart; // timer start
byte cnt = 10;
        
const char header[] = "\nRaw    Total   Temp C  Temp F";
         
void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL); // use 1.1V internal ref
  analogRead(aInPin);
  for(int i = 0;i < numSamples;i++) // for smoothing, fill total
    total += analogRead(aInPin);   // with numSamples * current
                                   // reading
}
void loop()
{
  if(millis() - tStart > tEnd)
  {
    tStart = millis(); // reset timer
    if(++cnt >= 10)
    {
      Serial.println(header); // every 10 lines
      cnt = 0;
    }
    val = analogRead(aInPin);
    total -= (total / numSamples); // make room for new reading
    total += val; // add new reading
    tempC = total * hAref / hnumSamples + calValue;
    if(t36)
      tempC -= 500;
    tempC = antiDither(tempC);
    tempF = tempC * 9 / 5 + 320;
    Serial.print(val);
    Serial.print("\t");
    Serial.print(total); // sum of samples
    Serial.print("\t");
    prntTemp(tempC);
    prntTemp(tempF);
    Serial.println();
  }
}
void prntTemp(int temp)
{
  Serial.print(temp / 10); // whole degrees
  Serial.print(".");
  Serial.print(temp % 10); // tenths
  Serial.print("\t");
}
int antiDither(int newVal) // prevents +1 <-> -1 dither
{                       
  static int val = 0, oldVal = 0;
  if(newVal != val && newVal != oldVal)
  {
    oldVal = val;
    val = newVal;
  }
  return val;
} 

1 Like

Your temp sensor is connected to A3... (at least in your schematic, difficult to see on your picture).
The small black wires are not pushed into the breadboard far enough. Push them deeper. Check all your wires!

In your simulation, the temperature sensor is connected to A3, while your sketch is expected it to be connected to A0.

The pictures of your actual setup don't show where the sensor is connected.

1 Like

My mistake, its connected to A0 in my actual work.

Here is the setup:
The tmp35 is connected to A0 and the PWM is at D9.

I don't see a flyback diode across that motor to protect the MOSFET. You may have blown it.

How many posts do you have on this same question? You need to stop crossposting before you get in trouble.

**WHAT IS THE PART NUMBER OF (perhaps blown) MOSFET? Please answer questions.

IRLZ44N would be a good logic level MOSFET.

1 Like

And I see you're asking the same questions in multiple posts, and that I'm answering the same questions you had answered hours ago. You now have one less person willing to help you. Good-bye.

1 Like

Hello. I apologize for crossposting as I did not know it was not allowed and I thought that my previous post would get covered up after it got inactive. It will not occur again.

Im not particularly sure what exactly is a part number but as per mentioned, my mosfet is IRFZ44N.

I was wondering what was the problem because before you have suggested to add some parts yesterday, it was still working. However now it does not. If ever the MOSFET did blow up I think it would make sense.

Im sorry as I am particularly new to these forums. Though you mightve already answered some of my questions before I am only trying to figure out the problem so that I could solve it. Thank you.

What are the letters on the end, there are several variations of that part number. If there are no more letters it is not a logic level MOSFET.

There is no more letters at the end of the MOSFET. Would you recommend that I replace this with a logic level MOSFET?

That is not a recommendation, that is a requirement of your design. Many also have an avalanche rating or UIS, use one of those with both ratings also eliminates the need for a flyback diode. Also be aware when you battery is about dead you can possibly burn up the MOSFET. Reason the MOSFET will be in the linear range (ohmic), depends if enough current is available.

1 Like

@johncomet ,

Your three topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

1 Like

How do you connect the flyback diode to the mosfet? Im confused as to which pins on the breadboard it should be placed in.

Hi,
If you problem is with the temperature sensor, then just write some code for the sensor.
Leave out the motor circuit, disconnect it.

Then see if your temperature readings vary.

Do you have a DMM? (Digital MultiMeter)

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like