Automating Water Tank Monitoring with LoRa and ESPHome

Learn how to build a reliable wireless water tank monitoring system using LoRa technology, eliminating long cable runs and enabling automatic pump control.

Amit Sharma

November 7, 2025

šŸ“– 9 min read•#Water Automation, #LoRa, #ESPHome, #IoT

Automating Water Tank Monitoring with LoRa and ESPHome

Water tank monitoring is a common challenge in many households and buildings, especially with overhead tanks on rooftops or underground sumps in basements. Running cables hundreds of meters for sensors is expensive and impractical. This is where LoRa (Long Range) wireless technology combined with ESPHome offers an elegant solution.

The Problem

Traditional water level monitoring faces several challenges:

Cable Run Issues

  • Distance: Overhead tanks can be 50-200 meters from control panels
  • Cost: Long cable runs are expensive (₹50-100 per meter)
  • Installation: Running cables through walls, ceilings is difficult
  • Maintenance: Cable damage from weather, rodents

Manual Monitoring Problems

  • Forgetting to check water level
  • Pump running dry (motor damage)
  • Overflowing tanks (water wastage)
  • No visibility into water usage

Existing Solutions Limitations

  • Float switches: Mechanical, unreliable, only 2 levels
  • Wired sensors: Expensive cable installation
  • Cloud-based systems: Require internet, subscription fees
  • Proprietary systems: Vendor lock-in, expensive

The MotorWala Solution

MotorWala uses LoRa (Long Range) wireless technology to solve these problems:

Overhead Tank (Rooftop)
   ↓ LoRa 433MHz (up to 500m)
   ↓ No cables needed!
   ↓
Hub (Inside house)
   ← OLED display
   ← Home Assistant
   ↓ LoRa 433MHz
   ↓
Pump (Basement)
   ← Flow sensor
   ← Relay control

System Components

1. Hub (Inside House)

  • ESP32 with WiFi and LoRa radio
  • OLED display showing real-time status
  • Home Assistant integration
  • Makes pump control decisions

2. Tank Sensor (Remote - Rooftop)

  • ESP32 with LoRa radio
  • Ultrasonic water level sensor
  • Battery powered (6+ months life)
  • Transmits data wirelessly

3. Pump Controller (Remote - Basement)

  • ESP32 with LoRa radio
  • Flow rate sensor
  • 10A relay for pump control
  • Receives commands wirelessly

Why LoRa?

LoRa (Long Range) is perfect for this application:

Range

  • Up to 500 meters line-of-sight
  • Penetrates walls and floors
  • Works through multiple stories
  • No expensive WiFi repeaters needed

Power Efficiency

  • Tank sensor: 6-12 months on battery
  • Low power transmission (6.3mW)
  • Deep sleep between measurements
  • No constant WiFi connection needed

Reliability

  • 433MHz frequency - less congested than 2.4GHz
  • CRC error checking
  • Encrypted packets (AES)
  • Automatic retransmission

Cost

  • No cable installation costs
  • No monthly fees
  • No internet required
  • One-time hardware cost

How It Works

Water Level Monitoring

The ultrasonic sensor measures distance from sensor to water surface:

Sensor → |←─ 100mm ─→| Water Surface
         |              |
Tank     |              | 330mm total height
Height   |              |
         |←─── 230mm ──→| Bottom

Calculation:

Water Level % = 100 - (distance / tank_height Ɨ 100)
Example:
- Tank height: 330mm
- Measured distance: 100mm
- Water level: 100 - (100/330 Ɨ 100) = 70%

The sensor reading is transmitted via LoRa every second to the Hub.

Automatic Pump Control

Hub receives data and makes intelligent decisions:

IF tank_level < 95% (configurable)
  AND flow_sensor working
  AND no sensor errors
THEN
  Turn pump ON via LoRa command
ELSE
  Turn pump OFF

Safety Features:

  • Pump turns OFF if no flow detected (dry run protection)
  • Pump turns OFF if sensor fails (fail-safe)
  • Configurable trigger level (default 95%)
  • Maximum run time monitoring

Real-time Display

Hub shows status on OLED display (rotates every 5 seconds):

