Electronic fuel level sensor with hands. Making a capacitive fuel level sensor with your own hands

The digital fuel level indicator circuit is highly repeatable and even with little experience working with microcontrollers, assembly and settings, no problems will arise. To program the avr microcontroller, I assembled the simplest programmer - the so-called Gromov programmer, it is excellent for both in-circuit programming and conventional programming, an article on this programmer is on the website. Now I drive and don’t worry about refueling “will there be enough or not enough” :) Schematic diagram indicator is shown below, click to enlarge:

And now more details about this device, photographs with an installation view in my execution, and photographs and setup instructions from the original author are in this archive.

Here's what this device does:

1. Displays the remaining fuel accurate to the nearest liter, the supported tank volume is selectable from 30 to 99 liters
2. Displays the voltage of the on-board network
3. Compensates for the swing of the float in the tank by repeated (the number is selected in the menu) measurements and displaying the arithmetic average value.
4. Changes the brightness of the backlight depending on the light level, 2 modes, day/night, determined by turning on the dashboard backlight.
5. Changes the indicator display mode to normal/inverse.

List of parts of the indicator on the microcontroller:

R1 - 1 kOhm
R2 - 75 kOhm
R3 - 10 kOhm trimmer
R4 - 4.7 kOhm
R5, R6, R8-R11 - 10 kOhm
R23, R12-R15 - 3.3 kOhm
R24, R16-R19 - 1.8 kOhm
R20 - 2 kOhm * selected depending on the backlight
R21 - 240 Ohm
R22 - 1 kOhm * selected and set to constant
C1, C2, C15 - 0.01 μm
C3, C4, C6-C11, C13-C15 - 0.1 μ
C5 - 47 microns
C12 - 4.7 microns
L1 - 100 mH
DD1-LM7805
DD2 - ATMega8
DD3 - LM317T
VT1 - IRFZ44
LCD1 - Nokia 1110/1200/1110i/1112

Connector PC10 - not indicated on the diagram; buttons and pins for programming the MK are connected through it.

I decided to make two boards, one for installing the display, the second the main one, the boards are round, the case diameter is 50 mm. I couldn’t find a mating part for the indicator connector, so I wired it for the cable, unsoldered the connector from it and soldered the cable directly onto the board from the back side, placing the display itself on double-sided tape.

The main board is formally two-sided, but the reverse side is all used under the “ground”; on the reverse side only stabilizers and a transistor are installed, the remaining parts are almost all SMD installed on the track side. Holes with square “ground” pads are soldered with jumpers, the remaining holes on the “ground” side are drilled out.

The two boards are connected to each other using contacts from some long-disassembled connector. In the case, the boards are fixed with one screw; a threaded bushing is soldered under it on the main board. There are no buttons as such, they are not needed often, only during initial setup and calibration, so they are simply connected to the PC10 connector, which is located on the back of the case; unfortunately, there are no photos of it. Signals for programming the MK are also output to this connector.

Setting up the digital fuel level indicator

1. Programming of the MK is done in-circuit, using any programmer, fuses are set as follows.

2. Setting voltage readings. To configure, we connect the indicator to a voltage of 12-14 V, connect a voltmeter to the same source and use the tuning resistor R3 to set the same value as the voltmeter shows.

3. Software setup. We set the tank capacity and calibrate it. We calibrate the tank as follows, start with an empty tank, set the calibration menu to 0 liters and press OK, then fill the tank with 1 liter, set the liters value to 1 and press OK again, and so on with each liter until the tank is full. The process is certainly slow, but you only need to do it once. If you also record the sensor readings during calibration, then if you need to repeat the device or if it fails, you can enter the values ​​directly into the firmware and not have to worry about calibration. We set the remaining settings to your taste. The design was assembled and tested by Ivan Fedorov.

I decided to make a digital indicator of the amount of fuel on freight car(bus), using a standard (rather mediocre) fuel level sensor...

Read the entire creation process and what came out of it in the article below.

Initial conditions:

  • Truck (bus) with on-board voltage 24v
  • Fuel tank for diesel fuel on 220l
  • Fuel level sensor DUMP39
  • Fuel level indicator EI8057M-3

Need to:

Make a digital fuel level indicator using a standard level sensor.

First, you will have to carefully study what a standard fuel level sensor, called a fuel level sensor, is. Let's dismantle it and examine it carefully.

As you would expect, there is a float, a rod, a variable resistor... wait, more about the variable resistor. As they say, it is better to see once than to hear a hundred times:
The design is both logical and clumsy. It is logical that the slider slides not directly over the variable resistance (which is quite delicate), but along the metal taps from it, but for such an increase in reliability you have to pay for discreteness. The clumsy thing about this design is that, as can be seen in the photo, in the middle position of the float we have a fairly large “dead zone”, due to the very wide central outlet from the resistance. Why this was done, we can only guess, but what we have, we will have to work with.

So, we rummage through the Internet and look for information. Here's what I dug up:

Float movement range - 412mm

