Smart Boat 19: Digital Gauges with ESP32 and INA219

3 min read 4 hours ago
Published on Oct 10, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of adding a digital fuel tank level gauge using an ESP32 and an INA219 module. This method is adaptable for various analog gauges, making it useful for monitoring other variables like water tank levels or engine temperatures. By the end of this tutorial, you will have a functional digital gauge that you can integrate into your existing setup.

Step 1: Gather Required Materials

Before starting, ensure you have the following components:

  • ESP32 (preferably 38-pin model)
  • INA219 module
  • 12V to 5V converter
  • Dupont breakout cables
  • Junction box (80mm x 80mm)
  • Tank sender (resistance-based sensor)

You can purchase these components from Amazon or AliExpress using the provided links in the video description.

Step 2: Solder the INA219 Module

  • Prepare the INA219: Use a soldering iron to attach the necessary pins to the INA219 module. Ensure a solid connection for reliable data transmission.
  • Check Connections: Verify that all pins are soldered correctly and securely before moving on to wiring.

Step 3: Wire the INA219 to the ESP32

  • Connect Power: Use the 12V to 5V converter to power the ESP32.
  • Wiring:
    1. Connect the VCC pin of the INA219 to the 5V pin on the ESP32.
    2. Connect the GND pin of the INA219 to the GND pin on the ESP32.
    3. Connect the SDA and SCL pins of the INA219 to the corresponding SDA and SCL pins on the ESP32.

Refer to the wiring diagram provided in the video for clarity.

Step 4: Connect the Tank Sender

  • Identify Tank Sender Wires: Locate the wires from your resistance-based tank sender.
  • Connect to INA219:
    1. Connect one wire to the output of the INA219.
    2. Connect the other wire to the ground.

Ensure that the sender is properly calibrated to match the gauge's range.

Step 5: Setup Home Assistant

  • Install Home Assistant: Make sure you have Home Assistant installed on your device.
  • Add Sensor: In Home Assistant, navigate to the configuration settings and add the INA219 sensor to monitor the fuel level.
  • Check Configuration: Ensure that the sensor is correctly configured to read data from the INA219.

Step 6: Configure the Sensor

  • Edit Configuration File: Access your Home Assistant configuration file to define the INA219 sensor parameters.
  • Example Configuration:
    sensor:
      - platform: ina219
        name: "Fuel Level"
        address: 0x40
    
  • Restart Home Assistant: After editing, restart Home Assistant to apply the changes.

Step 7: Add Gauge to Dashboard

  • Open Dashboard: Navigate to your Home Assistant dashboard.
  • Add New Card: Click on the option to add a new card.
  • Select Gauge: Choose the gauge card type and configure it to display the fuel level from your INA219 sensor.
  • Customize Display: Adjust the appearance and labels to suit your preferences.

Conclusion

You have successfully set up a digital fuel tank level gauge using an ESP32 and INA219 module. This setup can be adapted for various applications involving resistance-based sensors. Next steps could include expanding your monitoring system to include additional sensors or integrating more features into your Home Assistant dashboard. Happy tinkering!