Ive got a coolant temperature sensor out of a car that I want to use to measure temperature.
On the sensor it says: "VDO 130*c max 1 710 535 805/34/1 4.91"
I used this diagram here to wire it up:
Im not sure how to tell if its a 10k thermistor or not... So im not sure what resistor to use. I just used a random resistor.
With it wired up like that it does not work, it just gives an ADC reading which does not change.
If I change the 5V and ground around it works. Tho as I heat the sensor the ADC reading goes down, if I cool it it goes up. Does this mean it is a PTC thermistor?
I could not find a data sheet for this sensor... How would I go about working out temperature from the ADC reading? Do I need to measure the resistance of the sensor at different temperatures and make a temperature / resistance curve / graph?
I think the easiest thing to do is use your volt meter. If it is a 10k resistor, it will measure 10k at 77 deg F. As you heat, the resistance should go up, if it is PTC. If the resistance goes down with increasing temperature, it is NTC. Hope this helps.
Ok, resistance goes down as I heat it, so it is NTC. I will heat it to 25c (77f) and measure the resistance. I think it will be approx 6.5k ohms at 25c.
Does the divider resistor have to be the same as the thermistor?
I have been playing with the value in bold
"Temp = log(((10240000/RawADC) - 1000));"
I belive this is the value of the thermistor at 25c? I have tryed the value of the divider resistor, and thermistor at 25c.
This is how my sensor is connected:
The dividing resistor is 1000ohms.
I do get readings that go up and down with temperature, but they are wrong. Ie, -18c when ambient is 21c.
Here is how I have done it. The purpose of the Sensor base class is to provide different kind of sensors (e.g, ntc10, ds18b20, smt16030) with a common interface. In my code I have an array of pointers to sensor instances which I call through the base class.
I use the B parameter equation, check Thermistor - Wikipedia.
You have to know the sersor's B-value. If you don't know it, I guess you can start from 3950 which works for many NTC10 thermistors. Adjust it until the readings match with a known reference.
byte pin = 0;
float B = 3950; // thermistors B-value
int R0=10000; // resistor value
int order = 0; // 1 or 0 depending on which side the ground is
NTC ntc(pin, B, R0,order);
// convert the temperature. Returns temp in celsius * 10,
// if the temperate is 25*C, returns 250
int temp = ntc.updateTemp();
Serial.println(temp/10.0);
// return the last converted temp value. Doesn't do the conversion
int temp = ntc.getTemp();
Sensor.h:
#ifndef Sensor_h
#define Sensor_h
// pure virtual base class for temperature sensors
class Sensor
{
public:
virtual int getTemp() = 0;
virtual int updateTemp() = 0;
virtual int setCalib(int);
virtual int getCalib();
};
#endif // Sensor_h
Sensor.cpp
#include "Sensor.h"
int Sensor::setCalib(int calib) { return 0; };
int Sensor::getCalib() { return 0; };
NTC.h:
#ifndef NTC_h
#define NTC_h
#include "WProgram.h"
#include "wiring.h"
#include "Sensor.h"
class NTC : public Sensor
{
private:
int temp;
float B;
int R0;
float Ri;
public:
byte pin;
int calib;
byte id;
int order;
// constructor,
NTC(byte,float,int,int);
// return temp value
int getTemp();
int updateTemp();
int setCalib(int);
int getCalib();
};
#endif // NTC_h
NTC.cpp
#include "NTC.h"
#include "math.h"
#include <EEPROM.h>
const float t0 = 298.15;
//NTC::t0 = 298.15; //+25C
NTC::NTC(byte pin=0, float B=0, int R0=0, int order=0)
{
this->pin = pin;
this->B = B;
this->calib = 0;
this->id = 0;
this->R0 = R0;
this->order = order;
Ri = R0*exp(-B/t0);
}
int NTC::updateTemp()
{
temp = 0;
int val = analogRead(pin);
if (order == 1) {
val = 1023 - val;
}
float R = (float) val;
R *= R0;
R /= (1023 - val);
float Ri = R0*exp(-B/t0);
float t = B/log(R/Ri)-273.15;
temp = 10*t;
return temp;
}
int NTC::getTemp()
{
return temp;
}
int NTC::setCalib(int calib)
{
this->calib = calib;
return calib;
};
int NTC::getCalib()
{
return calib;
};