Go Down

Topic: [SOLVED]KY-013 analog temperature sensor incorrect readings. (Read 20807 times) previous topic - next topic

dainiusb

Jan 07, 2014, 06:34 pm Last Edit: Jan 07, 2014, 11:12 pm by dainiusb Reason: 1

My KY-013 sensor is acting weird, but I believe the problem is in the code. This is the original test code that I received with it:
Code: [Select]
#include <math.h>
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;// Convert Kelvin to Celcius
return Temp;
}
void setup() {
Serial.begin(9600);

}
void loop() {
Serial.print(Thermister(analogRead(0)));
Serial.println("c");
delay(500);
}

It's showing 32c instead of 18c. It seems that it's working in the opposite way. I mean, when I heat it, temperature drops, if it gets cold, temperature rises. Please revise the code and try to figure out where is the problem.

jremington

There is this comment
Quote
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

dainiusb

Swapped ground with power. Works well now. Thank You both.

eeds35

#3
Mar 18, 2014, 09:52 pm Last Edit: Mar 19, 2014, 11:33 am by eeds35 Reason: 1
Anyone has got this module working on Due?

Today i did some tests on this sensor with due. I connected analog out to S pin in middle i connected power 3.3v and in (-) pin i connected gnd.  Because that module is like voltage divider and you can see that between S pin and mid are 10k resistor.

Code now looks like this :
Code: [Select]
double Thermister(int RawADC) {
  double Temp,Vo;
  Vo=float(RawADC)*(3.3/4095);
  Temp = log(10000*(3.3/Vo-1));
  //Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;// Convert Kelvin to Celcius
  return Temp;
}


I am using 12 bit precission. And getting ~29-32C(need something like 20). When i measure out pin with tester i get ~1.6 volts but with arduino converting i get 2.26v. Maybe my tester is wrong :D

volt=float(analogRead(A1))*(3.3/4095); // conversion to volts


eeds35

Its turned out that it was IDE problems with DUE analog reading.

JVDE

Hi, I used the code at the top and my reading goes down when I apply heat. Strange. Can anybody help me ?

Thanks in advance,
Jens Van den Eede.

jremington

The positions of the resistor and thermistor are swapped. Swap power and ground connections to the sensor.

Go Up