Add a clean digital gauge alongside your existing analog gauge—without losing what already works. This guide shows how to read a standard fuel-tank sender (resistive type) with an ESP32 and an INA219, convert the voltage to % full in Home Assistant, and display a needle gauge. The same pattern works for many resistive sensors (water tank, coolant temp, oil pressure, etc.).

🧭 What You’ll Build

  • ✅ ESP32 “remote hub” reading sender voltage via INA219 (I²C)
  • ✅ A Home Assistant entity for Tank Sender Voltage
  • ✅ A template that converts voltage → percentage (% full)
  • ✅ Dashboard gauge (0–100%) with color bands + alerting
  • ✅ Scales to multiple tanks (up to eight INA219 modules per ESP32)

🧰 Parts & Tools

  • ✅ ESP32 dev board (30- or 38-pin) + optional screw-terminal breakout
  • ✅ INA219 module (prefer a pre-soldered version)
  • ✅ Dupont leads (female-female; or trim one end for screw terminals)
  • ✅ 12 V→5 V DC-DC buck (boat install) or USB (bench)
  • ✅ Optional junction box + double spade adapter (to share the sender terminal)

🔩 Solder the INA219 (if required)

  1. Insert the 6-pin header (short pins into PCB) and the 2-pin VIN+/VIN− screw terminal (screws facing out).
  2. Use Blu-Tack/putty to hold parts. Heat each pin, then feed a small amount of solder. Avoid bridges.
  3. Inspect joints and ensure pins are solid.
💡 Breakout Board Tips
  • ✅ Align ESP32 pin names with the breakout before pressing in evenly.
  • ✅ Screw-terminal breakouts make engine-bay wiring much more robust.

🔧 Wire ESP32 ↔ INA219 (I²C)

  • VCC → ESP32 3.3 V (red)
  • GND → ESP32 GND (black/green)
  • SCL → ESP32 GPIO22 (brown)
  • SDA → ESP32 GPIO21 (yellow)

🧵 Tap the Tank Sender

  1. Run a single wire from the sender terminal labeled Gauge to INA219 VIN+.
  2. Share with the analog gauge if needed using a double spade adapter.
  3. (VIN− on INA219 remains part of the board’s internal measurement path; no extra wiring there.)

⚙️ ESPHome Setup (ESP32 Firmware)

  1. Open ESPHome in Home Assistant → your ESP32 → Edit.
  2. Add the INA219 configuration from here: INA219 YAML for Tank Sender Voltage
  3. Ensure the I²C pins match your wiring (SDA: 21, SCL: 22) and expose a sensor named e.g. Tank Sender Voltage with update_interval: 5s.
  4. Save → ⋮ → Validate → ⋮ → Install → Wirelessly (OTA). Open logs; with electrics on, you should see a non-zero voltage.

🧮 Convert Voltage → % Full (Home Assistant)

  1. Open your configuration.yaml (e.g., via Studio Code Server) and include the tank-level template from here: Tank Level Template YAML (voltage → percentage)
  2. Set reference points in the template:
  • volts_full — measured when the tank is full
  • volts_half — measured at half (or use volts_empty instead)

The template handles both sender directions (increasing or decreasing resistance with level) and fits a straight line between points.

  1. Developer Tools → Check configurationRestart Home Assistant.
📏 Getting Reference Points
  • ✅ Start with a reasonable guess (many marine senders sit roughly 2–7 V).
  • ✅ After a full fill-up, record volts_full; later capture volts_half or volts_empty and update the template.

📟 Dashboard Gauge & Alerts

  1. Create a new dashboard (e.g., Tank Levels) and add the entities from your ESP32.
  2. Add card → Gauge → select the tank-level percentage entity.
  • Range: 0–100 % • Style: Needle
  • Severity example: Green ≤ 80, Yellow 80–90, Red ≥ 90 (or invert for “low level” alerts as needed)
  1. Add automations for threshold alerts (siren/horn/TTS/lights/notifications).

🧪 Test & Iterate

  • ✅ Watch “Tank Sender Voltage” live; verify % moves smoothly as fuel level changes.
  • ✅ Refine reference points after the next fill and mid-trip check to improve accuracy.
  • ✅ For multiple tanks, repeat with additional INA219 modules (up to 8 on one ESP32).

🛠️ Troubleshooting

  • No reading? Check you’re on the sender’s Gauge terminal and that ESPHome shows the INA219 online.
  • Weird % behavior? Swap which reference points you use (full/half vs. full/empty) and re-measure.
  • Voltage too low/high? Confirm ESP32 is at 3.3 V and I²C wires aren’t swapped (SDA↔SCL).
⚠️ Disclaimer

The information provided is for educational purposes. Perform installations safely; consult a licensed professional for boat electrical work. Use at your own risk.

🎬 Video Transcript

Introduction

I'm Rob from Smart Boat Innovations. In this video I’ll demonstrate how to add a digital gauge alongside an existing analog gauge. I’ll focus on setting up a digital fuel-tank level gauge. The method is versatile and applies to many resistance-based sensors and analog gauges—water tank level, engine coolant temperature, engine oil pressure, and more.

