Source codes for Arduino, ESP8266, ESP32, NewPing Library: Github project repository
Try the Level Level project for free with your hardware: HERE
Arduino Ethernet Wiznet W5100 / W5500 ESP8266 ESP32 Ultrasonic HC-SR04 JSN-SR04T Sigfox

Supported microcontrollers for project Waterwell Level Monitor

Riadiaci mikrokontróler Arduino Uno pre termostat
Arduino Uno / Nano
Riadiaci mikrokontróler NodeMCU v2 / v3 Lolin - ESP8266-12E / ESP8266-12F
NodeMCU v3 Lolin
Riadiaci mikrokontróler Wemos D1 Mini - ESP8266-12E / ESP8266-12F
Wemos D1 Mini
Riadiaci mikrokontróler ESP32 Devkit V1 - ESP-WROOM-32 / ESP32-S
ESP32 DevKit V1

Ethernet and Sigfox transmission technology modules for Waterwell Level Monitor project

Ethernet shield Wiznet W5100
Ethernet shield Wiznet W5100
Ethernet modul Wiznet W5500
Ethernet modul Wiznet W5500
Sigfox Wisol modem - IoT LPWAN Node 868 MHz
Sigfox Node Modem

Supported and tested ultrasonic sensors for recording water level

Ultrazvukový senzor vzdialenosti HC-SR04
Ultrazvukový vodotesný senzor vzdialenosti JSN-SR04T
Ultrazvukový senzor vzdialenosti HY-SRF05
Ultrazvukový senzor vzdialenosti URM07 ovládaný cez UART

Water Level monitor - Arduino / ESP8266 / ESP32

Project Water Level monitor uses web interface to visualize the measured data on the water level in the well, tank. The responsive web interface in the Bootstrap Bare template adapts to any screen on which the data is visualized. The data is readable on watches, smartphones, computers, Smart TVs and other devices. Web interface of the project uses a backend written in PHP, which processes incoming data supported by the POST request method, converts the measured water level to the actual water level (from bottom of waterwell), calculates the well volume based on known data on depth and well diameter entered into the system by the user. Datas are sent to a web server by a microcontroller, which performs measurements every 300 seconds - each 5 minutes, or in the case of transmission via the Sigfox IoT network, the data is sent every 11 minutes - because of limited messages that can be sent during 24 hours. Water level measurement is performed using ultrasonic sensors - HC-SR04, or its waterproof variant JSN-SR04T. Principle of measuring ultrasonic sensors is to send a Trigger signal with a length of 10μs (microseconds) and based on the time when the signal returns to the receiver - Echo it is possible to calculate the distance between the sensor and the level. An important parameter in both ultrasonic sensors is the beam width, in other words the detection characteristic. The HC-SR04 sensor has a 15 ° detection characteristic. The beam is relatively narrow and the sensor is also suitable for narrower wells and tanks, but it is not waterproof and has a high risk of corrosion (oxidation). The JSN-SR04T waterproof sensor has a detection characteristic of 60 to 75 °, which does not allow it to be used in narrow wells, as the beam expands greatly with distance and requires a well with a diameter of several units (6 meters at 4.5 well depth).

The web interface uses trigonometry to estimate the measurable maximum depth of the well at a known well diameter (another parameter for calculating the well volume). The web interface allows the user to calculate to what maximum depth of the well each of the sensors is suitable based on its characteristics. The project is so easy to use even for laymen who do not know which sensor is more suitable for application in their well. Microcontroller used also plays an important role in the system. The project used the Arduino (Uno) platform connected to an Ethernet module / shield from the Wiznet model W5100 and W5500 series, respectively, which provided HTTP connectivity and enabled the microcontroller to transfer data to a remote web interface on the Internet. As the level meter is an outdoor project, many users would also like the possibility of using a WiFi platform without having to pull Ethernet connectivity to the well. WiFi platforms from Espressif Systems - ESP8266 and ESP32, which are used in the project, allow operation in various modes - StandBy, Deep Sleep (deep sleep with WiFi modem turned off), StandBy + OTA - allows you to remotely upload to the board new firmware directly from the board Arduino IDE environment. For the Deep Sleep operating mode, there is a modified wiring diagram for the ESP8266 platform, which uses a signal from GPIO 16 (D0) that is fed to the RST to wake up the WAKE microcontroller. At the same time, this connection does not allow the program to be updated without disconnecting this jumper. For ESP32, the Deep Sleep mode is used using an RTC timer, which wakes up ESP after a certain time. Platforms can communicate with the web interface via HTTP, but also HTTPS protocol. The ESP8266 platform uses a fingeprint of the web server's public key in SHA1 format, but requires more frequent renewals, as they are valid for a maximum of one year or 2 years, respectively. The microcontroller from the ESP32 series uses the certificate of the root certification authority (in .pem format is that Root CA required), which issued a certificate for the web server. From the point of view of operation, this option is better, as the certificate of the certification authority is valid for 5 up to 20 years and no renewal of the certificate is necessary during that time.

For locations where is no coverage of the fixed Internet, it is also possible to use the IoT network Sigfox that is so popular in Europe (available also in USA). This technology allows you to transmit small volume of messages up to 12B in size. In the case of the Level meter project, the 4B water level value is sent. As Sigfox allows a maximum of 140 messages to be transmitted per day, the data transmission interval is extended to 11 minutes. Message that is sent via Sigfox network does not contain the full length that it can -->12B. Payload messages can also be supplemented with various system information, for example: GEO data (longitude / latitude), RSSI (Signal Strength), message number and others. The communication module that was used for the project is a Sigfox WISOL 868MHz UART modem. This modem communicates via AT commands via the UART interface, which is software emulated on microcontrollers. The communication will take over at a speed of 9600 baud / s. The WISOL modem is equipped with an integrated u.FL connector on the PCB module for antenna connection, which significantly reduces coverage even indoors / shaded outdoors. For successful data transmission, coverage by two, preferably three or more base stations is required for successful data transmission. Base station will transmit information from you to the Sigfox backend, where it is necessary to make a callback, which will trigger after receiving the data. The callback must make an HTTP or HTTPS request to the domain where the web application is running with the POST method and a suitably encoded payload that the web application backend expects. Webapp is fully translated to english, slovak, russian and german language.

Level meter - Callback settings in Sigfox Backend:
  • Callbacks --> Custom --> New
  • In Custom payload config we write: cislo1::uint:16
  • To URL pattern: (or another URL of your web server where the project will run), the possibility to use HTTPS
  • In the HTTP method, select: POST
  • To the Body (body of the message) we add:
  • hodnota={customData#cislo1}
  • To Content-Type: application/x-www-form-urlencoded

  • Web interface visualizations - Level meter

    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 - webapp - Set diameter and height of waterwell WaterWell Level monitor - webapp - Wiring diagram WaterWell Level monitor - webapp - Project info - Informations with source code for Arduino, ESP8266, ESP32

    Detection characteristics of the HC-SR04 sensor - 15° beam width

    Waterwell monitor - Detection characteristics of the HC-SR04 sensor - 15° beam width

    Detection characteristics of the JSN-SR04T sensor - waterproof - 45° beam width

    Waterwell monitor  - Detection characteristics of the JSN-SR04T sensor - waterproof - 45° beam width