Nominal resistance - 800 Ohm (according to another source, the nominal resistance is 761.0 – 193.5 Ohm)

Operating range from -40°С to +60°С

MTBF - 400 thousand. km to 95% wasting resources

Weight 160 gram, analogue - MAZ.

In general, not a lot.

We take the tester and measure it, and in the end we get the following picture:
Connection diagram:

Measured sensor parameters:

Total resistance - 767 Ohm

Additional resistance - 187 Ohm(it provides the minimum sensor resistance).

Left (from the photo) part of the resistance - 203 Ohm (13 taps to the slider), right part Ohm 376(17 taps to the slider).

Two metal sectors above the contact group - the left sector is not used, the right one goes to the fuel reserve lamp.

In general it's like this detailed description I’m giving it only for those who are curious, but we need the voltage value that we have at the output contact at different fuel levels. With the extreme left position of the contact at the output, we got 1.57v, at the extreme right position 3.28v, half a tank - 2.44v. At the beginning of the sector of switching on the lamp of the remaining reserve 2.95v.

More for the curious. The general connection diagram for the fuel level sensor looks something like this:
Reels L1A, L1B, L2- this is a deflection system of the fuel level indicator (essentially a milliammeter). The resistor is thermal compensation.

In fact, this is a diagram of a classic electromagnetic automotive device, specifically EI8057M-3- this is something else: there is an electronic circuit inside, the arrow is driven by a stepper motor, and all this is controlled using a microcontroller PIC.

In principle, this is enough to calibrate a digital indicator, if not for a couple of troubles:

1. Specified fuel tank capacity in 220l not true, in fact the tank holds more fuel.

2. In the extreme right position of the movable contact of the sensor, when there is supposedly no more fuel in the tank, in fact the float should already be below the tank level, which is, of course, nonsense (determined by the geometry of the tank and the fuel level sensor.

3. Having measured the geometry of the tank with a tape measure, we are convinced that it is a rectangular parallelepiped with slightly rounded long edges, dimensions 40x112x60 cm. Multiplying the sides accordingly, we get an internal volume of 268 liters, which, you see, is very different from the declared 220 l, and it is very doubtful that the internal partitions, mesh, fuel intake, etc. occupy almost 50 l.

4. As already written above, the resistance of the sensor over the length of its resistance is nonlinear.

What we do:

Fill the tank full and control the voltage at the FLS output. It turns out that after reaching the mark 1.57v The tank still contains a good twenty liters of fuel.

Remove the float and put the sensor in place. Naturally, the draft, devoid of a float, goes to the very bottom of the tank, look at the voltage - it is 3.02v! This is important because in fact, in this position there is no longer any fuel in the tank, and the moving contact has not yet reached the extreme position in 3.28v, while the standard device EI8057M-3 shows what's left in the tank 1/8 volume. (Putting the float in the central position, at standard EI8057M-3 we observe instead of the required ones 1/2 tank as much 5/8 level, with a full tank the standard device goes off scale).

We look at the graph of our fuel level sensor,

Let's take three points - the resistance of the sensor, the first point is its lowest resistance (moving contact on the left) formed by additional resistance in 187 Ohm(in the photo there is a vertical black rectangle), the second point at the middle position of the contact when connected in series 187 Ohm And 203 Ohm, i.e. 390 Ohm, the total resistance will accordingly be 390 + 376 = 766 Ohms.

(horizontally - resistance in Ohms, vertically - conventional units of length)

There is nothing pleasant in this picture; the sensor seems to be linear but has a significant kink.

With such a picture, we will either get accuracy in the middle, or at the ends of the broken line, or something in between by approximating:

Having received the formula with the correction and coefficient, you can, in principle, make something similar to a digital fuel level indicator, coefficient R 2 trend lines in 0,97 Of course it’s not bad, you can, in principle, use anything greater than 0.95.

But you can get your own conversion factor for each line, which will be more accurate:
We immediately measure the ADC value at the points we need so that 5% The tolerance for the divider resistors at the ADC input did not spoil anything for us and we get it in the range of an empty tank (ADC822) before 1\2 tank (ADC700):

(horizontally the received ADC readings, vertically the volume of fuel in liters)

Ranges from 1\2 tank (ADC700) to full (ADC456):
From the above we have the following:

1. As the amount of fuel increases, the resistance of the sensor decreases and the voltage drop across it decreases.

2. The sensor voltage delta is 1.45v, that at 10 bit ADC will be 56% which is more than enough to scale the ADC result to scale 0....220l and will allow you to simply digitize the result without using OU to adjust to the desired voltage range.

The scheme is incredibly simple:

Microcontroller Mega8, LED indicator on 3 discharge with a common cathode, input divider of two resistors R1, R2. Zener diode (in bourgeois zener "zener" diode :)) to protect the input MK just in case. I didn’t draw the power circuits, they are classic 0.1uF ceramics and some kind of electrolyte 100...1000uF as well as quenching resistors between the MK and the indicator, any in the range will do 80...100Ohm depending on the MK supply voltage and the brightness of the indicator. The voltage on board the car with the engine running was 27.5v.

