An electronic device or circuit which detects and indicates the various fuel levels in a fuel tank without a physical contact, through ultrasonic waves, is called an ultrasonic fuel level sensor
In this post we learn how to build a simple fuel tank level indicator circuit using Arduino and ultrasonic sensors.

In every vehicle the fuel tank is probably the most important part of the entire system, since the vehicle's operation critically depends on the presence of the tank fuel.
This also means that monitoring the fuel level in the tank becomes an essential factor for the owner or the driver of the vehicle.
Although, most vehicles are already equipped with an advanced digital fuel sensor indicator device, building your own circuit can be a lot of fun and satisfaction.
Warning: This project is only for experimental purpose. It must be done under expert supervision, if actual fuel is used for the tank fluid.
In this article we will learn how to build an LED based fuel indicator circuit using GSM wireless ultrasonic sensors and Arduino.
Ultrasonic Fuel Sensor Transmitter
To build the transmitter circuit, you will need the following modules:
- Arduino NANO - 1no
- Ultrasonic sensor module HC-SR04 - 1no
- nRF24L01 wireless Tx/Rx module - 1no
After programming the Arduino, the modules will have to wired as shown in the following diagram:

The white table at the top left shows how the pinouts of the nRF24L01 module needs to be connected with the Arduino board.
How it Works
As we can see, there are a pair of ultrasonic sensors in the module. One senor sends the ultrasonic frequency or the wave towards the fuel surface. The waves collide with the fuel surface and reflect back towards the module. The reflected ultrasonic waves are captured by the second sensor unit, and sent to the Arduino.
The Arduino compares the reflected ultrasonic time with the reference time of the tank "full height" and creates an estimation of the instantaneous height or the level of the fuel.
The information is then encoded and forwarded it to the nRF24L01 wireless module. The nRF24L01 module finally converts the code into RF signal and transmits it into the atmosphere for the receiver unit to capture the signal.
How to Mount the Sensors
Once assembled, the ultrasonic sensor will need to be installed on the fuel tank in the following manner:

The ultrasonic sensor will need to be installed by inserting the sensing heads through perfectly dimensioned holes, and sealed with appropriate sealing agent.
We can see the tank is specified with two measures, one is the full height, and the other is the maximum or the optimal fuel height inside the tank.
You will have to note these two measures as these will be required to be entered in the program code for the Arduino.
Ultrasonic Fuel Sensor Receiver
For making the fuel sensor receiver you will require the following materials:
- Arduino NANO - 1no
- Ultrasonic sensor module HC-SR04 - 1no
- nRF24L01 wireless Tx/Rx module - 1no
- LEDs as shown in the following diagram - 4nos
- Piezo buzzer - 1no
- 330 Ohm 1/4 watt resistors - 4nos
Circuit Diagram
After programming the various modules may be connected in the following manner:

Here, the nRF24L01 wireless works like a receiver. The antenna captures the RF content transmitted by the transmitter circuit, and sends it to the Arduino. As per the program code, the Arduino analyzes the varying ultrasonic time, and translates it into an incrementing digital output.
This digital output which corresponds with the instantaneous height or the level of the fuel is fed into an LED array. The LEDs in the array respond and illuminate sequentially enabling a direct visual indication of the fuel level to the owner.
The green LEDs indicate a healthy condition of the fuel content. The yellow LED indicates that the vehicle needs a refueling quickly, while the red LED indicates a critical situation, regarding the fuel about to finish. The buzzer now starts buzzing creating the necessary warning alarm.
Program Code
The complete program code for the transmitter and the receiver can be found in the following link:
https://github.com/Swagatam1975/Arduino-Code-for-Fuel-Sensor
You'll need to Change the two example values in the code with the values that you measured for your fuel tank:
// ------- CHANGE THIS -------//
float water_hold_capacity = 1.0; // Enter in Meters.
float full_height = 1.3; // Enter in Meters.
// ---------- -------------- //
Search Related Posts for Commenting
Hello Sir,
I’m very happy to find your website, it is a fantastic cache of information and is great for novices as well as more experienced technicians. I have some background in electronics, but it has been a long time since I’ve really used it, and I could use some help.
My inquiry is about the Ultrasonic Fuel Level Gauge, and I have a slight twist on the concept. I have a transceiver, DS1603L V1.0, that operates at 2Mhz, and it is capable of measuring the fluid level from below, affixed to the bottom of a metal fuel tank, with a detection range of a meter or so. It has a uart serial output, and I need to convert it to an analog voltage output for a standard 12v fuel gauge on my motorcycle. I bought it from Ebay, but they’re available on Amazon or AliExpress also.
An Arduino should be perfect for this, but I have no experience with these yet. Would you be interested in a little experiment and showing us how this might be done?
Thank you Beardly, unfortunately I too do not have an expertise in the field of Arduino, so I won’t be able to provide any help in this particular subject, although I wish I could!
Is there some form of signal smoothing, to try and eliminate signal variations due to fuel sloshing in the tank?
I don’t think that would affect the reading, because Arduino being a digital device will respond ony to the genuine peaks of the signal, and reject the lower undefined ones.
Still you can try connecting a 1uF capacitor across the ECHO pin and the ground pin.
I really appreciate your invention, but instead of the led indicators as the output signal can’t you upgrade it and use 16 x 2 LCD screen
You can upgrade it by reading the instructions as given in the following article:
https://www.homemade-circuits.com/learning-basic-arduino-programming-tutorial-for-the-newcomers/
Thank you for the Arduino code. I purchased a few of the ultrasonic modules to play with but haven’t had time until now (just retired) to work with them. You’ve given me a ‘kickstart’ and I appreciate it.
That sounds great, Glad I could help, keep up the good work!!
Hi,
Tahnks for the project.
Can you share the pcb design file for this project?
Hi, thanks, there’s no PCB for this project, because all the parts are in the form of modules, which needs to be joined with the wires.
Sir what will be the design if i simply want the circuit to measure a liquid volume using an ultrasonic sensor? I don’t have to use LED or buzzer and just a dc power supply? Hope you can help me. Thanks alot
COMMENT BOX IS MOVED AT THE TOP