Page 1 - Tank Level:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│      šŸ’§         │
│                 │
│      75%        │
│                 │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Page 2 - Last Run Duration:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│      ā±ļø         │
│                 │
│     450s        │
│                 │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Page 3 - Last Fill Time:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│      šŸ•         │
│                 │
│   14:30         │
│                 │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Page 4 - Pump Status:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│      āš™ļø         │
│                 │
│      ON         │
│                 │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Real-World Installation Example

Scenario: 3-Story House with Overhead Tank

Setup:

  • Ground floor: Pump and sump tank
  • Third floor: Overhead tank on roof
  • Living room: Hub with display
  • Distance: ~30 meters vertically, 15 meters horizontally

Installation Steps:

1. Tank Sensor (30 minutes)

  • Mount ultrasonic sensor in tank lid
  • Point sensor straight down at water
  • Power with 12V adapter or battery
  • No cables to run downstairs!

2. Hub (15 minutes)

  • Place in living room near TV
  • Connect to WiFi
  • Display shows tank status immediately
  • Add to Home Assistant

3. Pump Controller (20 minutes)

  • Install near existing pump
  • Connect flow sensor to water pipe
  • Wire relay to pump contactor
  • No cables to run upstairs!

Total Installation: 65 minutes vs 4-6 hours for wired system!

Results

Before Automation:

  • Manually checking tank: 3-4 times daily
  • Forgot to turn pump off: 2-3 times/week
  • Tank overflows: Once every 2 weeks
  • Pump runs dry occasionally
  • No usage tracking

After Automation:

  • Zero manual intervention needed
  • Never run out of water
  • Never overflow
  • Pump protected from dry running
  • Track daily water consumption
  • Home Assistant alerts for issues

Cost Savings:

  • No cable installation: Saved ₹5,000
  • No electrician needed: Saved ₹2,000
  • Water saved (no overflows): ~500L/month
  • Pump lifespan extended (no dry runs)

Home Assistant Integration

Once Hub is added to Home Assistant, you get:

Dashboard

type: entities
title: Water Tank
entities:
  - sensor.tank_filled
  - binary_sensor.pump
  - sensor.last_duration
  - number.tank_limit

Automations

Alert when tank low:

automation:
  - alias: "Low Water Alert"
    trigger:
      - platform: numeric_state
        entity_id: sensor.tank_filled
        below: 15
    action:
      - service: notify.mobile_app
        data:
          message: "Tank only 15% full - check pump"

Daily water usage:

automation:
  - alias: "Daily Usage Report"
    trigger:
      - platform: time
        at: "20:00:00"
    action:
      - service: notify.mobile_app
        data:
          message: >
            Today's water usage:
            Tank filled {{ states('sensor.last_duration') }}s
            (approximately {{ (states('sensor.last_duration')|int * 0.5)|int }} liters)

Pump running too long:

automation:
  - alias: "Pump Alert"
    trigger:
      - platform: state
        entity_id: binary_sensor.pump
        to: "on"
        for:
          minutes: 30
    action:
      - service: notify.mobile_app
        data:
          message: "āš ļø Pump running >30min - possible leak?"

Configuration Highlights

Hub Configuration

Key parts of the ESPHome YAML:

LoRa Setup:

sx127x:
  frequency: 433920000  # 433.92 MHz
  pa_power: 8           # 6.3mW power
  bandwidth: 125_0kHz
  spreading_factor: 7
  encryption: true

Packet Transport:

packet_transport:
  platform: sx127x
  update_interval: 1s
  providers:
    - name: "motorwala-tank-001"
      encryption: "TankSecretKey"
    - name: "motorwala-pump-001"
      encryption: "PumpSecretKey"

Tank Level Calculation:

sensor:
  - platform: template
    name: "Tank Filled"
    lambda: |-
      return 100.0 - (id(distance).state * 100.0 / float(id(tank_height)));
    unit_of_measurement: "%"

Pump Control Logic:

binary_sensor:
  - platform: template
    name: "Pump"
    lambda: |-
      if (isnan(id(distance).state) || id(flow).state <= 0)
        return false;  // Safety: OFF if sensor fails

      float empty_pct = id(distance).state * 100.0 / id(tank_height);
      float fill_pct = 100.0 - empty_pct;

      if (fill_pct < id(tank_limit))
        return true;   // Turn ON if below limit
      else
        return false;  // Turn OFF if above limit

Troubleshooting Tips

Sensor Reading Erratic

