CarDuino - reading oil temperature sensor

Hello,

my CarDuino project is still ongoing and I am in the finishing stages of creating an engine data module that will do many things, from reading engine revs to vehicle speed, coolant and oil temperatures, and fuel tank level.

I'm not entirely sure yet how I am going to read the oil temperature sensor so that the input pin won't be damaged.

Basically, the oil temperature sensor is an NTC that is connected to GND and has only one wire on its plug. Its resistance varies between about 20 and 600 ohm. So I guess to get a reading from it, I am going to have to make a voltage divider that takes 5V from the Arduino and feeds it into my input pin with an inline resistor, and that part of the circuit then gets grounded through the oil temperature sensor. It being an NTC, this will then give me changing analog values on the A2 pin that I can use to calculate the oil temperature.

Here is an excerpt from my engine data module schematic (there is a lot more going on in the schematic, but I have largely omitted parts here that aren't relevant to my question):

Please click on the image for a larger view.

Can I just pull the A2 pin up to 5V with a 150 ohm resistor, or will that damage the pin? Pull-up resistors are usually much bigger, aren't they? And should I protect my circuit with a diode to make sure there won't be 12 volts from the car present on either my Vcc or A2 pin?

Can I just pull the A2 pin up to 5V with a 150 ohm resistor, or will that damage the pin? Pull-up resistors are usually much bigger, aren't they?

Yes, you can and that resistor is not a pull-up in the original meaning, it's part of a voltage divider. If the connected pin was an output the 150Ω pull-up might give it a 33mA to sink but that's still within the specs if you don't have to many pins having the same current to sink.

And should I protect my circuit with a diode to make sure there won't be 12 volts from the car present on either my Vcc or A2 pin?

I don't see where in that schematic you would insert a diode that would add to protect the circuit. The DC/DC converter should isolate well enough so you don't have voltages higher than 5V given you did not connect a wire to the wrong side but in such a case the protection diode is in the wrong place too as Murphy's Law dictates.

I just worry because the car's oil temperature sensor is wired so that the oil temp gauge in the dashboard puts 12 volts onto the sensor's wire. And I am going to tap into that same wire with my voltage divider, and according to my schematic, that would also put 12 volts onto the Atmega's Vcc pin. Isn't that one of the ways you fry an Atmega?

I just worry because the car's oil temperature sensor is wired so that the oil temp gauge in the dashboard puts 12 volts onto the sensor's wire. And I am going to tap into that same wire with my voltage divider, and according to my schematic, that would also put 12 volts onto the Atmega's Vcc pin.

In your schematic there is no connection from the sensor to 12V. I made my complete post based on that diagram, so if it's not showing the complete setup any of my statements may be wrong.

I would not use the same sensor you're still using for your car dashboard. If you have to you have to find out the complete wiring of that setup. It may be possible but can be quite tricky and if you missed one wire you may fry your hardware. If you want to go that way post a schematic of the current wiring (not just the new one but the built-in from the car too).

I would buffer the signal from the OEM oil temp sensor to eliminate any chance of messing with that circuit. Then you will need to calculate your voltage divider values to divide the voltage within range of the analog input. You can always put a zener clamping circuit on the arduino analog input pin to protect against an overvoltage condition.

The only mention of the oil temperature sensor in the diagrams manual to my car is in conjunction with the instrument panel in the dashboard:

Click on image for larger view.

The oil temperature sensor is not connected to the engine control unit. The ECU gets all its info about the engine's temperature from the coolant temperature sensor(s). The oil temp sensor therefore only powers the oil temp gauge in the dahboard.

The car is a 1998 MG F, with a Rover 1.8-liter "K series" engine.

The sensor really only has one wire on it. The sensor is an NTC which assumes values between around 10 and 600 ohm, like I said. My guess is that the oil temp gauge has some sort of voltage divider circuitry in it as well, with the sensor being the resistor that goes to ground.

ok, I have amended the schematic with a few more details, including how the oil gauge seems to be wired in my car.

Please click on the image for a larger view.

I've also got another problem - as you can see, I am also trying to read the fuel gauge. The fuel gauge sender unit is basically a variable resistor which has some 10 ohm when the tank is full and around 120 when it's empty. This equals voltages roughly between 8 and 12 volts measured at the sender unit wire.

To get a constant reading for the fuel gauge with my Arduino, I would have to measure the fuel tank sender's voltage against the car's current voltage, right? So I've connected Aref to a 22K/10K voltage divider that supplies a reference voltage from the car battery to the Aref pin against which the fuel gauge pin A1 is measured.

The problem is, the reading isn't constant. I switch to analogReference(EXTERNAL) in my ccode right before I read the fuel gauge, and yet, when I dial the 12 volt supply on my test rig switchboard up or down, I get varying readings for the fuel gauge.

After reading the fuel gauge, I then switch back to analogReference(DEFAULT) to get the oil temperature sensor reading. But I can't get an oil temperature reading the way my test circuit on my desk at home is wired. I have a 1K pot wired to GND as a stand-in for the oil temperature sensor, but all I get is a constant reading of 1023 on analogRead.


Yes, I know, you are not supposed to just switch between EXTERNAL and DEFAULT with an external voltage source connected to Aref, but as far as I have been able to find out on the web, if you've got a big enough resistor in front of Aref, it doesn't matter.

I am also aware that I've got a diode between the car battery and my voltage divider, but the way I figure, the ~ 0.7v difference can be accounted for when I will measure which voltages on the fuel tank sender will correspond to which actual measured fuel tank levels, so it won't matter in the end. I figured it would be worthwhile to try to protect Aref against overvoltages by running it through the circuit's overvoltage protection section. Although rare, short-lived voltage spikes of +100V have been observed in cars.

I think you're over complicating this. You don't need to "measure the fuel tank sender's voltage against the car's current voltage." The cars current voltage should be relatively the same when the car is running. Take several readings and average them.

Use a common ground with your car (aka chassis ground). Shift the voltages to levels safe for the arduino (0V-5V using a voltage divider). Build a scale/formula from the voltages you're seeing.

map 0 - 1023 to 0-5V if you want. Manipulate the transducers to known values (etc get the oil temp to a known temperature and see what the arduino reads, then make a table of several different points). Put your table of data into excel and get your formula (its probably linear so y = mx+b). Do that for all transducers.

Way ahead of you... I've already done that and have mapped the fuel sender's voltage with a 22K/10K voltage divider on an analog pin. I've also calculated a formula. Weirdly, this was not a linear formula. My guess is that the shape of the fuel tank needs to be taken into account. It's narrow at the bottom and wider at the top, enough so that you get a distinct curve in the analog pin readings. Meaning, the analog reading drops faster when you first begin to fill the tank up from zero, and then it kind of bottoms out. I guess naturally, when a narrow space of volume is filled up with liquid, the level rises faster...

The problem is, those values have turned out to be wrong now that I have built a whole circuit and wanted to back test my data on the real thing. So at some point, I am going to have to repeat my measurements. I will do them on the car both with external and default Aref, just to see if they differ...

From my schematic, would you have an idea why I still can't get a reading on my oil temperature sensor?

If you disconnect all your added circuitry, and use a multimeter to measure DC voltage, can you see a DC voltage that changes with temperature on the Output (where the signal goes to the instrument cluster)?