```cpp
#include <math.h>
#define LED 2
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
double thermistor(int val){
double temperature;
temperature = log(((10240000 / val) - 10000));
temperature = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temperature * temperature)) * temperature);
temperature = temperature- 273.15;
return temperature;
}
void loop() {
int value = analogRead(A0);
double temp = thermistor(value);
Serial.println(temp);
delay(50);
}
jim-p
June 27, 2024, 2:07pm
2
In the IDE, on the Menu bar, click on Edit then on Copy for Forum.
Then paste your code here. It will be easier to read.
Do you have a DMM/Multimeter?
No sir, the problem is, the place where I bought the thermistor told me that it is NTC. But when I build the circuit and write the code, I cannot see any change whether I heat or cool the NTC. I wonder if there is an error with the code I wrote or is it in the thermistor?
jim-p
June 27, 2024, 3:26pm
4
Well let's see if it actually works.
Try this code:
It will print the ADC value and temperature.
#include <math.h>
#define LED 2
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
double thermistor(int val){
double temperature;
temperature = log(((10240000 / val) - 10000));
temperature = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temperature * temperature)) * temperature);
temperature = temperature- 273.15;
return temperature;
}
void loop() {
int value = analogRead(A0);
Serial.print("value = ");
Serial.print(value);
Serial.print(" temp = ");
double temp = thermistor(value);
Serial.println(temp);
delay(500);
}
Is the white wire GND and the orange 5V ?
Post a simple schematic showing how it is wired, the picture does not do it for me. Be sure to indicate polarity on the connecting leads.
jim-p
June 28, 2024, 7:38am
8
Please see posts #4 and #5
ZX80
June 28, 2024, 10:43am
9
The only information we have about this thermistor is that it's green .
Koepel
June 28, 2024, 11:40am
10
It can be a NTC, a PTC, a fuse or a capacitor.
Can you ask around if someone has a multimeter ?
xfpd
June 28, 2024, 6:41pm
11
Put the thermistor in line with a resistor and LED. Adjust the PWM to see the LED glow a little. Cool and heat the thermistor. Some of these need to be very hot. I used an NTC in a 50A circuit to slow inrush current.