Error in using NTC_Thermistor.h library

I am making a triple Arduino nano code in which I used Thermistor .h library but it doesn't read the data from sensors the answer is (-273 C) it should not be this. (sensor 1 =-273 C, sensor 2


=-273 C, sensor 3 =-273 C)

Also I had used many codes on calculations they worked but there are many loses in them example ( sensor 1 = 36.78 C, sensor 2 = 36.90 C and sensor 3 = 57 C)

Please help me to fix this code.

#include "NTC_Thermistor.h" // Adjust this if your library has a different name

// Define the thermistors using the NTC_Thermistor class
NTC_Thermistor thermistors[] = {
  NTC_Thermistor(A0, 10000, 25.0, 3950, 10000),
  NTC_Thermistor(A2, 10000, 25.0, 3950, 10000),
  NTC_Thermistor(A5, 10000, 25.0, 3950, 10000)
};

// Number of thermistors
const int numThermistors = sizeof(thermistors) / sizeof(NTC_Thermistor);

void setup(void) {
  Serial.begin(9600);
  analogReference(EXTERNAL); // Remember to hook up AREF to 3v3
  delay(1000); // Delay for stability
}

void loop(void) {
  for (int i = 0; i < numThermistors; i++) {
    float temp = thermistors[i].readCelsius(); // Using readCelsius method to get temperature in Celsius
    Serial.print("Sensor");
    Serial.print(i + 1);
    Serial.print(": ");
    if (temp != -273) {
      Serial.print(temp, 1);
      Serial.print(" C");
    } else {
      Serial.print("Error reading sensor");
    }
    if (i < numThermistors - 1) {
      Serial.print(", ");
    }
  }
  Serial.println();
  delay(1000);
}

I would start by using a simple sketch that only reads the analogue voltage of A0, A2 and A5 and sends that data to the serial monitor. Do you get values that vary depending on the temperature?

I think you have it wired backwards.
The thermistor should connect to GND and the resistor to 5V
Are you using this lib?

1 Like

I've corrected your spelling mistake in the word 'Thermistor' in the topic's title.

you mean without connecting series resistance?

Yes I am using libaray.
I connect resistor to ground and (analog + thermistor) .
5V to thermistor only

funny but thanks
I was in hurry so I type many wrong spelling
main thing is not here main thing is in code

yes I am using libaray.

See the wiring diagram in the link to the library

No

Use your existing wiring and just read analogue voltages on the inputs and print them. That way you can know that your wiring is OK.

Diagram
I'll try this

If you use 5V don't forget to remove the analogReference statement from your code.
Are you using the classic nano?

1 Like

Still same error even I connect wires according to circuit diagram and remove analog terms

#include "NTC_Thermistor.h" // Adjust this if your library has a different name

// Define the thermistors using the NTC_Thermistor class
NTC_Thermistor thermistors[] = {
  NTC_Thermistor(0, 10000, 25.0, 3950, 10000),
  NTC_Thermistor(2, 10000, 25.0, 3950, 10000),
  NTC_Thermistor(5, 10000, 25.0, 3950, 10000)
};

// Number of thermistors
const int numThermistors = sizeof(thermistors) / sizeof(NTC_Thermistor);

void setup(void) {
  Serial.begin(9600);
  analogReference(EXTERNAL); // Remember to hook up AREF to 3v3
  delay(1000); // Delay for stability
}

void loop(void) {
  for (int i = 0; i < numThermistors; i++) {
    double celsius = thermistors[i].readCelsius();
 // Using readCelsius method to get temperature in Celsius
    Serial.print("Sensor ");
    Serial.print(i + 1);
    Serial.print(": ");
    if (celsius != -273) {
      Serial.print(celsius , 1);
      Serial.print(" C");
    } else {
      Serial.print("Error reading sensor");
    }
    if (i < numThermistors - 1) {
      Serial.print(", ");
    }
  }
  Serial.println();
  delay(1000);
}

REMOVE the analogReference statement

1 Like

Thanks its working

Have a nice day!

1 Like

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