Waterwell Level Monitor - Arduino / ESP8266 / ESP32 / Sigfox + Ultrasonic Distance Sensor

Introduction: Waterwell Level Monitor - Arduino / ESP8266 / ESP32 / Sigfox + Ultrasonic Distance Sensor

About: I am student of University interested in Arduino, ESP related IoT stuff.

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).


  • Arduino Uno / Nano / Mega
  • Ethernet module (shield) Wiznet W5100 / W5500 or ENC28J60 or Wiznet W5500 V2
  • ESP8266 (NodeMCU, Wemos D1 Mini)
  • ESP32 (Devkit, standalone)
  • Optional Sigfox UART modem for IoT data transmission
  • Ultrasonic distance sensor HC-SR04 / JSN-SR04T / HY-SRF05 or URM-07

Step 1: Web Interface & Program Implementation for Microcontrollers

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.

Step 2: Sigfox - Best Option for Locations Without Internet

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: http://arduino.clanweb.eu/studna_s_prekladom/data... (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}&token=123456789
  • To Content-Type: application/x-www-form-urlencoded

Step 3: Codes for Microcontrollers and Webapp Codes

Program implementations for microcontrollers: Arduino, ESP8266, ESP32 can be found at Github: https://github.com/martinius96/hladinomer-studna-scripty/blob/master/examples/Hladinomer/HTTP/StandBy/StandBy.ino

Test web interface where you can try your microcontroller program for FREE is available at (sketches for microcontrollers are communicating with that web interface, so you will see your datas there too!): http://arduino.clanweb.eu/studna_s_prekladom/?lang=en

If you are interested in web interface codes, contact me at: martinius96@gmail.com

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share


    • Home Cooked Speed Challenge

      Home Cooked Speed Challenge
    • Micro:bit Contest

      Micro:bit Contest
    • Made with Math Contest

      Made with Math Contest