ADS1115 with NTC 47K thermistor on Arduino UNO

I read a lot of similar topics and none of the Codes give good results,
Can anyone help with a code that works correctly for a 47K thermistor and ASC1115 16 bit on an Arduino UNO?

  • NTC 47k and resistor 47k are 5v voltage dividers.
    -VCC=5v

Exactly what is no good?
Have you calibrated your readings?
Do you have the datasheet for your thermistor?

--Exactly what is no good?
the result of calculation according to different formulas is not good, or a completely illogical result or approximately correct.

--Have you calibrated your readings?
What exactly do you mean?

--Do you have the datasheet for your thermistor?
yes

Does the datasheet have a table of resistance values?
Does it have coefficients for the Stienhart-Hart equation?

Post the data sheet so I can see.

data sheet

With the table it is easy.
You just need to do a linear interpolation between temperature values.

Once you find the thermistor resistance, find the place in the table where that value is inbetween two resistance values. Then interplate between the two temperature values to find the temperature

Use this library to do the interpolation

Example:
Say the therrmistor resistance is 48000.
That falls between 46998 and 49395 in the table.

Temperature  Resistance
 23.89         49395
 25.00         46998

Interpolated T = y0 + (x - x0) * [(y1 - y0) / (x1 - x0)]

T = 23.89 + (48000- 49359) * [ (25.00 - 23.89) / (46998-49395)]

T = 24.52

ok, it just needs to be inserted into Cod to work properly, which I don't know why and I'm asking for help.

if there is an example code that would adapt to my values.

You can search for example code but I don't know of any offhand that uses a table. You will have to enter the table values by hand. Only enter the range that you need.

Have you ever written any Arduino code?

Of course, I have a lot of projects behind me, I am an IT and mechanical engineer by profession.
It's the first time I meet ADS1115, until now I used Analog input from Arduino 10bit and it was simpler for me.

Keep in mind that the ADS1115 is an absolute voltage sensor, with an internal voltage reference, and that the thermistor voltage divider output is proportional to Vcc.

So you need to use the ADS1115 to measure both Vcc and the divider output.

You made it sound like the problem was reading a thermistor and converting that to a temperature.
There are several libraries for using the ADS1115 with examples.

Have you tried this one
https://docs.arduino.cc/libraries/ads1x15/

It will take a pretty clean electrical design to get (most of) those 16 bits of resolution. No floating grounds, no long hookup wires, no push-in bread board, no EZ-hooks, etc.

I tried this formula to calculate and result on Serial monitor is below
vcc=5v, NTC 47k and resistor 47k are 5v voltage dividers.
The temperature in the room is 18c.

int thermistor_25 = 46998;
float refCurrent = 0.00047; 
ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V 1 bit = 3mv 0.1875mV (default)

adc2 = ads.readADC_SingleEnded(2);
Voltage = (adc2 * 0.1875)/1000; 
  float resistance = (Voltage / refCurrent); 
  float ln = log(resistance / thermistor_25);
// from Steinhart-Hart thermistor calculator //
  float A = 0.009098880323;
  float B = 0.0002148732041;
  float C = 0.0000001064658112;
  float kelvin = 1/(A + (B * ln) + (C*(ln * ln * ln)));
  float temp = kelvin - 273.15;

result on Serial monitor
adc2: 16102
Voltage: 2.065875053 // for this voltage the NTC has about 69k , around16c
resistance: 4395.479003906
ln: nan
kelvin: nan
temp: nan

Please edit your post to include ALL the code and use code tags (<code> editor button). Explain what "doesn't work" means, and what you have done to investigate the problem.

Where did you find that code? It is not correct.

resistanceNTC should be calculated like this

float refResist = 47000;
float Vs = 5.0;

adc2 = ads.readADC_SingleEnded(2);
Voltage = (adc2 * 0.1875)/1000; 
float resistanceNTC =( (Vs * refResist) / Voltage ) - refResist

resistanceNTC = ((5*47)/2.06)-47 == 67k approximately how much NTC should be at a voltage of 2.06v
am I right?

That formula is no good for your thermistor.
Use the table provided in the data sheet and the values will be exact.
See post #6 and #7

float refCurrent = 0.00047;
 float resistance = (Voltage / refCurrent); 

I think that you are calculating the resistance wrongly.

That formula suggests that you have a constant current of 0.00047A = 470µA flowing though the thermistor - which you don't.

To find the current you would need to measure (or calculate) the voltage across the 47kΩ resistor, and then use that voltage and resistance to calculate the current that flows through the thermistor.

EDIT: When I posted this reply, posts #15 to #17 did not show up on my PC.
That is strange because post #15 was from 10 hours ago.

Do you have you thermistor connected like this?

yes