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:
-
Check sensor mounting
- Must point straight down
- Not at angle
- Clear path to water
-
Increase filtering:
filters: - sliding_window_moving_average: window_size: 10 -
Account for foam:
- Foam causes false readings
- Install baffle plate to calm surface
LoRa Connection Drops
Problem: Hub loses connection to tank/pump
Solutions:
-
Check antenna
- Use external antenna
- Mount vertically
- Away from metal
-
Increase power:
sx127x: pa_power: 20 # Max power -
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:
-
Check flow sensor
- Must detect water flow
- Clean sensor if clogged
-
Verify relay
- Test manual control in Home Assistant
- Check relay coil power (12V)
-
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.