# Reading an older resistance based vehicle sensor

I want to read an oil pressure sender on an older vehicle. The sensor is grounded on the engine block and has a single wire attached to it. I understand the resistance changes as the pressure changes. I can not wrap my head around how to read that resistance with my Arduino. The Arduino would be powered from the car so would share the same ground, but where would the voltage come from? Any help would be appreciated.

Dan

The basic gauge or meter that you see in basically anything that has a needle moving across a dial is a current meter. This kind of thing:

If one end of that oil gauge is connected to 12V and the other end goes to ground via the sensor, then it will show the current through the sensor, which depends on the resistance. Change the dial calibrations to PSI and you have an oi gauge.

The easiest way to do this with an Arduino is connect 12V to the sensor via a suitable resistor. Then measure the voltage at the sensor/resistor junction on any analog pin. To choose "suitable", you need to know the maximum resistance of the sensor (highest or lowest pressure) and then calculate a resistor so that the voltage is less than 5V.

I built exactly that for my 1987 GM vehicle. I used this for my voltage divider:

Full write up is here: Arduino Current Sensor

Basically all you need to do from a hardware perspective is build that two resistor scheme on a small circuit board and splice that one wire going to the oil pressure gauge and bring it into the 12k ohm resistor (on the side that goes to the “+”).

If I recall correctly exactly 5K ohm resisters weren’t readily available at my nearby shore, I think it was 5.1K or 5.2K I used. Just get whatever is about ± 1/2 K ohm that you can; the guy that designed that divider built in a bunch of buffer.

I personally don’t like splicing wires in my car at arbitrary locations; I prefer being less intrusive incase it needs to be reversed etc. Depending on what you mean by “old”, your instrument cluster may have a cluster connector, something along the lines of this:

I researched the pin functions and then carefully pulled the pins out that I wanted to measure (I did oil pressure, fuel level, left & right signals), soldered a wire on to the back end of the pin, then snapped the pin back into the connector.

Then it’s just a matter of writing some code to compare what you get from AnalogRead() to what the gauge shows at very conditions and define a map or divisor to convert volts->reading.

I struggled a lot with Fuel level in my car. I found that a simple divisor wasn’t working because, while “420” is “fuel full”, it doesn’t drop to zero as a simple percentage. I ended up writing what I think of as an accelerated decay function to divide by a higher divisor the closer the voltage gets to zero. A map would work as well in this case. Oil pressure is pretty close with a simple integer divisor in my car.

Good luck!

Thanks guys, this clears things. I am building a system to monitor some of the basics on a 1978 GC motorhome. Did you use Arduino's built in power supply or make up a new one. I'm thinking of using a 7805 voltage regulator with some beefy capacitors to power the contraption.

@monte_carlo_ecm:
On your diagram, could you show exactly where you connected your oil pressure sensor?
TNX

Power it with a 12V to USB car phone charger. Switching regulator inside, will run much cooler and be less wasteful of your battery if left on all the time.

dandeluca21,

I like CrossRoads recommendation, nice and simple. In my case I wanted to power it from the barrel port and leave the USB available for plugging in my laptop as required and not have to switch the cable back and forth. I have to recommend against going straight from an ignition power source to the Arduino's barrel power; I popped a voltage regulator on my Arduino doing that. I built one of these:

Except I used a 7809 instead of 7805 because I'm using an Arduino Mega which specifies that it needs 7-12 volts input. It's cheaper and easier just to get a premade variable voltage converter/regulator from eBay, but if you enjoy building your own stuff from scratch then a circuit like that one works.

outsider,

You see where it says 17v Max on the diagram? Hook up where the "+" symbol is there. You can ignore the wire on the other side of that 17v Max symbol where it runs to ground, the oil pressure sender circuit will be grounded already.

Here is a super rough back of the envelope board layout for connecting the sensors. A0 - 2 are for temperature sensors. A3 is so I can measure the engine voltage and A4 is for the Oil pressure sensor.

I would be very careful bringing wires from the car electrical system into a processor board without some signal conditioning on them. Automotive electrical systems are notorious for all sorts of strange spikes etc. (starters are notorious for spikes). I don't know just what the input impedance of the Arduino is (just starting to play with them), but my preference would be a resistor in series with the input, a ceramic capacitor from the input to ground and a clamp diode. All of this should be close to the board itself - the RC combination helps isolate and absorb spikes as well as smoothing the signal. I'm guessing 1 or 2k ohms for the series resistor, but you need to look at the specs for the Arduino and see what the input impedance is for the ADC.

dandeluca21,

That's how I did it for Oil Pressure. I have to agree with gpsmikey, especially if you're going to try to measure the car's supply voltage. I'm measuring my car's supply voltage via my (hacked OEM) ECM so I don't have hands on experience measuring that directly. For oil pressure, fuel, and turn signals, I'm using only the two resistor voltage divider scheme as you've drawn it without any other components. So far it's working okay (a few months now), but I am accepting the risk that I may blow my analog pins or worse at some point. If you aren't going to heartbroken having to buy another Arduino board should it pop, you could try the simpler way first.

Hello,

I have built my prototype board and written my program, everything is complete except for the Oil pressure component. As I visit this thread I once again confused how @monte_carlo_ecm method functions. The single wire returning from the sender will simply have 12V. That will not change as the resistor of the sensor changes, what will change is the current flowing through that wire. The Arduino can not read that current unless I add more than just a voltage divider.

Still not wrapping my head around this

Actually, the voltage from across the sender should change. The gauge itself provides the other "half" of the voltage divider circuit if you will. It is measuring the current through the gauge AND the sender. If they simply provided 12v with no current limit to the sender it would be at serious risk of catching fire etc. at the low resistance point (without testing the sender or a spec sheet, I don't know what the resistance range of the sender is - I know on the fuel sender for my truck, it will vary from about 130 ohms down to about 3 ohms according to the shop manual). Measure the voltage at the terminal on the sender with the ignition on, but the engine not running. Measure the same point with the engine running (keeping fingers and probes clear of moving stuff in there - they can bite!!). That should give you an idea of what you are dealing with. I assume in all this discussion, you have an oil pressure gauge and not just a light correct? (a light would just have an oil pressure switch not a variable resistance sender)

I understand now. I know the sensor resistance varies from close to 0 ohms to about 90 ohms at full pressure. (I bench tested a replacement sensor.) The wire that runs to the sensor should have resistance, but I don't know what that resistance is.

This is the part I did not realize that the gauge has a resistance.

I am assuming the gauge provides a relatively steady resistance, creating the voltage divider Once I know what the resistance of the gauge is, I can calculate the pressure.

For the purposes of this discussion, the resistance of the wire from the gauge to the sender should be 0 ohms (it is actually more like 1/2 ohm or something, but it is a very small part of the equation). Measure the voltage as I indicated then you can decide what sort of conditioning you need to do from the sender wire to the Arduino (probably a resistive divider with a capacitor to provide a low pass filter as well as lowering the voltage). You want the input to the Arduino to be probably less than 4 volts or so (gives you a safety margin assuming you are using a 5volt unit). If they connected 12volts direct to the sender, when it was at the "close to 0 ohms" you measured, you would either fry the sender or the wire to it so there is definitely some other resistance in the circuit - most of it should be in the gauge.