Integrating existing analog gauges into our smart-boat system has several benefits. A key advantage is setting alerts when a value reaches a specific threshold. These alerts can trigger actions such as sounding an indoor siren, activating an outdoor horn, broadcasting speech over speakers, flashing lights, or sending notifications to tablets and smartphones. You can also access historical data for the sensors we digitize to track and analyze changes over time. For a fuel tank, this yields insights into fuel-consumption patterns. And finally, you get a sleek digital gauge on your SmartBoat dashboard.

For this project we’ll use the extremely versatile ESP32. It acts as a remote hub with numerous ports to connect a wide variety of sensors. In our case it connects to existing analog sensors, collects data, and transmits it wirelessly to our central system—a Raspberry Pi running Home Assistant. If you haven’t set up an ESP32, don’t worry; I have a separate quick-start video.

We’ll also use the compact INA219 device, available for about two dollars on AliExpress. It’s straightforward: connect a single wire from the INA219 to the tank sender, link the INA219 to the ESP32, and do some basic configuration in Home Assistant. With a single ESP32 we can connect up to eight INA219 devices, so if you’re following my engine-monitoring videos you can keep using the same ESP32. Let’s get started.

ESP32 and INA219 Overview

Please watch my previous video on setting up the ESP32, power supplies, and integrating with Home Assistant. I like to use a breakout board with the ESP32; it makes wiring easier and less fragile. Line up the pin numbers and names between the ESP32 and the breakout board, and press it in evenly until the pins are fully seated.

For this project we’ll use the INA219 board. It’s tiny—about the size of a finger. On the front there are six small pins, of which we’ll use four. On the other side are two screw terminals labeled VIN+ and VIN−.

Soldering INA219 Pins

Many boards no longer come pre-soldered. In the description I link to a soldered INA219; if yours isn’t soldered you’ll assemble it. Insert the six header pins into the six holes (short pins into the board, long pins facing out), and the screw terminal into VIN+ and VIN− with the screws facing outwards. Put the board on wood and use Blu-Tack or similar to hold it. Heat the pin for a couple of seconds, then touch solder to the pin so it flows. Don’t add too much and avoid bridging across pins. Do the six header pins, then the two VIN pins. Check the joints are solid.

Wiring up INA219 and ESP32

We’ll connect the INA219 to the ESP32 and the breakout board. I use Dupont cables—buy a bunch. Choose colors to match: red for 3.3 V, green/black for ground, and two different colors for the data pins—say brown (clock) and yellow (data). From left to right on the INA219: VCC (3.3 V from the ESP32), GND, SCL (clock), and SDA (data). Push the Dupont plugs onto the header; they can be tight. Since I’m landing on a breakout board, I trim one end and use the screw terminals.

Wiring Diagram

Summary: SCL → GPIO22, SDA → GPIO21, VCC → 3.3 V, GND → GND. That’s all we need between the INA219 and the ESP32.

Connect Tank Sender

Now connect the INA219 to the tank sender. Run a red wire from VIN+ on the INA219 to the sender terminal labeled Gauge. If the analog gauge is already using that terminal, use a spade double-adapter so two wires can share it—one to the analog gauge and one to the INA219. That’s all the wiring. Next we’ll configure Home Assistant.

Add to Home Assistant

In Home Assistant, open ESPHome. You should already have an ESP32 device created from the earlier video; I created one called digital_gauges. You can rename the hostname if you prefer. Open Edit; it’s the basic YAML. On my website, under Code, find the digital-gauge YAML. Copy that and paste it here. This defines the interface to the INA219 and exposes a voltage sensor. We’ll read the sender voltage and then convert it to the measured quantity—in this case, tank percentage. Save, validate, and install OTA. The logs should show the voltage (with electrics on).

Sensor Configuration

Next we correlate voltage to percentage full. I’ve written a template you can paste into configuration.yaml. It’s generalized and calculates the correlation between voltage and percentage based on a few reference points. These resistive sensors are nearly linear, so a straight-line fit works well. Provide volts_full and either volts_half or volts_empty; the template handles both directions (resistance increasing or decreasing with level). Save, check configuration, and restart Home Assistant.

Add Gauge to Dashboard

Create a dashboard called Tank Levels. Add an Entity card for the voltage if you like, then add a Gauge card for the tank level percentage. Set minimum 0 %, maximum 100 %, and choose the needle gauge. Set severities as you prefer. With this setup, you mainly need to set volts_full and volts_half/volts_empty, and ensure the sensor names match those in your ESPHome YAML.

When you first start, if you don’t know the voltage levels, make an educated guess. Many senders read in the 2–7 or 8 V range. After you fill your tank, check the actual voltage and update the template values. Do the same when the tank is half or empty, and you’ll have an accurate digital tank measurement.

Outro

Thanks for joining me and exploring the world of smart boating. If you found this helpful, please like the video, and consider subscribing for more boating and technology content. Your support helps me create more valuable videos. Until next time.