reading car's fuel gauge signal with arduino uno

Hello! Im new with arduino and wanna ask for help. My goal is to read analog values from fuel float and print values on the display which would be driven by arduino.

Im using arduino uno. My car has 2 wires going to dash (gnd and signal). AFAIK, arduino could accept only 5V on i/o ports… Im thinking about using voltage divider but not sure how? between gnd and signal wires?? My fuel gauge works by reading resistance, so somehow i need to read resistance from signal wire if im correct?

My wiring concept is:

Car’s manual says:


It looks like the tank sensor is sending a signal to the ECU which then sends a signal to the fuel gauge. While they present Ohms the reality is a voltage based on resistance. The tank sensor is likely getting some excitation and sending a voltage proportional to fuel level in the tank.

Also where they mention Ohms note that a full tank is about 0 to 6 Ohms and an empty tank 295 to 315 Ohms which tells me the tank out is not linear. If I say 0 Ohms is full and 300 Ohms is empty then 150 Ohms would be 1/2 tank which it isn't.

What you need to do is actually get the voltages and see what they actually are then worry about voltage dividing if necessary and finally map the non linear voltages to a tank level.

Ron

Now i've checked resistance of those 2 wires, it was ~140ohms (fuel level in the tank is less than 1/2, so readings are correct). Now im thinking to connect ground wire to arduino ground and signal wire to arduino's analog pin?

the voltage between +12v and signal wire is 0.1V, so it's safe to connect directly to arduino. Thanks!

You want to measure between the signal wire and ground. The analog input(s) of an Arduino are 0 - 5 Volts max. That assumes running it on 5 V and using the 5 V reference. If between ground and your signal wire it exceeds 5 volts then you need a simple divider. YOu also need to see if the signal is non-linear.

Ron

void setup()
{
 Serial.begin(2400);
pinMode(A0,INPUT_PULLUP);
}
void loop()
{ 
  int val = analogRead(A0);
  val = map(val, 0, 1023, 0, 315);
  Serial.println(val);
}

Tried this code, but getting ~310 readings (instead of ~140).. Connected signal wire to arduino A0 and signal gnd to arduino gnd

If you wanted to do it like that the code would look more like this:

 int analogPin = A0;      
 int Ohms = 0;                     
 int val = (A0);           

void setup()
{
  Serial.begin(2400);          //  setup serial
}

void loop()
{
  int val = analogRead(0);
  val = map(val, 0, 1023, 0, 315);
  Serial.println(val);             // debug value
  Serial.print ("Ohms =  ");
  Serial.print (val);
  Serial.println(); 
  delay(1000);
}

So we say 0 to 315 Ohms but that assumes linearity which the fuel sensor is not. What that tells me is using those numbers is that 157.5 Ohms is 1/2 tank of gas and we know it is not. Half tank is about 116 to 126 with a nominal of about 121 Ohms.

When the numbers are not linear we call them logarithmic. Not quite a straight line equation.

The Arduino uses a 10 bit ADC or 2^10 = 1024 meaning with the Arduino 5 Volt Ref (normally not very accurate) an analog input of 0 to 5 volts = 0 to 1023 bits which is 1025 quantization levels. So what the code is doing is looking at A0 assigning a range of 0 to 1023 and then mapping it to 0 to 315. That's all the code is doing. I apply 1.5 volts and I see 117 Ohms with the code I just posted. I apply 5 volts and get 315.

Ron

Ron

Ron_Blain:
If you wanted to do it like that the code would look more like this:

 int analogPin = A0;      

int Ohms = 0;                   
int val = (A0);

void setup()
{
  Serial.begin(2400);          //  setup serial
}

void loop()
{
  int val = analogRead(0);
  val = map(val, 0, 1023, 0, 315);
  Serial.println(val);            // debug value
  Serial.print ("Ohms =  ");
  Serial.print (val);
  Serial.println();
  delay(1000);
}




So we say 0 to 315 Ohms but that assumes linearity which the fuel sensor is not. What that tells me is using those numbers is that 157.5 Ohms is 1/2 tank of gas and we know it is not. Half tank is about 116 to 126 with a nominal of about 121 Ohms. 

When the numbers are not linear we call them logarithmic. Not quite a straight line equation. 

The Arduino uses a 10 bit ADC or 2^10 = 1024 meaning with the Arduino 5 Volt Ref (normally not very accurate) an analog input of 0 to 5 volts = 0 to 1023 bits which is 1025 quantization levels. So what the code is doing is looking at A0 assigning a range of 0 to 1023 and then mapping it to 0 to 315. That's all the code is doing. I apply 1.5 volts and I see 117 Ohms with the code I just posted. I apply 5 volts and get 315.

Ron

Ron

One thing isn't clear for me, it's wiring. I need to connect signal wire to one of arduino's analog pins and that's all? gnd and signal wires are connected to car's chassis.

Probably i need to make voltage divider, connect +12v trough divider to arduino, then connect signal ground to arduino's ground and signal wire to analog pin?

What you need to do is use a meter and take some measurements. Then worry about the need for a voltage divider. Ground is chassis ground in automotive and the signal wire is just that. Ground to ground and signal to your A0 pin assuming it is a voltage and that voltage does not exceed 5 volts.

Many automotive sensors work on 5.0 volts provided by the ECU. You have no idea what your signal is so measure it.

Ron

I’m not getting any volts from gnd and signal wire. Except if I attach multimeter’s one wire to +12 and other to signal wire, then multimeter reads 0.1V.

Tried connect to arduino A0 with 10k voltage divider and use signal as second resistor, kinda worked while car’s stock fuel gauge was unplugged… Resistance between signal and car’s chassis 1174ohms, between signal gnd and signal wire 140ohms. If i connect stock car gauge, then signal resistance to chassis 570ohms.

While car gauge was unplugged with 10k resistor i was able to read ~249 in arduino which stands for 1.42V (checked with multimeter, correct). But when i plug into circuit fuel gauge back, arduino reads random values and voltage becomes 0.64V (because resistance changes from 1174 to 570).

Still not sure why can’t just connect signal gnd to arduino gnd and signal to A0

In order not to load down the signal coming from the sensor you should probably run it though an op-amp buffer. Then you can do whatever you want with it.

Are you measuring from the tank or to the indicator? My read was that the ECM reads the tank and sends a signal to the indicator. Resistors alone do not make a signal, they require excitation. If the tank sensor acts like a pot then one wire will be a fixed excitation and the other the signal return assuming chassis ground. The 140 Ohms could make sense depending on how much fuel is in the tank.

Ron

Here's a completed project to lock at https://www.instructables.com/id/Measure-Fuel-Level-With-Arduino/

Billhigdon:
Here’s a completed project to lock at https://www.instructables.com/id/Measure-Fuel-Level-With-Arduino/

Yeah and what they don’t show is someone on their back under the car dropping the fuel tank to install the sensor. :slight_smile:

Ron

You don't need to install anything, you use the sending unit/sensor that's already in the tam. The one they picture is one they used for development.

I appologize, they don't use the on in the tank already. Grr

Here's a link to a more complicated one that uses the fuel level sensor that's already in the tank

Here's a link to another that uses the sensor that's already in the tank

Billhigdon:
You don't need to install anything, you use the sending unit/sensor that's already in the tam. The one they picture is one they used for development.

They are not all the same. Different sensors output different signals. Wife has a Jeep and I have a GMC truck. They use different sensors to send different signals to the ECU which in turn sends signals to the gauges on the dashboard. So even the code won't be the same. While I can appreciate it was a demo it really didn't say much.

Ron