My board layout:
On the right side of the board I placed a power converter that provides 5v at onboard voltage 10...30v the converter is assembled on MS3406 3 according to the typical diagram from the datasheet. throttle murata 1812. The zener diode indicated in the diagram is 3.3v I screwed up when wiring and soldered on top.

Why did I apply Mega8 when there is a much more convenient one Tiny26 and so on. ? because Mega 8 available 1kB RAM, why so much? The microcontroller not only measures the voltage at the input and displays the recalculated value on the indicator, it constantly records the measured values ​​in one of 256 memory cells, filling them in a vicious circle and after recording each cell, it calculates the average value over all currently available 256 cells.

The indicator is located outside the board on the car's dashboard and is connected to it 11 wire loop. The board is placed in a tiny case (the second one, the one with 4 wire terminals); excess plastic was removed from the case with side cutters.

The board is single-sided, without jumpers:

First, I unsoldered the PWM switch and checked the work, it works. varnished. you can continue building:

P.S. The project was created with the enormous support of Roman Viktorovich, for which many thanks to him, also thanks to the man Johnson from Ukraine for mathematical help and some ideas.


Used with the original level sensor (in the tank), and instead of the standard pointer (on the dashboard).
This device (based on 16f676) displays the readings of the fuel sensor in the tank (40 l) on a two-digit seven-segment (with a common anad). Power supply from the car’s on-board network is 12 V. We connect the sensor in the tank to the “in” input.


Calibration of the device: Press the button on the device - flashing zeros will appear on the indicator, this means that our tank is empty. If it is really empty, press the button again. If not, empty it completely and press the button.
The indicator will light up 02 (2 liters) - fill in 2 liters and press the button.
After 04 lights up, fill in another 2 liters (there are already 4 liters in the tank) and press the button.
Thus, during calibration, all the values ​​​​on the indicators are in blinking mode, and by pressing the button we agree that there are actually n-liters in the tank when its value is blinking. After calibration, the display will display 40, which means 40 liters of gasoline in the tank (because that’s how it is) and the blinking will stop. The device has switched to measurement mode. We don’t touch the button anymore so as not to reset the settings. When the fuel level drops below 6 liters, the indicators start blinking, this indicates that it’s time to refuel. The kit includes firmware with different calibration steps, all working and quite accurate.
The device shows accurately in a state of rest, when gasoline is not splashing in the tank and the float is not pumping.
There were pitfalls with the selection of a 1.5 kOhm divider, but my circuit worked without problems with a resistance of 500 Ohms!





A fuel level sensor is an indispensable thing for any car. It allows you to monitor the remaining fuel in the tank in real time, and, therefore, not to stall at the most inopportune moment. The capacitive sensor is immersed in the tank, and the readings obtained from it are displayed on the instrument panel.

Types of sensors

Modern sensors are based on a potentiometric design. It is quite simple, gives accurate measurements and is affordable. Such sensors are divided into lever and tubular. But they cannot be used in all types of cars.

Advanced non-contact sensors are able to determine the volume of fuel without diving into the tank. There are several types of such devices:

  • Magnetic;
  • Radio controlled;
  • Ultrasonic.

They are quite complex in design, so they can only be manufactured in a factory. But a simple do-it-yourself capacitive contact sensor can be done by an avid radio amateur who has the skill of working with a soldering iron and understands the principles of operation of a car’s fuel system.

The main principle of operation of such a sensor is that a signal is sent for a specific fuel level value. Of course, the float does not drop immediately as soon as the fuel level goes down, but after some time. In this regard, the device may give a slight error, which also depends on the design of the tank and fluctuations in gasoline or diesel. Data is displayed on the dashboard in digital or analogue form. The digital value is more accurate and has minimal error.

How to make a capacitive sensor

The operating principle of a capacitive sensor is to compare electrical capacitance data. In essence, the device is a regular capacitor. You can make such a device by having two metal tubes or plates on hand. The manufacturing rules are as follows:

1.Both electrodes are isolated from electrical contact.

  1. When the sensor is immersed in fuel, the space between the electrodes is freely filled with fuel, and when the level drops, the electrodes remain in the air.
  2. The meter is not installed level in the tank, but slightly inclined.
  3. The power supplied to the device should not be more than 5 W, otherwise the gasoline will ignite from a spark.
  4. The circuit itself is located close to the sensor, the closer the better.
  5. The length of the wires from the circuit to the sensor should not be more than 2 cm.
  6. The capacitive sensor consists of two modules connected by three wires: the sensor module itself and the display module. Two wires supply power to the sensor module, and the third carries the signal from the sensor to the display module.

If there is a lot of fuel in the tank, then the capacity of the sensor is higher, and it takes longer to charge. This measurement principle can be implemented using a built-in microcontroller. Part of the voltage is supplied to the input by a resistive motor. When the meter receives voltage, the microcontroller turns on. When the voltage reaches the peak level, the timer starts. From the timer, data is sent to the reflection module.



error: Content protected!!