Build a digital oil-pressure monitor using an ESP32 āremote hub,ā an INA219 board over I²C, and Home Assistant/ESPHome. This guide follows every technically relevant step from the video: soldering the INA219, wiring to the ESP32, tapping the existing oil senderās āGaugeā terminal, adding INA219 in ESPHome, calibrating voltsābar from two points, creating a template sensor (in ESPHome), and adding a 0ā5 bar gauge with alerting.
š§ What Youāll Build
- ā ESP32 remote hub that can host multiple sensors (temp + oil pressure)
- ā
INA219 wired via I²C (
SCL
/SDA
) to read the sender voltage - ā Template sensor converting voltage to pressure (bar) using two calibration points
- ā Home Assistant dashboard gauge (0ā5 bar) with color severities
- ā Alerting options: indoor siren, outdoor horn, flashing lights, push notifications
- ā History trends to spot changes in engine health over time
š§° Parts & Tools
- ā ESP32 dev board + small breakout/terminal board (for sturdier wiring)
- ā INA219 breakout (with 6 header pins + VIN+/VINā screw terminal block)
- ā Dupont jumper leads (femaleāfemale; trim ends if using screw terminals)
- ā Soldering iron, solder; optional Blu-Tack/putty to hold parts while soldering
- ā Optional spade double-adapter to share the senderās āGaugeā terminal
- ā Wires, 3.3 V supply for the ESP32 (shared with existing temp sensor if present)
š© Solder the INA219 (if your board isnāt pre-soldered)
- Place the 6-pin header into the INA219ās 6 small holes (short pins into the PCB).
- Insert the 2-pin screw terminal into the VIN+ / VINā holes with the screws facing outward.
- Use putty/Blu-Tack to hold parts. Heat each pad for a couple seconds, then feed in a small amount of solder. Avoid solder bridges.
- Inspect and wiggle-check all joints so the pins are solid.
š” Breakout Board Tips
- ā Line up ESP32 pin names/numbers with the breakout before pressing in evenly.
- ā A breakout with screw terminals makes wiring more robust in an engine bay.
š§ Wire ESP32 ā INA219 (I²C)
- ā VCC on INA219 ā ESP32 3.3 V
- ā GND on INA219 ā ESP32 GND
- ā SCL on INA219 ā ESP32 GPIO22
- ā SDA on INA219 ā ESP32 GPIO21
- ā Re-use the same ESP32 from your temperature project; share 3.3 V as needed.
š ļø Tap the Engineās Oil Sender
Run a single wire from INA219 VIN+ to the oil-pressure senderās terminal labeled āGaugeā. (Other terminals you may see: āWarning Light,ā āIsolated Earth.ā) If the analog gauge is already using that terminal, use a spade double-adapter to share it: one wire to the analog gauge, one to the INA219.
Note: If you have room and prefer a dedicated sender, a T-fitting with two senders also works; this guide still applies.
āļø ESPHome Setup (ESP32 Firmware)
- Open ESPHome in Home Assistant ā your ESP32 ā Edit.
- Add the I²C section and the INA219 sensor using the snippets from the code page (donāt paste code hereāuse the link):
š smartboatinnovations.com/code/oil-pressure/ - Use GPIO21 for
SDA
and GPIO22 forSCL
as wired above. Default address and shunt value (0.1 Ī©
) are fine. - Give the bus-voltage sensor a helpful name (e.g., āOil Sender Voltageā) and set update_interval ā 5 s.
- Save ā ā® ā Validate ā ā® ā Install ā Wirelessly (OTA). Watch logs; with the engine off, āOil Sender Voltageā will likely read ~
0.0 V
.
š Calibrate: Volts ā Bar
- Add a temporary Entity card for āOil Sender Voltageā to observe live values.
- Record two points for your engine:
⢠Electrics ON, engine OFF: e.g., 0 bar at ~0.72 V (example from the video).
⢠Engine RUNNING: e.g., 3.8 bar at ~5.4 V (example from the video). - These senders are near-linear, so use a simple line between the two points. The videoās sample yields a slope of ~0.812 with an offset from the start voltage (0.72 V).
š§® Template Sensor (in ESPHome)
- From the same code page, copy the Oil Pressure template snippet (donāt inline it here; link above) and paste it at the end of your ESPHome YAML.
- Replace the constants with your two calibration values (start voltage and slope). The sample includes a small guard so pressure doesnāt go negative when the engine/electrics are off.
- Save ā Validate ā Install (OTA) again.
š Dashboard Gauge & Alerts
- Add card ā Gauge for the new oil-pressure sensor.
- Range: 0ā5 bar. Style: Needle.
- Severity (per the video demo): Green 3, Yellow 4, Red 0 (low pressure = red).
- Create automations for low pressure (sirens/horns/lights/phone notifications).
š§Ŗ Test & Iterate
With the engine running, you should see ~3.7ā3.8 bar and ~5.3ā5.4 V (as in the demo). Small variation is normal. If needed, refine your constants so the gauge matches observed behavior.
š¬ Video Transcript
Introduction
Iām Rob from Smart Boat Innovations. In this video we set up oil-pressure monitoring for our engineāour second engine-monitoring project using the super-useful ESP32 microcontroller. In the first project we set up engine-temperature monitoring with the ESP32; here weāll use the same ESP32. The ESP32 functions as a remote hub with numerous ports to connect sensors. In our case, it connects to temperature and oil-pressure sensors, collects data from them, 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 video dedicated to that. Integrating oil-pressure monitoring into our smart-boat system gives several advantages. The most important is the ability to set alerts when the pressure deviates from the optimal range. Those alerts can trigger actions such as sounding an indoor siren, an outdoor horn, flashing lights, or pushing notifications to tablets and phones.
Many engines include a built-in oil alarm, but they often arenāt loud enough. Can you hear yours while youāre up at the bow watching dolphins, or if a soft watch and inexperienced crew members are in control? With this system you also get historical data on engine pressure trends, so you can monitor and evaluate variations over time and get a clearer view of performance and health.
I spent time considering the best approach for oil-pressure monitoring. For the temperature project we added extra sensors alongside the engineās built-in one. Initially I planned a similar approach for oil pressure by introducing a separate, dedicated sender using a T-fitting so we could house two senders: the existing engine sender and another dedicated to the smart-boat system. Space constraints around my engine prevented adding the T-fitting and extra sender. Given the reliability of standard oil-pressure senders and a desire not to disturb the existing setup, I decided to use readings from the existing sender for this project. If you want to go the T-fitting route, this guide still applies.
For the measurement weāll use a compact INA219 device (about two dollars on AliExpress). The setup is straightforward: connect a single wire from the INA219 to the pressure senderās āGaugeā terminal, connect the INA219 to the ESP32, and then do some basic configuration in Home Assistant.
ESP32 and INA219 Overview
Please watch my previous video on setting up the ESP32, power supply, and integrating it with Home Assistant. I like to use a breakout board with the ESP32āit makes wiring sensors easier and the assembly less fragile. Line up the pin numbers and names between the ESP32 and the breakout board, and press the ESP32 in left-right-left-right until the pins seat fully.
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, and on the other side two screw-terminal pins labeled VIN+ and VINā.
Soldering INA219 Pins
Many boards no longer come pre-soldered. In the description I link to one that is; if yours isnāt, youāll solder it yourself. Insert the six header pins into the six holes (itās not symmetricalāthe shorter pins go into the board and the longer pins face out). Insert the screw terminal into the two VIN holes with the screws facing outwards. Put the board on a piece of wood and use Blu-Tack or similar to hold it. Heat the pin with the iron for a couple of seconds, then touch solder to the pin so it flows. Donāt add too much and donāt let it bridge across pins. Do the six header pins and then the two VIN pins. Check the joints are solid.
Wiring Up INA219 and ESP32
Weāll connect the INA219 to an ESP32 and the breakout board. I like to use Dupont (breadboard) cables; buy a bunch. I choose colors to match: red for 3.3 V, green for ground, and two different colors for the data pins (clock and data), say brown and yellow.
From left to right on the INA219: the first pin is the power pin (VCC) for 3.3 V from the ESP32, then GND, then the clock (SCL), then the data (SDA). Push the Dupont plugs onto the header; theyāre tight. Since Iām using a breakout board with screw terminals on the ESP32 side, I trim the Dupont females off that end and land the bare ends in the breakout screws. (You can also buy female-to-male jumpers.)
Connections on the ESP32 breakout: brown (clock) to GPIO22, yellow (data) to GPIO21, red to 3.3 V (shared with the temperature sensor), and green/black to GND.
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 the Oil Sender
Now connect the INA219 to the engineās oil-pressure sender. Run a red wire from VIN+ on the INA219 to the sender terminal labeled Gauge. You may also see terminals labeled Warning Light and Isolated Earth. If youāre sharing the existing sender with the analog gauge, use a spade double-adapter so two wires can share the āGaugeā terminal: one to the analog gauge, one to the INA219. Thatās the wiring complete.
Add to Home Assistant
In Home Assistant, open ESPHome. This continues from the earlier ESP32 setup and engine-temperature video. Open the ESP32 device you set up for engine monitoring and view its YAML. Weāll add more YAML: first the I²C section that declares the bus and pins (GPIO21 and GPIO22), then the INA219 platform block. The code is on my website; copy it from there rather than typing.
The I²C section defines the protocol between the INA219 and the ESP32, and the pins weāre using (21 and 22 for SDA/SCL). After that, add the INA219 sensor block. The default address is fine, the shunt resistance is 0.1 Ī© (typical), weāll read the bus voltage and name it something like Oil Sender Voltage, set maximums, and an update interval of about 5 s. Save, validate, and install OTA. Watch the logs: with nothing powered youāll see Oil Sender Voltage at 0.0 V, which is expected. Youāll also see the temperature sensor from the previous project.
Sensor Configuration & Calibration
To help calibrate, add the Oil Sender Voltage to a dashboard as a temporary card. We need a couple of points: the relationship between voltage and pressure (bar). With electrics on and engine off I get about 0.72 V, which corresponds to 0 bar. With the engine running I get about 5.4 V at around 3.8 bar. That gives two points.
These pressure senders are almost linear in resistance, so we can use basic maths to derive a simple formula. Using the two points, the slope comes out at about 0.812, and we subtract the start voltage (0.72 V). It wonāt be exact, but itās close enough to know when the engine is at normal pressure and when it deviates substantially.
Template in ESPHome
We can implement the formula in ESPHome (or as a Home Assistant template sensor). Iāll do it in ESPHome. On my website thereās a code snippet for the Oil Pressure template YAML; paste it at the end of your ESPHome YAML. Replace the constants with your values from calibration (including the small check to prevent negative values when the engine/electrics are off). Save, validate, and install OTA again.
Dashboard Gauge & Testing
Back on the dashboard, add a gauge for oil pressure. Iām using 0ā5 bar with a needle gauge. For severities I set Green at 3, Yellow at 4, and Red at 0 (low pressure red). You can add automations to alert when the bar value changesāsirens or notifications. Start the engine: I see about 3.7 bar and a voltage of ~5.3 V (previously it was 5.4 V). Engines vary a little. The calculation is based on the formula we put in the ESPHome YAML. We now have a digital oil-pressure meter; set up your alerts as needed.