Hello friends, I hope you all are doing great. Today, I am going to share the new Rain Gauge Library for Proteus Simulation. Every weather station has one: a small white funnel on a pole that tells you how many millimetres of rain have fallen. Inside it sits one of the cleverest little mechanisms in measurement - a see-saw bucket that tips over every time it fills, and a magnet that closes a switch at every tip. With this library you can run a full Proteus simulation of a tipping-bucket rain gauge, switch bounce and all, so that your pulse counting is right before the gauge goes up the pole.

Figure: The rain gauge simulation running: light rain, heavy rain, a downpour and the easing.
Updates

Rain Gauge Library for Proteus

Latest version: V1.0 (November 2026, this tutorial)

Other water and soil sensors: Soil Moisture · Capacitive Soil · Rain Sensor · Water Level · Turbidity · YF-S201 Flow · pH Sensor · TDS Meter · PH-4502C · Soil NPK

Helping Tools

The gauge comes alive at run time: in a window on its front the bucket fills, tips and rocks back, drops fall from the funnel, and the reed switch lights at every tip. The demo is a weather station's rain display: an Arduino counts the tips through a storm - light rain, heavy rain, a downpour and the easing - and shows the rainfall, the rate and a bar chart of the storm on an OLED, with a RAIN and a HEAVY LED.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the rain sensor board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the Rain Gauge Library for Proteus Simulation:

Figure: The Rain Gauge Library for Proteus Simulation.

How Does a Tipping-Bucket Rain Gauge Work?

Rainfall is measured as a depth: one millimetre of rain means a millimetre of water over every square metre, a litre per square metre. The gauge's funnel collects the rain over a known area and pours it into a little see-saw with a cup on each end. When the cup under the funnel holds the water of 0.2794 mm of rain, its weight tips the see-saw over: the full cup empties, and the other cup swings under the funnel and starts to fill. A small magnet rides on the see-saw, and as it passes a reed switch fixed in the body, the switch closes for a moment. One tip, one pulse. Count the pulses and you know the rainfall; count them in a minute and you know how hard it is raining.

The tipping-bucket rain gauge at a glance
Tipping-bucket rain gauge
Outputa reed switch (a dry contact) on two wires: one closure per tip
Resolution0.2794 mm (0.011 in) a tip - other gauges 0.2, 0.254 or 0.3 mm
Closuretens of milliseconds a tip; the contact bounces as it closes
Wiringone wire to an input with a pull-up, the other to ground (on RJ11 plugs, the middle pins)
Supplynone - it is just a switch
Rainfalltips x 0.2794 mm; the rate from the tips in a time

Rain Rates

Meteorologists describe rain by its rate per hour. One common scale calls anything under 2.5 mm/h light, up to 7.6 mm/h moderate, up to 50 mm/h heavy, and more than that violent. A downpour of 80 mm/h fills the bucket every 12.6 seconds of real time; a drizzle of 1 mm/h takes almost 17 minutes per tip. That is why a rain gauge gives totals with a resolution of 0.28 mm, but a rate only once a few tips have come in.

Switch Bounce

A mechanical contact does not close cleanly: its reeds touch, spring apart for a millisecond or two, and touch again. A microcontroller is fast enough to see every one of those touches, so a sketch that simply counts falling edges counts every tip two or three times. The cure is a debounce: once a tip is counted, ignore the input for a short time - 20 ms is plenty, because even a cloudburst tips the bucket only every few seconds. Our model closes the switch for 60 ms per tip with one bounce at the start, so you can see the problem and the cure.

Features of the Rain Gauge Library for Proteus Simulation

  • A real-looking gauge: the white body with the funnel's rim, the base and the two-wire cable, drawn compact - with a window into the gauge.
  • Animated: in the window the bucket fills and tips from side to side, drops fall from the funnel's spout and the reed switch lights when it closes.
  • A real dry contact: S1 and S2 are a switch - 0.1 ohm closed, 100 Mohm open - that needs a pull-up like the real one.
  • Real bounce: 60 ms a tip with one bounce, so an undebounced count doubles.
  • A storm on a fast clock: SPEED 60 runs a minute of rain each simulated second - a 20-minute storm in a 20-second simulation; the switch's timing stays real.
  • A pop-up: the gauge in section, the rate, the rainfall and each minute's rain over the storm, eight live tiles, graphs, an event log and a check page.
  • A complete package: about 2.3 MB with the library, our OLED, 5 mm LED and resistor libraries, our Arduino UNO V4.0 and the demo, without the source code of the model.

The Rain Gauge in Proteus

