Proposal for a Digital Rain Gauge

by jaimearavena in Circuits > Arduino

34 Views, 0 Favorites, 0 Comments

Proposal for a Digital Rain Gauge

web.jpg

This proposal describes the preliminary design of a low-cost electronic rain gauge, without moving parts, that uses a commercial capacitive sensor to measure the water level of rainfall. The operating principle is based on measuring the voltage changes produced by variations in the sensor's capacitance when it comes into contact with water. The prototype uses an ESP8266 microcontroller with WiFi connectivity, allowing real-time measurement access through a web page available from any internet-connected device. The possibility of having several sensors that can indicate the rate of water per minute will be valuable in generating alarms in the event of excessive rainfall.

This document is intended for individuals familiar with the Arduino IDE, ESP8266 programming, and basic electronics concepts. It should be noted that this report represents a conceptual feasibility prototype.

Supplies

wemos.jpg
sensor.jpg
BME280.jpg

All components can be purchased from platforms like AliExpress or local distributors. The estimated total cost is under USD 25.

* Microcontroller: Wemos D1 module based on ESP8266.

* Prototyping shield: Expansion shield for Wemos D1.

* Capacitive moisture sensor: Using the DFRobot product.

* Optional environmental sensor: BME280 (pressure, temperature, ambient humidity).

* Plastic funnel: Wide diameter to improve collection accuracy.

* Power supply: 5 V source or battery.

* Cables and connectors.

* Materials for housing and assembly.

Design and Construction

esquema1.jpg
inferior.jpg
sensor final.jpg
soilsensorschematic.jpg
tarjeta  wemos.jpg
stak.jpg

Electrical Connections

The CPU is powered with 5 V and supplies energy to the sensors. The connections are as follows:

* Capacitive sensor:

* `VCC` → `5V`

* `GND` → `GND`

* `SIG` → `A0` (analog input)

* BME280 sensor (I²C):

* `VCC` → `5V`

* `GND` → `GND`

* `SDA` → `D1`

* `SCL` → `D2`

Sensor Operating Principle

The sensor uses an astable circuit based on a 555 timer. The operating frequency is fixed (in the kHz range) and feeds an RC filter. The output voltage of this filter varies according to the capacitance between the sensor's copper traces, which changes based on the water level. This voltage is read by the analog-to-digital converter (ADC) integrated in the ESP8266.

Sensor Preparation and Assembly

The original sensor, designed for soil insertion, was modified by cutting the curved part of its traces to allow uniform immersion in a plastic tube acting as a water container. The electronic components and the edges of the board were sealed with transparent adhesive to protect them from moisture.

Rainwater is collected through a funnel that directs the liquid into the sensor tube.

The ratio between the funnel’s surface area and the receiving tube determines the measurement accuracy in millimeters.

A siphon tube should be added at an appropriate height to automatically empty the container.


Calibration and Data Modeling

mm vs adc.jpg
mm vs 1000ADC.jpg


The relationship between the ADC reading and water height (in mm) is not linear. Therefore, experimental calibration for each unit is essential, as the coefficients critically depend on the specific geometry of the assembly.

Methodology: The sensor is submerged at known depths, and ADC values are recorded. Multiple measurements at each point are recommended for averaging and reducing error, given the system's sensitivity. The measurements show a complex relationship that does not fit well with standard regressions.

For this reason, a variable change was applied using `1000/ADC` as the independent variable, obtaining the following:

For our prototype, a high correlation (0.994) was achieved using a polynomial model of the reciprocal variable (1000/ADC). The resulting regression was:

`mm = a0 + a1(1000/ADC) + a2(1000/ADC)²`

where:

* `a0 = 8.486309`

* `a1 = -14.3801`

* `a2 = 6.064292`

The ADC values for a fixed height showed a standard deviation below 4 counts.

Software

web.jpg

The firmware, developed in the Arduino IDE, includes the following main functionalities:

1. Initialization (`setup()`): Configures WiFi in access point (AP) mode, initializes the web server and sensors (BME280).

2. Main loop (`loop()`): Performs measurements at regular intervals (e.g., every 2 minutes) via the `calculos()` function.

3. Measurement (`getSensorReadings()`): Reads ADC and BME280 sensor values using appropriate libraries.

4. Web Server: Handles HTTP requests asynchronously. The `handleRoot()` function generates an HTML page with the latest values and an SVG graph of the last 24 hours, created by `drawGraph()`.

5. Time synchronization: The `fecha()` function retrieves the current time from an NTP (Network Time Protocol) server.

The program uses a non-blocking delay (`smartDelay()`) to maintain web server responsiveness between measurements.

Tests and Results

prueba.jpg

Initial tests were conducted indoors simulating rainfall with a dropper. The basic functionality of the measurement system, web server, and data chart was validated. The “mm of rain” values obtained are for testing purposes and require calibration under real conditions.

The chart displays variables plotted every 2 minutes to cover 24 hours. The lines on the right under the cursor show values from the previous day.

Using a 3D printer, it is possible to build a protective box that includes the collector and the bird guards.

Improvements

moisture32.jpg

* Low power mode: Implement the ESP8266 deep sleep mode between measurements to allow prolonged autonomous operation on battery.

* Persistent storage: Add a microSD card to store historical data and prevent loss during power outages. Wemos provides a shield for this purpose.

* Backup battery: Include a small auxiliary battery to retain information during main battery replacement.

* External ADC: Use an external analog-to-digital converter (e.g., ADS1115) to improve accuracy, especially at low readings.

* Cloud integration: Publish data on IoT platforms such as ThingSpeak for remote monitoring and analysis.

* Sensor modification: Follow the guide from \[The Cave Pearl Project]

([https://thecavepearlproject.org/2020/10/27/hacking-a-capacitive-soil-moisture-sensor-for-frequency-output/](https://thecavepearlproject.org/2020/10/27/hacking-a-capacitive-soil-moisture-sensor-for-frequency-output/))

to modify the sensor so that its output frequency varies instead of voltage, significantly improving accuracy and resolution. This appears to be the most important improvement.

* Dedicated hardware: Use an ESP32 module with an integrated battery to simplify design and power management as shown:

Conclusion

A functional prototype of a low-cost automatic rain gauge has been presented, demonstrating the feasibility of the core concept. Its WiFi connectivity and low cost make it an ideal candidate for deploying geographically distributed rainfall monitoring networks.

Furthermore, the simplicity of the project makes it suitable for educational purposes, motivating students in electronics, programming, and environmental sciences.

This document serves as an initial proposal to be refined and improved in future iterations.

JAL / Aug 24, 2025