Explore source codes for Arduino, ESP8266, ESP32, (Ethernet / WiFi / LoRaWAN): GitHub project repository
Immerse yourself in our IoT dashboard featuring your hardware: ON-LINE IoT dashboard
For source codes of the web interface or any inquiries, please contact the author at: martinius96@gmail.com

Water Level Monitor Project

Experience the augmented reality (AR) simple visualization app - READY
Augmented reality - webapp for Android, iOS, IoT dashboard data

Supported microcontrollers for Water Level monitor - AVR / ESP



Transmission technology modules - Ethernet



Compatible ultrasonic proximity sensors



Water Level monitor - Arduino / ESP8266 / ESP32


Unlock the power of water level monitoring with our IoT Dashboard, featuring a dynamic web interface that serves as the central hub for visualizing accurate measurements. Our system utilizes ultrasonic sensors, including popular models like HC-SR04 and its waterproof variant JSN-SR04T, to record data about the water level in dug wells through a sensor node equipped with a microcontroller. In addition to HC-SR04 and JSN-SR04T, our program supports various sensors with Trigger/Echo signals, such as RCW, US-XXX, IOE-SR0X, SR0X, HC-SR0X, HY-SRF0X, DYP-MEXXX, and Parallax PING)))™ series, providing flexibility in implementation. The sensor node routinely conducts 10 averaged measurements with the ultrasonic sensor every 5 minutes. The recorded values are then transmitted to the server via multiple interface options, including WiFi, Ethernet, IoT network LoRaWAN, NB-IoT, or Sigfox. Experience real-time data representation on the dashboard, showcasing the current water level along with volume conversion for the well and a trend analysis compared to the previous measurement. Delve into historical data through tabular or graphical representations with line graphs, allowing users to track water level trends over time. Our web interface is responsive, adapting seamlessly to screens of smartphones, computers, tablets, and Smart TVs for a user-friendly experience. Upon receiving data, our backend corrects the measured water level to the actual depth of the well, compensating for the sensor's transmission of differential water levels. Using the real height of the water level and the known diameter of the well, our web interface calculates the volume of the well in liters, providing valuable insights for effective well management. Optimize your water level monitoring with our IoT Dashboard—precision, flexibility, and connectivity at your fingertips.

Water Level Monitor webapp dashboard in OS Android with automatic data update via jQuery

Ultrasonic sensors operate by sending a Trigger signal with a 10 μs duration, which reflects off the water surface and returns as the Echo. The Time-of-Flight method calculates the time between transmission and reception to determine the distance of the water level from the sensor. The speed of sound is calculated at 343 m/s at a temperature of 20 °C, forming the basis for accurate distance measurement. An essential parameter is the beam width, representing the detection characteristic. The HC-SR04 sensor features a narrow 15° detection characteristic, making it suitable for narrower wells and tanks. While the HC-SR04 is ideal for narrower environments, it is not waterproof and has a higher risk of corrosion in wet conditions. Therefore, placing it above the well is recommended to minimize the impact of humidity. The JSN-SR04T, a waterproof sensor, has a wider 60° detection characteristic. However, this limits its use in narrow wells, as the beam widens with distance. A larger well diameter is required (e.g., 6 meters diameter for a well depth of 4.5 meters) to guarantee accurate measurements without reflections. Ultrasonic sensors, in general, are maintenance-free. However, the JSN-SR04T sensor has a control electronic board that should not be exposed to moisture and water. The sensors, including JSN-SR04T, can measure a maximum height of approximately 400 to 450 cm, providing a versatile range for various well depths. Understanding the intricacies of ultrasonic water level sensors empowers effective monitoring, ensuring precision and reliability in diverse environmental conditions. Explore placement strategies and the features of HC-SR04 and JSN-SR04T for optimal results in your water level measurement system.