Problem: Tank level jumping around

Solutions:

  1. Check sensor mounting

    • Must point straight down
    • Not at angle
    • Clear path to water
  2. Increase filtering:

    filters:
      - sliding_window_moving_average:
          window_size: 10
    
  3. Account for foam:

    • Foam causes false readings
    • Install baffle plate to calm surface

LoRa Connection Drops

Problem: Hub loses connection to tank/pump

Solutions:

  1. Check antenna

    • Use external antenna
    • Mount vertically
    • Away from metal
  2. Increase power:

    sx127x:
      pa_power: 20  # Max power
    
  3. Reduce data rate (increase range):

    sx127x:
      spreading_factor: 10  # Slower but longer range
    

Pump Not Responding

Problem: Tank low but pump doesn't start

Solutions:

  1. Check flow sensor

    • Must detect water flow
    • Clean sensor if clogged
  2. Verify relay

    • Test manual control in Home Assistant
    • Check relay coil power (12V)
  3. Review logs:

    esphome logs motorwala-hub-001.yaml
    

Cost Breakdown

MotorWala System

  • Hub + Tank + Pump: ₹8,999
  • Power supplies: ₹500
  • Installation (DIY): Free
  • Total: ₹9,499

Traditional Wired System

  • Sensors: ₹2,000
  • Cables (100m): ₹5,000
  • Conduit/fittings: ₹1,500
  • Controller: ₹3,000
  • Electrician: ₹3,000
  • Total: ₹14,500

Savings: ₹5,001 + easier installation!

Advanced Features

Multiple Tanks

Monitor multiple tanks with one Hub:

Hub (Living Room)
  ā”œā”€ LoRa → Tank 1 (Overhead)
  ā”œā”€ LoRa → Tank 2 (Underground Sump)
  └─ LoRa → Pump

Battery Powered Sensors

For truly wireless installation, run Tank sensor on battery:

deep_sleep:
  run_duration: 5s      # Wake for 5s
  sleep_duration: 300s  # Sleep for 5min

Battery Life: 1-2 years on 2000mAh

Water Usage Tracking

Track water consumption over time:

sensor:
  - platform: integration
    name: "Daily Water Usage"
    source: sensor.flow_rate
    unit_of_measurement: "L"

Creates graph in Home Assistant showing usage patterns.

Comparison with Alternatives

| Feature | MotorWala (LoRa) | WiFi System | Wired System | Float Switch | |---------|------------------|-------------|--------------|--------------| | Range | 500m | 30-50m | Unlimited* | 0m (in tank) | | Cable Cost | ₹0 | ₹0 | ₹5,000+ | ₹3,000+ | | Battery Life | 1-2 years | Days | N/A | N/A | | Installation | Easy | Easy | Hard | Medium | | Levels | Continuous | Continuous | Continuous | 2 levels only | | Cloud Required | No | Often Yes | No | No | | Monthly Fee | ₹0 | ₹0-500 | ₹0 | ₹0 |

*Wired requires long, expensive cable installation

Safety Considerations

Electrical Safety

  • Use external relay for AC pumps (don't wire directly)
  • Fuse all power supplies
  • Keep controllers away from water
  • Consult electrician for AC installations

Operational Safety

  • Set up low-water alerts
  • Monitor pump runtime
  • Manual override always available
  • Test system monthly

Data Security

  • LoRa packets are encrypted (AES)
  • API encryption between ESPHome and Home Assistant
  • Local control only (no cloud)
  • Change default encryption keys

Conclusion

Water tank automation with LoRa solves the traditional challenge of long cable runs while providing:

āœ… Wireless - No expensive cable installation āœ… Long Range - Up to 500 meters āœ… Low Power - Battery lasts 1-2 years āœ… Reliable - Encrypted, error-checked communication āœ… Smart - Automatic pump control with safety features āœ… Local - No cloud, no subscriptions āœ… Open Source - ESPHome, customizable

Whether you have an overhead tank on the roof, an underground sump, or both, MotorWala provides a cost-effective, reliable solution for automatic water management.

Ready to automate your water system? Check out MotorWala or browse the full YAML configurations to build your own!


Have questions about water tank automation? Join our community forum or contact us.

Share this article

Amit Sharma

Writer and automation enthusiast at Wala Works, passionate about open-source solutions and smart home technology.