---
title: "Water Level Monitor"
url: "https://maker.wiznet.io/Hannah/projects/water-level-monitor/"
markdown_url: "https://maker.wiznet.io/Hannah/projects/water-level-monitor/md"
type: "UCC: User Created Content"
author: "Martin Chlebovec"
author_url: "https://github.com/martinius96/hladinomer-studna-scripty"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Martin Chlebovec"
original_url: "https://github.com/martinius96/hladinomer-studna-scripty"
published: "2025-10-29"
language: "en"
likes: 0
views: 393
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Water Level Monitor

> Water Level Monitor - Arduino / ESP8266 / ESP32

Original author: Martin Chlebovec (source: https://github.com/martinius96/hladinomer-studna-scripty)

## Documents and links

- [Water Level Monitor](https://github.com/martinius96/hladinomer-studna-scripty) (code)

## Article

#### **Project Overviewhladinomer-studna-scripty** is an open-source project designed to monitor **water levels in wells, tanks, or reservoirs** and visualize the data via **web and MQTT communication**.

Originally built around Wi-Fi (ESP8266/ESP32), this version integrates **WIZnet’s W5500 Ethernet controller**, transforming it into a **wired IoT water monitoring node** with enhanced stability and reliability.

This approach eliminates the connectivity issues of Wi-Fi—signal interference, range limits, and unstable networks—while maintaining real-time communication through HTTP (JSON) and MQTT protocols.

**우물, 탱크, 저수조** 등에서 수위를 측정하고 그 데이터를 **웹과 MQTT를 통해 시각화·모니터링**하는 오픈소스 프로젝트입니다.
ESP8266/ESP32의 Wi-Fi 환경으로도 설계되어있고, 아두이노와 **W5500 **을 이용해 **유선 기반 IoT 수위 모니터링 노드**로도 구현되어있습니다.

#### **Core Hardware**

| Component | Function |
| --- | --- |
| **Arduino Board (UNO/MEGA, etc.)** | Main controller and data processor |
| **WIZnet W5500** | Wired Ethernet communication with hardware TCP/IP offload |
| **Water Level Sensor (HC-SR04, JSN-SR04T, etc.)** | Measures distance from sensor to water surface |
| **Power Supply (DC / PoE options)** | Reliable power delivery for long-term installations |
| **MQTT Broker / Web Server** | Centralized data visualization and remote access |

> 💡 **W5500’s hardware TCP/IP engine significantly reduces MCU load, ensuring smooth long-term operation.**

| 구성요소 | 역할 |
| --- | --- |
| **Arduino 보드 (UNO/MEGA 등)** | 전체 제어 및 데이터 처리 |
| **WIZnet W5500** | 유선 이더넷 통신, 하드웨어 TCP/IP 오프로딩 |
| **수위 센서 (HC-SR04, JSN-SR04T 등)** | 거리 기반 수면 높이 측정 |
| **전원 공급부 (DC/PoE 옵션)** | 현장 환경에 따라 안정적 전력 공급 |
| **MQTT 브로커 / 웹서버** | 수집 데이터 시각화 및 원격 관리 |

#### **How It Works / Main Features**

This system follows a simple yet powerful workflow:

1. **Water Level Measurement**
   The ultrasonic sensor measures the distance to the water surface, calculating the level (in cm) and volume (in liters).

2. **Data Communication**
   Through W5500, the device performs **HTTP GET** requests to the webserver (`arduino.clanweb.eu`) and retrieves JSON-formatted data.
   Then, it publishes parsed values to the MQTT broker (`mqtt.iotindustries.sk`) using topics: `hladinomer/vyska` → water height / `hladinomer/objem` → volume

3. **MQTT Integration**
   The MQTT broker allows real-time visualization and remote monitoring via platforms such as Node-RED, Grafana, or AWS IoT Core.

4. **Periodic Operation**
   The system collects and transmits data every **60 seconds**.

5. **Error Recovery & Reconnection**
   If the MQTT connection drops, the system automatically retries.
   DHCP failures trigger an immediate fallback to static IP.

> ⚙️ **Main libraries used:**
> `Ethernet2.h` (W5500), `ArduinoJson.h` (for JSON parsing), `PubSubClient.h` (for MQTT communication)

1. **센서 측정**
   초음파 센서가 수면까지의 거리를 계산하여 수위(cm)와 용량(리터)을 산출합니다.

2. **데이터 통신**
   W5500을 통해 **HTTP 요청(GET)**으로 웹서버(`arduino.clanweb.eu`)에서 JSON 데이터를 수신하고, **MQTT 퍼블리시**로 `hladinomer/vyska`(수위), `hladinomer/objem`(용량) 토픽을 전송합니다.

3. **MQTT 통합**
   브로커(`mqtt.iotindustries.sk`)에 데이터를 업로드하여,
   다른 시스템(예: Node-RED, Grafana, AWS IoT Core)에서 구독 및 시각화 가능.

4. **주기적 업데이트**
   기본 60초 주기로 데이터 수집 → HTTP → MQTT 업로드 루프를 수행합니다.

5. **에러 복구 및 재접속**
   MQTT 연결이 끊기면 자동 재시도하며, DHCP 실패 시 정적 IP로 즉시 전환합니다.

#### **Key Technologies**

| Technology | Description |
| --- | --- |
| **WIZnet W5500 Ethernet Controller** | Hardware TCP/IP stack for reliable, low-overhead network handling |
| **MQTT Protocol** | Lightweight message transport for IoT data |
| **HTTP + JSON** | RESTful data exchange with remote servers |
| **ArduinoJson Library** | Efficient parsing of incoming JSON payloads |
| **PubSubClient Library** | Manages MQTT publishing and subscription |
| **Deep Sleep / OTA** (ESP extension) | Optional low-power and remote firmware update features |

> 🔒 **Future expansions with WIZnet ecosystem:**
>
> - W6100 for **IPv6-ready networks**
>
> - **TLS-secured MQTT** communication
>
> - **PoE (Power over Ethernet)** for power + data integration

#### **Applications & Benefits**

| Sector | Example Use | Benefit |
| --- | --- | --- |
| **Agriculture** | Groundwater or irrigation well monitoring | Real-time water resource management |
| **Smart Buildings** | Rainwater or cooling tank tracking | Prevent overflow, automate maintenance |
| **Industrial Plants** | Cooling or waste-water tank level control | Increased safety and efficiency |
| **Disaster Response** | Flood / drought monitoring | Early warning systems |
| **Smart Cities** | Centralized water network monitoring | Improved urban water infrastructure management |

**Advantages of WIZnet Ethernet Integration:**

- Reliable in **noisy or remote environments** (no signal loss)

- Immune to **RF interference** in industrial sites

- Enhanced **network security** (wired-only connectivity)

- Ideal for **24/7 unattended operation**

| 분야 | 적용 예시 | 기대 효과 |
| --- | --- | --- |
| **농업** | 지하수 수위 감시, 관정 자동 급수 | 실시간 수자원 관리 |
| **스마트 빌딩** | 빗물 저장조, 냉각수 탱크 모니터링 | 누수 방지 및 유지보수 자동화 |
| **산업 플랜트** | 냉각수/폐수 탱크 수위 감시 | 안전성 및 자동 제어 향상 |
| **재난 대응** | 홍수·가뭄 대비 수위 모니터링 | 조기 경보 시스템 구축 |
| **스마트시티 인프라** | 중앙 서버 기반 원격 감시 | 도시 규모 물 관리 최적화 |

**WIZnet 기반의 장점**

- **Wi-Fi보다 안정적** (지하·원거리·전파혼잡 구간 대응)

- **산업 환경 내 간섭 최소화**

---

Source: https://maker.wiznet.io/Hannah/projects/water-level-monitor/