Integrate various water level sensors into your system by creating customized firmware. Each sensor type brings unique capabilities, ensuring flexibility and adaptability to different monitoring scenarios. Other types of water level sensors that can be integrated (you need to create your own firmware):
  • Laser (LiDAR) - (DFRobot DTOF LD19 LIDAR, DFRobot ToF Laser ...)
  • Hydrostatic - (LMK307, DPT200, PT20eco, HDL300 ...)
  • Electrostatic (capacitive / inductive) - XKC-Y25-NPN
  • Pressure (differential / with compensating atmospheric pressure sensor)
  • Optical - (GP2Y0A02YK0F, YD-02F, FS-IR02 ...)
  • Mechanical (float / bobber)
  • Magnetic (Hall) - (VCL9, Sen-Hz41wa ...)
  • Microwave (radar) - (CS476, CS475A-L, SP69, WLR 8/15/30 ...)
  • Ultrasonic - (A01NYUB, URM37), another type of output (RS-485, 4-20 mA, Modbus RTU, M-bus, PROFINET)
  • Note: If the water level from the bottom of well is recalculated on the microcontroller's side, parameter - Well depth in web interface must be set to 0 cm!

  • Video demonstration of the web interface - Water Level monitor:



    Ultrasonic sensors are suitable for:


  • Dug waterwells
  • Digged waterwells
  • Septics and cesspools
  • Streams and lakes
  • Plastic rainwater tanks
  • Silos (measuring bulk filling)
  • Containers (waste monitoring, fill level)
  • Boiler rooms (monitoring of wood, pellets, coal, wood chips materials)
  • Shafts and cellars (flooding - groundwater height monitoring)

  • Ultrasonic sensors are NOT suitable for:


  • Drilled waterwells (due to detection characteristics - wide beam)
  • Pipes and tubes (due to detection characteristics - wide beam)
  • To waterwells with a gradient tributary (rippled water surface attenuates ultrasound, measurement is impossible)
  • In places with a sudden change in temperature (temperature affects the time of sound propagation, so even the stationary level appears to fluctuate)
  • Vacuum tanks (measurement is not possible)
  • Detection characteristics of ultrasonic proximity sensors - MATLAB scripts:
  • HC-SR04.m Download
  • JSN-SR04T.m Download

  • Plug n' play firmware - Ultra Low Power / StandBy


    Compiled firmware available for immediate upload to the microcontroller (libraries are not required)!
    Firmware name Firmware function ESP8266 ESP32
    Ultra Low Power

    Firmware for ULP applications with low current consumption. The firmware is loaded via the bundled ESPTOOL tool automatically, which is run with a .bat script (in the script it is necessary to change the COM port of your ESP board). After uploading the firmware and assuming that ESP does not have the SSID and password from the previous project stored, WiFiManager will start, which is used to configure the existing WiFi network. ESP will start broadcasting an open WiFi network with SSID -> Hladinomer_AP in AP mode. After connecting the client (Windows / Android / iOS) the Captive portal will start on 192.168.4.1 (the client should be redirected automatically). WiFiManager allows you to select a WiFi network in range in the web interface, set a password. After successfully connecting ESP to the specified WiFi network and assigning IPv4 from the given range, Captive Portal will be turned off, ESP remains in STA-Station mode. Subsequently, the sensor node will start transmitting data to the web interface Water Level Monitor . The next time the sensor node is started, Captive Portal and WiFiManager will no longer start, as the WiFi network configuration is permanently preserved. After datas are sent to server, ESP microcontroller will switch to Deep Sleep mode. It will turn off main processor Xtensa. ESP8266 is awakened via WAKE timer (jumper between GPIO16 and RST required - check Wiring diagram), ESP32 is awakened via RTC Timer.

    ESP8266 .bin firmware ESP32 .bin firmware
    StandBy

    Firmware for StandBy mode of the microcontroller, which sends at regular intervals (5 min) measurements of the water level to the web server and at the same time maintains connectivity with the AP in the LAN network. The firmware is loaded via the bundled ESPTOOL tool automatically, which is run with a .bat script (in the script it is necessary to change the COM port of your ESP board). After uploading the firmware and assuming that ESP does not have the SSID and password from the previous project stored, WiFiManager will start, which is used to configure the existing WiFi network. ESP will start broadcasting an open WiFi network with SSID in AP mode --> Hladinomer_AP. After connecting the client (Windows / Android / iOS) the Captive portal will start on 192.168.4.1 (the client should be redirected automatically). WiFiManager allows you to select a WiFi network in range in the web interface, set a password. After successfully connecting ESP to the specified WiFi network and assigning IPv4 from the given range, Captive Portal will be turned off, ESP remains in STA-Station mode. Subsequently, the sensor node starts transmitting data to the web interface Water Level Monitor. The next time the sensor node is started, Captive Portal and WiFiManager will no longer start, as the WiFi network configuration is permanently stored.

    ESP8266 .bin firmware ESP32 .bin firmware

    Principle of water level measurement and data transmission - Block diagram


    Level meter for cesspool, septic tank, well, measuring principle - ultrasonic proximity sensor

    Enhance your well monitoring experience with our advanced web interface, backed by a powerful backend that leverages trigonometry to estimate the maximum depth of your well. This innovative solution is designed to calculate the optimal depth for each sensor, based on its unique characteristics, making it accessible even for those unfamiliar with sensor selection. The project seamlessly integrates with microcontrollers, with the option to use the widely popular Arduino platform (Uno/Mega) in revision R3. This compatibility extends to Ethernet shields communicating via the ICSP interface. Alternatively, Ethernet modules such as Wiznet W5100, W5500, and USR-ES1, as well as MicroChip's ENC28J60 with software TCP stack, are fully supported, enabling HTTP connectivity on port 80. Explore the versatility of WiFi microcontrollers, including Espressif Systems' ESP8266 and ESP32, both of which offer various operating modes such as StandBy, StandBy + OTA for remote firmware updates, and deep sleep mode for ultra-low-power applications. The ESP microcontrollers stand out by providing encrypted communication through the HTTPS protocol. ESP32 goes a step further, allowing the use of PHY Ethernet with the LAN8720 RMII interface, supporting both HTTP and HTTPS connections. Security is a priority with the incorporation of Root CA certificates in .pem format directly into the source code of the microcontrollers, stored in flash memory (PROGMEM) to optimize RAM usage. These certificates, issued for 10 to 20 years, eliminate the need for frequent renewals. Effortlessly access real-time data on water level and volume in JSON format through the web interface. Take your well monitoring to the next level by integrating our water level monitor project via MQTT into popular home automation platforms like Hassio, Domoticz, and Loxone. Visualize data on dedicated dashboards such as Grafana, Ubidots, Thingsboard, or Cayenne. Empower your peripheral control capabilities by using data from the web interface to manage irrigation, watering, and domestic waterworks. Elevate your well monitoring experience with our user-friendly and technologically advanced solution, catering to both experts and novices alike.

    Operating mode StandBy StandBy + Over The Air (OTA) Ultra Low Power (ULP) FreeRTOS
    Microcontroller - - - -
    Arduino + Ethernet × × ×
    ESP8266 ×
    ESP32
    Source codes for Arduino, ESP8266, ESP32 (required installation of libraries): Available here

    Available libraries for microcontrollers (Arduino / ESP)


    Library archive (.zip) extract to C:/Users/[User]/Documents/Arduino/libraries
    Library name Library function Download
    NewPing

    Library for AVR microcontrollers (ATmega) Arduino Uno / Nano / Mega. It allows to perform measurements with ultrasonic distance sensors RCW, US-XXX, IOE-SR0X, SR0X, HC-SR0X, HY-SRF0X, DYP-MEXXX, Parallax PING)))™.

    Download
    NewPingESP8266

    Library for ESP8266 and ESP32 microcontrollers. It allows to perform measurements with ultrasonic distance sensors RCW, US-XXX, IOE-SR0X, SR0X, HC-SR0X, HY-SRF0X, DYP-MEXXX, Parallax PING)))™.

    Download
    Ethernet2

    Library for AVR microcontrollers (ATmega) Arduino Uno / Nano / Mega. It enables communication with the Ethernet module Wiznet W5200 to W5500 via the SPI interface.

    Download
    Ethernet3

    Library for AVR microcontrollers (ATmega) Arduino Uno / Nano / Mega. It enables communication with Ethernet module Wiznet W5500 V2 - USR-ES1 via SPI interface.

    Download

    Screenshots of Water Level monitor webapp


    WaterWell Level monitor - webapp - main page - Last measured values with automatic refresh - AJAX WaterWell Level monitor - webapp - Historical measured datas with timestamp WaterWell Level monitor - Record, minimal, maximal value per day, week, month WaterWell Level monitor - graph of water level in time - week / year

    UART output of sensor nodes - FreeRTOS - ESP32:


    ESP32 - FreeRTOS - ESP-IDF - ultrasonic sensor measurement and data transfer to webserver via HTTP, POST transfer method ESP32 - FreeRTOS - ESP-IDF - ultrasonic sensor measurement and data transfer to webserver via HTTPS, POST transfer method Supported hardware for well level project - Arduino - Ethernet and WiFi connectivity - ESP8266 - ESP32 Sensor node ESP32 with PHY Ethernet module LAN7820 and ultrasonic sensor JSN-SR04T IoT ultrasonic sensors suitable for solar power, LoRaWAN, WiFi support QR code scanner - AR for ultrasonic sensor