The device is RAINGAUGETEP in TEPRAINGAUGE.LIB, under Sensors > Weather, with the prefix U and the model TEPRAINGAUGE.DLL. Search RAIN or gauge in Pick Devices. Two pins along the bottom: S1 and S2, the two ends of the reed switch - either way round. Its properties: PROFILE (DEMO or STEADY), RATE (mm/h for STEADY), TIP (0.2794 mm) and SPEED (60).

Figure: The rain gauge.

Download Rain Gauge Library for Proteus Simulation

Click the button below to download Rain-Gauge-Library-for-Proteus-v1.0.zip (about 2.3 MB, without the source code of the models):

Rain Gauge Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPRAINGAUGE.LIB, TEPOLED12864.LIB, TEPLED5MM.LIB, TEPRESISTOR.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPRAINGAUGE.DLL, TEPOLED.DLL, TEPLED5MM.DLL, TEPRESISTOR.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch (no extra library).
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install Rain Gauge Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPRAINGAUGE.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for RAIN.

Proteus Simulation of a Weather Station's Rain Display

Our demo is the rain part of a weather station. U1 is the gauge with PROFILE DEMO and SPEED 60: a 20-minute storm in 20 simulated seconds - dry for two minutes, light rain at 6 mm/h from minute 2, heavy rain at 40 mm/h from minute 6, a downpour at 80 mm/h from minute 12, easing to 10 mm/h from minute 16, and dry again from minute 20. S2 goes to D2 of our Arduino UNO Library for Proteus V4.0 and S1 to ground; R1, 10 k, pulls D2 up to 5 V. Our OLED SSD1306 Library for Proteus shows the readings, and two LEDs from our 5mm LED Library for Proteus sit beside it: RAIN (green, D5) and HEAVY (red, D6), each through 220 ohm. The Arduino's built-in monitor is the same window as our TEP Serial Monitor Advance for Proteus. Open RainGauge-Weather-ArduinoUnoV4.pdsprj.

Figure: The whole simulation on an A4 sheet.

The Sketch

The sketch needs no library. Its two constants are the gauge's amount per tip and the demo's clock:

const float TIP = 0.2794;                                   // mm of rain a tip (0.011 in)

An interrupt on D2 catches every falling edge - the moment the reed closes - so no tip is missed while the sketch is drawing the OLED:

  attachInterrupt(digitalPinToInterrupt(PIN_RAIN), onTip, FALLING);

Inside the interrupt routine the debounce: an edge within 20 ms of the last counted tip is the contact bouncing, so it is counted as a bounce, not as rain:

  if (now - lastTipMs < DEBOUNCE) { bounces++; return; }    // the contact bouncing - not a new tip

Once a second the main loop copies the counters with the interrupts briefly off, so it never reads a half-updated number:

    noInterrupts(); const unsigned int t = tips, b = bounces; interrupts();

It keeps the count of each of the last six seconds and turns the tips of the last five into a rate in millimetres per hour - divided by SPEED, because the demo's rain runs sixty times fast:

    rate = (history[0] - history[5]) * TIP * 3600.0 / 5.0 / SPEED;    // mm per hour of rain

The OLED shows DRY, LIGHT RAIN, HEAVY RAIN or DOWNPOUR in big letters, the total and the rate, a bar chart of the tips in each of the last 24 seconds, and the counts of tips and bounces. RAIN lights while the rate is above zero, HEAVY from 30 mm/h.

Rain Gauge Simulation Results

Open the project and press Run. The demo runs 25.5 simulated seconds and took 206 seconds on our PC with the pop-up open and the pictures being taken. Click the gauge for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.

The First Drops

For the first two minutes of the storm nothing falls: D2 sits at 5 V through the pull-up, the switch reads 100 Mohm, and the OLED says DRY. At minute 2 light rain begins at 6 mm/h, and in the gauge's window the water starts to rise in the raised cup - slowly: at minute 4.5 the bucket holds 0.249 mm, not yet enough to tip. The first tip comes at minute 4.8. The bucket rocks over, the reed lights for a moment, the sketch counts its first 0.28 mm and prints "Now: LIGHT RAIN". With only one tip in the five-second window the rate reads 3.4 mm/h - the coarse first estimate every tipping-bucket gauge gives in light rain.

Heavy Rain

At minute 6 the rain turns heavy: 40 mm/h, a tip every 0.42 simulated seconds. The bucket rocks steadily in its window, drops stream from the funnel, and the bars on the OLED grow. The monitor follows: 1.68 mm and 20.1 mm/h at minute 8 while the window still holds some light rain, 3.07 mm and 33.5 mm/h at minute 10 - the HEAVY LED comes on at 30 - and 43.6 mm/h at minute 12. At minute 9 the gauge has tipped 8 times, 2.24 mm. Every tip also closed the switch twice - once, a bounce, and again - and the sketch counted the second closure as a bounce, not as rain: the monitor shows the tips and the bounces rising together.

Figure: Heavy rain.

