Thanks everyone for your reply, I did some trials and decided to use a 3.3kohm resistor. I could not understand nor build a working equation so i used a lookup table which is very good until 100 °C (i could not check above that temperature in that moment. I compared the data with a DS18 temperature sensor so i'm quite sure the measures are good. Now i'd like to go further and understand why my equations didn't work with this thermistor, and if someone is as curious as me we can try to figure it out.
I used this code: (it contains a lot of trials and comments, don't care about those)
#include <OneWire.h>
#include "lookupTEMP.h"
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// https://github.com/milesburton/Arduino-Temperature-Control-Library
OneWire ds(2); // on pin 10 (a 4.7K resistor is necessary)
/*
double sonda0;
//misura sonda NTC
double Thermistor(int RawADC) {
double Temp;
Temp = log(8800.0/(1024.0/RawADC-1)); // for pull-up configuration
// Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001732725 + (0.000208681 + (0.0000000429398 * Temp * Temp ))* Temp );
//Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
*/
void setup(void) {
Serial.begin(115200);
}
void loop(void) {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
int adcIN;
byte c ; //suppporto ciclo for
if ( !ds.search(addr)) {
//Serial.println("No more addresses.");
//Serial.println();
ds.reset_search();
//delay(250);
return;
}
//Serial.print("ROM =");
for( i = 0; i < 8; i++) {
//Serial.write(' ');
//Serial.print(addr[i], HEX);
}
if (OneWire::crc8(addr, 7) != addr[7]) {
//Serial.println("CRC is not valid!");
return;
}
// Serial.println();
// the first ROM byte indicates which chip
switch (addr[0]) {
case 0x10:
//Serial.println(" Chip = DS18S20"); // or old DS1820
type_s = 1;
break;
case 0x28:
// Serial.println(" Chip = DS18B20");
type_s = 0;
break;
case 0x22:
//Serial.println(" Chip = DS1822");
type_s = 0;
break;
default:
//Serial.println("Device is not a DS18x20 family device.");
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
//delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
//Serial.print(" Data = ");
//Serial.print(present, HEX);
//Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
//Serial.print(data[i], HEX);
//Serial.print(" ");
}
//Serial.print(" CRC=");
//Serial.print(OneWire::crc8(data, 8), HEX);
//Serial.println();
// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an "int16_t" type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
//fahrenheit = celsius * 1.8 + 32.0;
/*Serial.print(" Temperature = ");
Serial.print(celsius);
Serial.print(" Celsius, ");
Serial.print(fahrenheit);
Serial.println(" Fahrenheit");
*/
//sonda0 = double(Thermistor(analogRead(A0)));
//Serial.print("S0 - DS ");
//Serial.print(sonda0);
Serial.print("D: ");
Serial.print(celsius);
adcIN=analogRead(0);
for(c=0;lookUp[c]<adcIN;c++);
Serial.print(" T: ");
Serial.print(c-10);
Serial.print(" KT: ");
Serial.println(adcIN);
delay(500);
}
with this lookup table:
int lookUp[]= {
//-10
319,321,323,325,327,329,331,333,335,337,
//0
339,341,343,344,346,348,350,352,354,356,
//10
358,360,362,364,365,367,369,371,373,375,
//20
377,379,381,383,384,
//25
386,388,390,392,394,
//30
396,398,400,402,403,405,407,409,411,413,
//40
415,417,419,421,422,424,426,428,430,431,
//50
433,435,436,438,440,442,443,445,447,449,
//60
451,453,454,456,458,460,461,463,465,467,
//70
469,470,472,474,475,477,479,481,482,484,
//80
486,487,489,491,492,494,496,497,499,501,
//90
503,505,506,508,510,511,513,515,516,518,
//100
519,521,522,524,526,528,529,531,333,534,
//110
535,537,538,540,541,543,544,545,547,548,
//120
549,550,551,552,554,555,557,558,560,561,
//130
562,563,564,565,566,567,568,569,570,570,
//140
571,572,573,573,574,575,575,576,577,577,
//150
578};
hope this might help someone else...
As I was saying, I'd like to be able doing an equation which simplyfies the code like I always did with other thermistor.
I used a little software to find thermistor coefficent A B C and they results to me:
R1 2080 T1 30
R2 2980 T2 80
R3 4166 T3 140
Coeff.
A = 17.32725887 e-3
B = -20.86815698 e-4
C = 42.93982203 e-7
R 25°C 1993.28 ohm
beta -769.86 K
If someone can explain me what's my mistake... I can't figure it out