Measure Fuel Level With Arduino

25,696

27

16

Introduction: Measure Fuel Level With Arduino

About: My experience in the field of electronics led me to discover the existence of open hardware and software, in all the years that followed that discovery I just started to develop my own technologies and advise …

The sensing unit usually uses a float connected to a potentiometer, typically printed ink design in a modern automobile. As the tank empties, the float drops and slides a moving contact along the resistor, increasing its resistance.[2] In addition, when the resistance is at a certain point, it will also turn on a "low fuel" light on some vehicles.

Meanwhile, the indicator unit (usually mounted on the dashboard) is measuring and displaying the amount of electric current flowing through the sending unit. When the tank level is high and maximum current is flowing, the needle points to "F" indicating a full tank. When the tank is empty and the least current is flowing, the needle points to "E" indicating an empty tank.

The digital fuel gauge in a 2012 Hyundai Elantra showing a full tank along with a distance to empty display.

The system can be fail-safe. If an electrical fault opens, the electrical circuit causes the indicator to show the tank as being empty (theoretically provoking the driver to refill the tank) rather than full (which would allow the driver to run out of fuel with no prior notification). Corrosion or wear of the potentiometer will provide erroneous readings of fuel level. However, this system has a potential risk associated with it. An electric current is sent through the variable resistor to which a float is connected, so that the value of resistance depends on the fuel level. In most automotive fuel gauges such resistors are on the inward side of the gauge, i.e., inside the fuel tank. Sending current through such a resistor has a fire hazard and an explosion risk associated with it. These resistance sensors are also showing an increased failure rate with the incremental additions of alcohol in automotive gasoline fuel. Alcohol increases the corrosion rate at the potentiometer, as it is capable of carrying current like water. Potentiometer applications for alcohol fuel use a pulse-and-hold methodology, with a periodic signal being sent to determine fuel level decreasing the corrosion potential. Therefore, demand for another safer, non-contact method for fuel level is desired.

Wikypedia

Step 1: Theory

There are two thing you must understatnd:

Magnetic switch:

This sensor have many diferent values resistors (Low level 240 ohm High level 30 ohm), that conmutes to "GND" (Not necessarily).

Ohms law:

if we can apply a fixed voltage and a fixed resistor we can apply the Ohms law.

and measure the voltage in any given level, so we transfom digital commuting analogic.

Step 2: Schematics-materials

-Arduino Nano

-Oled Display

-Breadboard

-Level Sensor

-2 2.2K resistors

-2 100ohm resistors

https://tuppens.com/kus-wema-fuel-water-tank-level...

Step 3: Program

The program basicaly takes a measured value from 0-1023

we first take notice what value we get at the low level and the high level

i got

min = 295

max = 785

then map it from 0 to 100

Like this.

TankValue0 = map(sensorTankValue0, 295, 785, 0, 100);

Attachments

Step 4: Test

Be the First to Share

    Recommendations

    • Recycled Speed Challenge

      Recycled Speed Challenge
    • Make it Move Contest 2020

      Make it Move Contest 2020
    • Build a Tool Contest

      Build a Tool Contest

    16 Discussions

    0
    jyoti.dhatarwal1999
    jyoti.dhatarwal1999

    4 months ago

    can you tell me the pinout of the fuel sensor,like which pin is connected to which?

    0
    ivan.a.daniel
    ivan.a.daniel

    Reply 3 months ago

    Hello
    The (VCC, 5v) goes to the positive side of the fuel sensor. The negative side of the sensor will have one side of the 100 ohm resistor connected to it. The other end of the resistor is connected to ground.

    The junction (where they are joined)of the resistor and the sensor is connected to A0 on the Arduino.

    Hope this helps

    0
    zuhdiifadhlurrohman
    zuhdiifadhlurrohman

    4 months ago

    hello, how to make with arduino uno? please help me.

    0
    jmorles
    jmorles

    Reply 4 months ago

    It's just the same thing, copy the code compile and download!

    0
    Swierio
    Swierio

    2 years ago

    Can’t download the code on my ipad. Do you know why?

    0
    jmorles
    jmorles

    Reply 10 months ago

    Do you use winrar
    the code is this one

    #include "SSD1306Ascii.h"
    #include "SSD1306AsciiAvrI2c.h"
    SSD1306AsciiAvrI2c oled;
    #define I2C_ADDRESS 0x3C

    int TankValue0;
    int TankValue1;

    void setup() {
    Serial.begin(9600);
    oled.begin(&Adafruit128x64, I2C_ADDRESS);
    oled.setFont(System5x7);
    oled.clear();
    }

    void loop() {
    int sensorTankValue0 = analogRead(A0);
    int sensorTankValue1 = analogRead(A1);
    TankValue0 = map(sensorTankValue0, 295, 785, 0, 100);
    TankValue1 = map(sensorTankValue1, 295, 785, 0, 100);
    if (TankValue0 < 0) {
    TankValue0 = 0;
    }
    if (TankValue1 < 0) {
    TankValue1 = 0;
    }
    if (TankValue0 > 100) {
    TankValue0 = 100;
    }
    if (TankValue1 > 100) {
    TankValue1 = 100;
    }
    oled.print("T0=");
    oled.print(TankValue0);
    oled.println(" ");
    oled.print("T1=");
    oled.print(TankValue1);
    oled.println(" ");
    oled.setCursor(0, 0);
    }

    0
    JothikannanC
    JothikannanC

    2 years ago

    How about the flammable fuels? if the sensors produce heat/current it would make fire isn't it?

    0
    jmorles
    jmorles

    Reply 10 months ago

    The fuel sensor is suitable for it

    0
    jmorles
    jmorles

    Answer 10 months ago

    #include "SSD1306Ascii.h"
    #include "SSD1306AsciiAvrI2c.h"
    SSD1306AsciiAvrI2c oled;
    #define I2C_ADDRESS 0x3C

    int TankValue0;
    int TankValue1;

    void setup() {
    Serial.begin(9600);
    oled.begin(&Adafruit128x64, I2C_ADDRESS);
    oled.setFont(System5x7);
    oled.clear();
    }

    void loop() {
    int sensorTankValue0 = analogRead(A0);
    int sensorTankValue1 = analogRead(A1);
    TankValue0 = map(sensorTankValue0, 295, 785, 0, 100);
    TankValue1 = map(sensorTankValue1, 295, 785, 0, 100);
    if (TankValue0 < 0) {
    TankValue0 = 0;
    }
    if (TankValue1 < 0) {
    TankValue1 = 0;
    }
    if (TankValue0 > 100) {
    TankValue0 = 100;
    }
    if (TankValue1 > 100) {
    TankValue1 = 100;
    }
    oled.print("T0=");
    oled.print(TankValue0);
    oled.println(" ");
    oled.print("T1=");
    oled.print(TankValue1);
    oled.println(" ");
    oled.setCursor(0, 0);
    }

    0
    Che-YuL1
    Che-YuL1

    11 months ago

    Hi, thank you for the instruction!
    In the Schematics-materials says need two 100ohm resistors, however I can only find one used, what's another?
    Also, what does the A1 pin do? I see it connects to the sender negative, and have no value to display?
    Thanks for answering!

    0
    jmorles
    jmorles

    Reply 10 months ago

    There is only one, surely it is a mistake of mine, A1, it really is for another sensor.

    0
    Shahab-ulI
    Shahab-ulI

    Question 2 years ago

    Can you plz tell me formula to calculate different values like max and min values

    0
    jmorles
    jmorles

    Answer 2 years ago

    i used the map function, but first i use a voltmeter sketch, then i map from higher to lowest, usually the lowest is cero, the one that may varies is the high level.