Introduction: Measure Fuel Level With Arduino
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. 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.
Step 1: Theory
There are two thing you must understatnd:
This sensor have many diferent values resistors (Low level 240 ohm High level 30 ohm), that conmutes to "GND" (Not necessarily).
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
-2 2.2K resistors
-2 100ohm resistors
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
min = 295
max = 785
then map it from 0 to 100
TankValue0 = map(sensorTankValue0, 295, 785, 0, 100);