Vehicle temperature sensor reading

As part of my first Arduino ECU/Datalogging project im trying to read the coolant temperature on a CBR600RR motorcycle engine (for FSAE). The temperature sensor has 3 pins; pin 1 receives 5V from the ECU, pin 2 connects to ground through the ECU, and pin 3 goes to the gauge cluster. Ive read the "Decoding thermistor characteristics table" post but it seems overly complicated for what I need to do.
The temperature range will be between 100-250 degrees F and I only need an accuracy of around 5 degrees F and a reading only about once every 5-10 seconds.
So, I connected the sensor directly to my arduino with Pin 1 to 5V, Pin 2 to ground, Pin 3 to analog input 1(A0). Here is my code

int val = 0; // variable for value read
int temp = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
val = analogRead(A0); // read the input pin
Serial.println(val);
temp = map(val, 0, 1023, 100, 250); //scale input value to temperature
// Serial.println(temp);

delay(2000);
}

I know I need to get the min/max resistance of the thermistor so I can set up the scale part right. But my problem right now is that im not getting a consistant reading (anything from 250-500) even though temperature is not changing.

Is this likely to be a software or wiring problem? Or maybe out of range of the thermistor (its at ambient for this test)?

Im a mechanical engineering student so I have only basic knowledge of circuits and software so I would appreciate any help/suggestions.
Thanks

Make sure you have everything set up right by testing it with a known voltage first. I suggest connecting the +3.3V output of your Arduino to your analog input and verifying the reading (should be 675 or so). If it's around 675 and holding steady(ish) then your software is good and there's something wrong with your sensor or how you have it hooked up.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Alright, I hooked the analog input to the 5V and 3.3V, im getting 1022-1024 @ 5V and 698-709 @ 3.3V. So I think my software should be fine. Im not sure how else to hook up the wiring. There is only three pins.

Do you have any data on what's actually inside the temperature sensor? If it is just a thermistor then it is ignoring the 5V coming to it and just behaving like a temperature-dependent resistor. You won't get any "voltage" out of it then -- you'll have to configure it in a resistor divider configuration or something like this.

Any more info on the sensor? Can you open it up to see what's inside?

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

I cant open it up, its a copper cylinder like this:

But I think I may have figured it out. I put it in a voltage divider arangement like so
5V---Thermistor----A0 input----1k resistor----GND
and I connected the 5V to Pin 3 of the thermistor and the copper exterior of the thermistor to A0.

My data is now consistant jumping around only +/- 2 and increasing when I heat up the thermistor.

Now my question is how to adjust the data to reflect actual temperature values? The data im getting now is around 50(at ambient) and increased to around 100 when I heated up the thermistor.

Would getting two known points like 100F and 200F and finding their relative arduino readings (maybe 60 and 150) then doing some interpolation work?

Now we're getting somewhere. If you're getting 50 at ambient (20 C?) then that's 50/10235 = 0.244 volts. The voltage divider you are forming has a gain of 1k/(1k+RT) where RT is your thermistor value. The output voltage from your assembly is then 51k/(1k+RT)=0.244 volts from which we can solve that RT=20k approximately.

Of course I could have probably suggested you measure that directly with a DMM :slight_smile:

If that's true, then you don't have to do any interpolation. I'd replace the 1k resistor with a 10k-20k resistor (let's say 10k for now) then you have the equation:

analog voltage = 5*10k/(10k+RT)

from which you can solve for RT. Thermistors generally have well-known temperature-resistance properties that you can look up at various manufacturers. Given that you only need accuracy to 5 degrees though it would probably be easiest to just build a lookup table of analog voltage reading-->temperature. Use a commercial temperature gauge for the moment to build this lookup table (e.g., heat up your sensor and the temperature gauge at the same time and just take readings).

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

Thanks for the help!
Here is my code

void loop()
{
val = analogRead(A4); // read the input pin
volt = (0.004887585*(val));
res = ((1000volt+5000)/volt);
temp = (-0.04472
res+145.148);
Serial.println(val);
Serial.println(volt);
Serial.println(res);
Serial.println(temp);
Serial.println("--------");

delay(1000);
}

Im not sure how to get the right numbers to set the temperature though. I found a data sheet on the thermistor and it says
2.1k-2.6k ohm @248F
0.65k-0.73k ohm @176F

I used those 2 data points to make a linear fit equation but it doesnt seem to work. Im assuming the temperature/resistance relationship isnt linear. Is there another way to do this or am I going to have to get a thermometer and make a chart?

im getting data like this:

52
0.25
20673.08
-779.35

50
0.24
21460.00
-814.54

52
0.25
20673.08
-779.35

Thermistors are definitely not linear functions of temperature.

Here's more than you ever wanted to know about them:

http://www.vishay.com/docs/29053/ntcintro.pdf

IF you knew the material constant B of the thermistor you could use the equations shown in the above to solve for the temperature.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Hi! I'm responsible of the injection system for our FSAE University car. The thing is that I've been collecting information about the sensor of the injection system, but couldn't find any specific info about how they work exactly with the ECU, (by the way we are putting a LINK ECU, not the original one). So, do you know any website where I can find info about it?

Look in the CBR600 shop manual. It should have a section on testing the sensor.