The Downpour

At minute 12 the downpour arrives: 80 mm/h, a tip every 0.21 seconds. The OLED switches to DOWNPOUR at minute 14 when the five-second window is full of it, with 57.0 mm/h; at minute 15 the gauge has tipped 30 times - 8.38 mm - and in the picture the reed is caught closed, lit in the window. Both LEDs are on, and the tallest bars of the chart march across the screen. By minute 16 the rate reads 70.4 mm/h and the total 9.50 mm. In the pop-up the minute bars stand tall and the rainfall curve climbs steeply.

Figure: The OLED in the downpour.
Figure: The simulation in the workspace.
Figure: The downpour.

After the Storm

At minute 16 the rain eases to 10 mm/h, and at minute 20 the storm is over. The sketch's rate follows a few seconds behind, as a five-second window must: 53.6 mm/h at minute 18 (HEAVY RAIN again), 23.5 at minute 20, LIGHT RAIN at 6.7, then DRY - and both LEDs go out. The gauge stopped at 37 tips: 10.34 mm of rain in the storm, and 37 bounces caught by the debounce. Without it the sketch would have reported 20.68 mm - twice the truth.

Figure: After the storm.

The Graphs, the Event Log and the Check Page

The Graphs page plots the rain rate, the rainfall, the switch and the tips. The Event log follows the storm minute by minute. The Check page sums up the run: 10.34 mm of rain in 25.5 scene minutes, 0 mm/h now; 37 tips of 0.2794 mm; the switch open with 5.00 V across it; 37 re-closes after a bounce; and the clock at x 60.

Figure: The Graphs page.
Figure: The Event log.
Figure: The Check page.

The monitor shows the sketch's side: every change of class, and a line every two seconds with the scene minute, the rainfall, the rate, the tips and the bounces.

Figure: The monitor.

A Rain Gauge, a Rain Sensor and the Wind

Our Rain Sensor Library for Proteus is a different thing: a board of interleaved tracks that tells you whether it is raining - handy to close a window or stop a sprinkler - but not how much. The rain gauge measures the amount. Put it on a pole with our Anemometer Wind Speed Sensor Library for Proteus and our Wind Vane Direction Sensor Library for Proteus and you have the three classic instruments of a weather station: wind speed from pulses, wind direction from a resistor ladder, and rain from the tips of a bucket.

Try It Yourself

  • Remove the debounce line from the sketch: the tip count doubles - every tip and its bounce.
  • Click Storm 100: a tip every 0.17 s, the bars run full and HEAVY lights.
  • Click Drizzle 2: a tip only every 8.4 s at SPEED 60 - the rate reads zero between tips; a longer window would smooth it.
  • Set SPEED to 1 in the gauge and in the sketch: real time - and a long wait between tips.
  • Set TIP to 0.2 and change the sketch's TIP: the count rises, the rainfall stays the same.

Ideas to Extend the Demo

  • Keep today's and this month's rainfall in the EEPROM so a power cut does not lose them.
  • Add our anemometer and wind vane for a complete weather station.
  • Send an alert when the rate stays above 30 mm/h for ten minutes - a flash flood warning.

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real Rain Gauge

  • Your gauge's tip: check its amount - 0.2794, 0.2, 0.254 or 0.3 mm - and set TIP; SPEED is 1 for a real gauge.
  • Level and clear: mount it level, above splashing and away from walls and trees; clean the funnel's filter of leaves and insects.
  • Interrupt and debounce: count with an interrupt and ignore 20 ms after each tip; a long cable may need a small capacitor too.
  • Heavy rain: tipping buckets under-count a little in a cloudburst - water keeps arriving while the bucket moves.
  • Winter: snow sits in the funnel and is counted only when it melts.

Troubleshooting

  • The count is twice too high: no debounce - ignore edges for 20 ms after a counted tip.
  • Nothing is counted: no pull-up on the input, or the other wire not on ground.
  • The rate is 60 times too high: the demo's clock - divide by SPEED, or set the gauge's SPEED to 1.
  • The rate jumps in steps: only a few tips in the window - a longer window smooths it.
  • The part is not simulated: TEPRAINGAUGE.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The bucket, the tips and the reed switch work the way tipping-bucket gauges work; the gauge is our own drawing, compact, with a window into it.
  • Our own choices: the switch's 0.1 ohm and 100 Mohm, its 60 ms and one bounce, the storm, the fast clock and the drawing.
  • Not modelled: the under-count in very heavy rain, evaporation, wind, the funnel's delay and snow.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or any gauge maker.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the Rain Gauge Library for Proteus Simulation. I hope it helps you build your weather station, your garden logger or your flood warning before the gauge goes up the pole - and shows that measuring rain is a simple idea done well: a see-saw, a magnet, a switch and a counter. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!