Skip to content

Techposts/LoRa-Water-Tank-Monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TankSync - LoRa Water Tank Monitor

License: MIT License: AGPL-3.0 ESP-IDF GitHub Release GitHub Stars

Long-range wireless water tank level monitoring using LoRa (RYLR998), ESP32, and a cloud dashboard. Monitor multiple tanks from up to 5km away with no WiFi needed between sensor and receiver.

Receiver Transmitter

Architecture

                    LoRa 865/915 MHz (up to 5km)
                    =========================>
  TRANSMITTER                                          RECEIVER
  ESP32-C3 SuperMini                                   ESP32 DevKit v1
  + SR04T Ultrasonic                                   + RYLR998 LoRa
  + RYLR998 LoRa                                      + SH1106 1.3" OLED
  + 18650 Battery                                      + WS2812B LED
  + Solar (optional)                                   + WiFi
                                                          |
                                              +-----------+-----------+
                                              |                       |
                                       MQTT over TLS            Web UI
                                              |              192.168.x.x
                                    +---------+---------+
                                    |                   |
                              Home Assistant      TankSync Cloud
                              (auto-discovery)    tanksync.smartghar.org

Features

  • Long Range: RYLR998 LoRa module, 5km+ line of sight
  • Multi-Tank: Support up to 10 transmitters per receiver
  • Low Power: Transmitter deep sleeps between readings (configurable 1-1440 min)
  • Local Display: SH1106 1.3" OLED on receiver shows tank levels, battery, signal
  • Web UI: Built-in configuration interface on the receiver (WiFi, MQTT, LoRa, OTA)
  • Home Assistant: Native MQTT auto-discovery integration
  • TankSync Cloud: Web dashboard with push notifications, multi-tank monitoring, QR device linking
  • MQTT over TLS: Secure communication between receiver and cloud (port 8883)
  • OTA Updates: WiFi OTA for receiver, LoRa OTA relay for transmitter
  • Captive Portal: Auto-redirect WiFi setup on iOS, Android, and Windows
  • Remote Config: Push sleep interval and sample count to transmitters over LoRa
  • Email Verification: Resend API + Cloudflare Turnstile on signup
  • Auto MQTT Provisioning: QR code scan auto-configures receiver's cloud MQTT connection

Hardware

Component Part Approx. Cost
Receiver MCU ESP32 DevKit v1 (or ESP32-C3 SuperMini) $4-8
Transmitter MCU ESP32-C3 SuperMini $3
LoRa Module REYAX RYLR998 (x2) $8 each
Ultrasonic Sensor JSN-SR04T / AJ-SR04M (waterproof) $4
Display SH1106 1.3" OLED I2C $3
Battery 18650 LiPo + protected holder $2.40
Solar charger CN3791 MPPT (replaces TP4056 for solar TX) $1.45
Boost converter MT3608 3.7V β†’ 5V $0.60
Power monitor (optional) INA219 over I2C $1.45

Total: ~$46-63 per complete system (entry vs premium SKU)

πŸ“ Detailed wiring diagrams, pin connections, and power chain β†’ Includes block diagrams for both DevKit-RX and C3-RX, full TX power chain with solar charging, and both power-monitoring variants (voltage divider vs INA219 over I2C with auto-detect).

πŸ“‹ Full BOM β†’

Quick Start

Option 1: Pre-built Firmware (Recommended)

Download the latest .bin files from Releases.

# Receiver (ESP32 DevKit)
esptool.py --chip esp32 -b 460800 write_flash 0x10000 tanksync-receiver-vX.Y.Z.bin

# Receiver (ESP32-C3 SuperMini)
esptool.py --chip esp32c3 -b 460800 write_flash 0x10000 tanksync-receiver-c3-vX.Y.Z.bin

# Transmitter (ESP32-C3)
esptool.py --chip esp32c3 -b 460800 write_flash 0x10000 tanksync-transmitter-vX.Y.Z.bin

Option 2: Build from Source

Prerequisites: ESP-IDF v5.4+

