Temperature sensor using thermistor

I'm currently working on a project that has a thermistor voltage divider with the out put being processed with some maths to get the temperature. From there if the temperature gets above a certain number. I have a temperature about 5-10 degrees above the room's, so I can heat it up with my hand.

int led = 6;
int therm= A1;    
double temp=0;
double volt = 0;
double down = 0;
double res=0;
void setup() 
{
 
}

void loop()
{  
 res=analogRead(therm)*5/1023;
 down = 9.7064/res;
 volt= log(down-1.94128);
 temp= 34.48275862*volt;
 if(temp>30)  
  {
   digitalWrite(led,HIGH);     
  }   
  else
  {
     digitalWrite(led,LOW);   
   }
  }

I assume you are posting because it doesn't work. It's missing

pinMode(led, OUTPUT);

In setup()

Thank you so much, I can't believe that I forgot this. I'll try this when I'm in class tomorrow.

Also be aware your "5v" may not be actually 5v but lower and throw out your measurements.

Analog may well need to be averaged as well to get stable reading.

One reason why they now use ds1820 digital sensors.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.