1

Connecting all like shows the image, thermistor shows, that I'm going to be burnt:





The code is simple:

#define analogPin  A0 //the thermistor attach to 
#define beta 4090 
#define resistance 10 

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  //read thermistor value 
  long a =analogRead(analogPin);
  //the calculating formula of temperature
  float tempC = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
  float tempF = 1.8*tempC + 32.0;
  Serial.print("Temp: ");

  Serial.print(tempC);

  Serial.print("  C");

  Serial.print("Fahr: ");
  Serial.print(tempF);
  Serial.print(" F");
  delay(200); //wait for 100 milliseconds
}

Do I have a wrong thermistor or wrong code?

closed as unclear what you're asking by gre_gor, sempaiscuba, per1234, Greenonline, jose can u c Sep 7 '18 at 13:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    There are no magicians here. What model/type of thermistor have you connected? What the thermistor's parameters are? – smajli Sep 3 '18 at 9:43
3

The series resistance is 220 Ohms (Red, Red, Brown).

You also need to take into account the thermistor resistance at 25C. Assuming its 10K. Hence choosing a 10K series resistance will make the calculations easier.

     int THERMISTORNOMINAL =  10000;
     int SERIESRESISTOR = 10000;
     int TEMPERATURENOMINAL = 25;  

     a = 1023 / a - 1;
     a = SERIESRESISTOR / a;
     tempC = a / THERMISTORNOMINAL;     // (R/Ro)
     tempC = log(tempC);                  // ln(R/Ro)
     tempC /= Beta;                   // 1/B * ln(R/Ro)
     tempC += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
     tempC = 1.0 / steinhart;                 // Invert
     tempC -= 273.15;                         // convert to C
  • Could you make a full working sketch? This code snippet is confusing because it does not show if the variables are a float or integer. Add a link to a source for your calculation as well. – Jot Sep 3 '18 at 18:43
  • I used 10K. The image is wrong. – Ver Nick Sep 4 '18 at 9:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.