Where do you buy your ky-013 thermistor module?

Hello,

I purchased a ky-013 thermistor module (*) on AMZ but the data were ridiculously wrong.
Capture

Where do you buy your perfect workinf ky-013 thermistor module ?
I am based in France.

Regards
Al

Please post the schematics. That costs less theb buying new ones.

yes, now i prefer quality

In what way? What code did you use? How did you connect the module up?

Your statment is too generic to help!

1 Like

Sorry for that,
I bought here : https://www.amazon.fr/AZDelivery-thermistance-Température-Capteur-Arduino/dp/B07DQMX1XG/

In a description on merchant web site, we can see the signal is connected to a digital io. That's weird!
1

I tested first like it is drawn but after i connected the signal to A0

I spent half a day trying to have the right temperature, i tested this type codes

Please post detailed test results, not general statements. You were also asked in reply #4.

here is the code :

`//==== declaration
const int ThermistorPin = A0;

double Thermistor(int RawADC) {
  double Temp;
  Temp = log(100000.0*((1024.0/RawADC-1))); 
  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;
}


//==== Execution
  int readVal=analogRead(ThermistorPin);
  double temp =  Thermistor(readVal);
  Serial.println(temp);  // display tempature
  Serial.println("c");`

Actual temperature of the thermistor: 21,1°C (measured with infrared device)
Temperature obtained with the above code : 28°C

That code looks suspicious -- Is the KY-013 a 100K or a 10K thermistor? And `(1024.0/RawADC-1) looks susceptible to RawADC==0 and ... awkward.

Is this math for determining the value of an unknown resistor in a voltage divider correct?

Shouldn't this be:
Temp = log(10000.0*((1024.0/RawADC-1)));
Ten k instead of one hundred k?

@JCA34F right
Here is the new version. I pay a particular attention to the casting.
Result is far much better
Actual temp : 21.7 °C
Measured temp : 23.04 °C

But When i increased the temperature with lighter, the measure drops

//==== declaration
const int ThermistorPin = A0;

double Thermistor(int readVal) {
  double Temp;
  double R1 = 10000; // 10^^3 Ohms
  Temp = R1*1024.0/((double)readVal-1);
  Temp = log( Temp ); 
  Temp = (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ) ;
  Temp = 1. /Temp ;
  Temp = Temp - (double)273.15;            // Convert Kelvin to Celcius
  return (Temp);
}

//==== Execution
  int readVal = analogRead(ThermistorPin);
  double temp =  Thermistor(readVal);
  Serial.print(temp);  // display tempature
  Serial.println(" °C")

Is the fixed resistor on your KY-013 between GND and the thermistor, or is it between the +V and the thermistor?

I'd work out the voltage divider equation based on its' actual circuit.

The parentheses around the -1 look wrong. I don't know your actual circuit to get the terms right, but it seems like you should do the (1024.0/readVal) before the -1.

I guess R1 is between the Signal and the +V=5Volt (center)

Thanks.

So the formula should look and work like a voltage divider with the variable resistance on the bottom.

Using this calculator, at 25C, when the NTC thermistor should read 10K, it would work like this:

Your formula should be like that formula, but divide top and bottom by Vout to get:

R2 = R1 * 1 /(Vin/Vout -1);

Where, with the ADC, the Vin/Vout ratio is the 1024/(readVal) (Or I'd use 1024/(readVal+0.5) per the arguments in Gammon Forum : Electronics : Microprocessors : ADC conversion on the Arduino (analogRead) and to protect against divide-by-zero.

Here's some untested, modified code:

//==== declaration
const int ThermistorPin = A0;

double Thermistor(int readVal) {
  double Temp;
  double V_in_out_ratio = 1024.0/(readVal+0.5);
  double R1 = 10000; // 10^^3 Ohms
  Temp = R1/(V_in_out_ratio-1);
  Temp = log( Temp ); 
  Temp = (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ) ;
  Temp = 1. /Temp ;
  Temp = Temp - (double)273.15;            // Convert Kelvin to Celcius
  return (Temp);
}

//==== Execution
  int readVal = analogRead(ThermistorPin);
  double temp =  Thermistor(readVal);
  Serial.print(temp);  // display tempature
  Serial.println(" °C")

Where did you find this code?

There is an old thread where what DaveX is questioning comes up, it can be found here. Note the reply of jremington post #2.

Temperature sensor module KY-013
These modules are the same, they're all on boards labelled “S1”. THE PINS ARE MARKED BACKWARDS ON THESE.
Has pin 1 (marked S) (GND), pin 2 (5v power) and pin 3 (marked -) (analog signal.)

on this site: https://wiki.makehackvoid.com/workshops:arduino:dxmodulepack

Here are the options:

While I do not have that thermistor module apparently some went one way and some the other way, right and left sides of the schematic.

Assuming a 10K thermistor and a 10K series resistor at 25C the thermistor resistance should be 10K and in either case the Vout should be 2.5 volts with Vcc 5.0 volts. Using most of the code samples I see online when I apply an accurate 2.5 VDC to my analog in pin I get 30 to 31 degrees C.

Either I am looking at all of this wrong applying 2.5 VDC and expecting 25 C. or the code samples and I tried a few, are not quite correct and accurate.

If you have a DVM I would measure the Vout of your module and note the ambient temperature Vout. Next I would heat the thermistor and note if Vout increases or decreases? That will tell you how the board is configured. If Vout increases the module is as shown on the right. If Vout decreases the left side of the schematic.

Ron

1 Like

Before measuring voltages with a DVM, I'd measure plain old resistances and compare them to a 10K thermistor chart.

Another source of error is if the plain 10K resistor isn't accurate. If you measure yours and it's different than the 10K spec, you can increase the accuracy of the calculation by using your measured value instead of the 10K in the formulas.

Try reversing + & - wires, leave S (signal) as is.

I checked on internet, you were right a second time!

I change the formula : Temp = R11024.0/((double)readVal-1);
to Temp = R1
1024.0/(double)readVal - 1;

@DaveX i found the code here (among other sources):
here

or here