# Receiver (ESP32 DevKit)
cd firmware/receiver
idf.py build
idf.py -p /dev/ttyUSB0 flash

# Receiver (ESP32-C3)
cd firmware/receiver-c3
idf.py set-target esp32c3
idf.py build
idf.py -p /dev/ttyACM0 flash

# Transmitter (ESP32-C3)
cd firmware/transmitter
idf.py set-target esp32c3
idf.py build
idf.py -p /dev/ttyACM0 flash

First Boot

  1. Receiver starts in AP mode -- connect to the TankSync WiFi network
  2. A captive portal opens automatically (or navigate to 192.168.4.1)
  3. Configure your home WiFi credentials, MQTT broker, and LoRa settings
  4. Transmitter auto-pairs on first boot -- press the "Start Pairing" button in the receiver web UI

TankSync Cloud

A web dashboard for monitoring your tanks from anywhere. Use the hosted version or self-host your own.

Hosted: tanksync.smartghar.org -- sign up, scan the QR code from your receiver's web UI, and your tank data flows to the cloud automatically.

Self-host:

cd pwa
npm install
cp .env.example .env    # Edit with your MQTT broker and API keys
npm run build
npm start               # Runs on http://localhost:4800

Features: multi-tank monitoring, push notifications, QR code device linking, email verification, dark/light themes, historical charts.

See pwa/deploy/ for production deployment with systemd and Nginx.

Home Assistant Integration

The receiver publishes auto-discovery messages via MQTT. Tanks appear automatically in Home Assistant as sensor entities.

Home Assistant Dashboard

Project Structure

firmware/
  receiver/          ESP32 DevKit receiver (MIT)
  receiver-c3/       ESP32-C3 receiver variant (MIT)
  transmitter/       ESP32-C3 transmitter (MIT)
pwa/
  server/            Fastify + SQLite server (self-host) (AGPL-3.0)
  server-cloud/      Fastify + PostgreSQL server (cloud deploy) (AGPL-3.0)
  client/            React + Tailwind frontend
  deploy/            Systemd, Nginx, and deploy scripts
hardware/            BOM and hardware designs (CC BY-SA 4.0)
docs/                Documentation and images
.github/workflows/
  build-firmware.yml  Automated firmware builds on tag push
  deploy-cloud.yml    CI/CD deploy to DigitalOcean on push

CI/CD

  • Firmware: Push a version tag (git tag v2.2.0 && git push origin v2.2.0) to auto-build all 3 firmware binaries and create a GitHub Release
  • Cloud: Push changes to pwa/ on main to auto-deploy to the production server via SSH

LoRa Message Protocol

Transmitter -> Receiver:  TANK:<dist_cm>:<bat_pct>:<bat_v>:<msg_id>:<fw_ver>
Receiver -> Transmitter:  ACK:<msg_id>
Config Downlink:          SET:SLEEP=<seconds>:SAMP=<count>
Pairing:                  PAIR_REQ / PAIR_ACK:<addr>:<name>

Security

  • MQTT over TLS (Let's Encrypt certificates, auto-renewing)
  • Per-user MQTT credentials with topic-level ACL
  • Cloudflare Turnstile captcha on signup
  • Email verification via Resend API
  • Rate limiting on auth endpoints (5 register/min, 10 login/min)
  • JWT tokens with 30-day expiry
  • Security headers (X-Frame-Options, CSP, HSTS via Cloudflare)
  • UFW firewall, fail2ban, SSH key-only deploy

License

Component License Details
Firmware (firmware/) MIT Free for any use
Cloud App (pwa/) AGPL-3.0 Must share source if hosted as a service
Hardware (hardware/) CC BY-SA 4.0 Attribution + ShareAlike

Contributing

Contributions are welcome! Please open an issue or pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

Author

Ravi Singh - YouTube

Built with ESP-IDF, React, Fastify, and a lot of late nights.

About

Wireless water tank level monitor using LoRa (RYLR998) and ESP32-C3. Features deep sleep for 50+ days battery life, real-time web dashboard, MQTT/Home Assistant integration, and RGB LED status indicators.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages