Arduino Rain Gauge Calibration





Introduction: Arduino Rain Gauge Calibration


In this Instructable we 'construct' a rain gauge with Arduino and calibrate it to report daily and hourly rainfall. The rain collector I am using is a re-purposed rain gauge of the tipping bucket type. It came from a damaged personal weather station. However there are a lot of great Instructables on how to make one from scratch.

This Instructable is a part of a weather station I am making and is a documentation of my learning process disguised as a tutorial:)

Characteristics of the Rain Gauge:

  • measurements of daily and hourly rainfall is in inches for easy upload to Weather Underground.
  • debouncing code for the magnetic switch is not included to keep the code simple.
  • being more of a tutorial the finished product is more of a prototype of a prototype.

Step 1: Some Theory

Rainfall is reported/measured in millimeters or inches which has the dimension of length. It is indicative of how high, every portion of rain area got the rain, if the rain water had not dissipated and drained away. So, a 1.63 mm of rainfall would mean that if I had a flat leveled tank of any shape the rain water collected would be of a height 1.63 mm from the tanks bottom.

All rain gauges have a rainfall catchment area and a rainfall amount measurement. The catchment area is the region over which the rain is collected. The measuring object would be some kind of volume measurement for a liquid.

So the rainfall in mm or inches would be

rainfall height = volume of rain collected / catchment area

In my rain collector, the length and breadth were 11 cm by 5 cm respectively giving a catchment area of 55 So a collection of 9 milliliters of rain would mean 9 cc/55 = 0.16363... cm = 1.6363... mm = 0.064 inches.

In the tipping bucket rain gauge, the bucket tips 4 times for 9 ml (or 0.064... inches of rain) and so a single tip is for (9/4) ml = 2.25ml (or 0.0161.. inches). If we take hourly readings (24 readings per day before resets) keeping three significant digit accuracy is decent enough.

Thus, at each bucket tip/tumble, the code accesses it as 1 on-off-on sequence or one click. Yes, we have reported 0.0161 inches of rain. To repeat, from the Arduino point of view

one click = 0.0161 inches of rain

Note 1: I prefer the International System of Units, but Weather Underground prefers the Imperial/US units and so this conversion into inches.

Note 2: If calculations are not your cup of tea, head over to Volume of Rainfall which provides perfect help for such matters.

Step 2: Parts for This Project

Most of the parts were lying around and a fair listing (for formality) is

  1. Arduino Uno (or any other compatible)
  2. Rain Gauge from old damaged weather station.
  3. Breadboard.
  4. RJ11 to connect my Rain Gauge to the breadboard.
  5. 10K or higher resistor to act as a pull up resistor. I have used 15K.
  6. 2 pieces of male-to-female jumper wires
  7. 2 male-to-male jumper wire.
  8. USB Cable; A Male to B Male


  • Syringe (12 ml capacity was used).

Step 3: The Rain Collector

The photos of my rain collector should make thing clear to many. Anyway, the rain that falls on its catchment area gets channeled to one of the two tipping-buckets inside it. The two tipping-buckets are connected like a see-saw and as the rain water weight ( 0.0161 inches of rain for mine ) tips one bucket down it gets emptied and the other buckets goes up and positions itself to collect the next rain water. The tipping motion moves a magnet over a 'magnetic-switch' and the circuit gets electrically connected.

Step 4: Circuit

To make the circuit

  1. Connect digital pin #2 of Arduino to one end of the resistor.
  2. Connect the other end of the resistor to the Ground pin (GND).
  3. Connect one end of the RJ11 jack to the digital pin #2 of Arduino.
  4. Connect the other end of the RJ11 jack to the +5V pin of Arduino (5V).
  5. Plug the rain gauge to the RJ11.

The circuit is complete. Jumper wires and breadboard make the connections easier to make.

To complete the project connect the Arduino to the PC using the USB cable and load the sketch provided below.

Step 5: The Code

The sketch RainGauge.ino (embedded at the end of this step) is well commented and so I shall point out three sections only.

One part counts the number of tipping-bucket tips.

if(bucketPositionA==false && digitalRead(RainPin) == HIGH){

Another part checks time and computes the rain amount

if(now.minute()==0 && first == true){
	hourlyRain = dailyRain - dailyRain_till_LastHour;

and another part clears the rain for the day, at midnight.

if(now.hour() == 0){
	dailyRain = 0;

Step 6: Calibration & Testing

Disconnect the Rain Collector from the rest of the circuit and perform the following steps.

  1. Fill up the syringe with water. I fill mine with 10 ml.
  2. Keep the Rain Collector on a level surface and pour out the water from the syringe bit by bit.
  3. I keep a count of the tipping buckets. Four tips were enough for me, and drained 9 ml from the syringe. According to calculations (see theory section) I got the amount of 0.0161 inches of rain per tip.
  4. I include this information into my code in the beginning.
const double bucketAmount = 0.0161;

That's all to it. For more accuracy, one can include more digits like 0.01610595. Of course your calculated numbers are expected to vary if your Rain Collector is not identical to mine.

For testing purposes

  1. Connect the Rain Collector to the RJ11 socket.
  2. Connect the Arduino to the PC using the USB cable.
  3. Open the serial monitor.
  4. Pour previously measured amounts of water and observe the output when the hour completes.
  5. Do not pour any water but wait for the next hour to complete. The hourly rain must be zero in this case.
  6. Keep the PC with the connected circuit powered overnight and see if the daily rain and hourly rain get reset to zero at midnight. For this step, one can also change the PC's clock to a suitable value (to watch the outputs on the serial monitor live).

Step 7: Afterthoughts & Acknowledgements

The resolution of the rainfall readings in my case is 0.0161 inches and cannot be made more accurate. Practical circumstances may decrease the accuracy further. Weather measurements do not have the accuracy of quantum mechanics.

Part of the code was borrowed from Lazy Old Geek's Instructable.



    • Space Challenge

      Space Challenge
    • Microcontroller Contest

      Microcontroller Contest
    • Spotless Contest

      Spotless Contest

    We have a be nice policy.
    Please be positive and constructive.





    Thanks for sharing the project.
    i have some questions:
    1- why the rtc doesn't show the same time as my computer?
    2- if i want to save all the data i get from arduino and make a database in a file, is it better to make it inside arduino code? or save it in an EPROM for example? or make it by compute (the systems keeps sending the data to the computer, and the computer stocks the data)?

    This is great and this worked for me. can you please share code for wind direction if you have. It will be great. I am implementing cloud based Weather station with NodeMCU and Maplin weather station spare parts ( Wind speed, wind Direction and Rain Gauge ) .

    This is great, and seems to work for me. I assume you'd be able to change the code so that it could record total rainfall at a higher resolution? For example total for 15 minutes (or even more frequent!), as well as hourly and daily? Would this be an easy thing to add to the code?

    In fact this project was created as I wanted to repurpose a weather station rain and wind sensors with an Arduino. It worked fine, uploading data after every 15 minutes (to weather underground) untill a hailstorm totalled them.

    Such Arduino codes are available all over the internet ( and I shall be glad to share mine too).

    So, my issue on this has to do with the conversions on 2 parts. The first is this part:
    "9 cc/55 = 0.16363... cm = 1.6363... mm = 0.394 inches"
    So as I do the calculations, 9 cc/55 does equal 0.16363 cm which does equal 1.6363 mm. BUT, as I do the conversion to inches, I come up with 1.6363 mm = 0.06442 inches, not 0.394 inches.
    Next is this:
    "In the tipping bucket rain gauge, the bucket tips 4 times for 9 ml (or 0.394... inches of rain) and so a single tip is for (9/4) ml = 2.25ml (or 0.0161059413027953.. inches)"
    So 9/4 is in fact 2.25, but if you say 9 ml = 0.394 inches of rain, if I take 0.394/4 =0.0985, not 0.0161059413027953 inches.
    Can you explain how you came to these numbers?

    Two points from my side:

    1. Thank you for spotting the error. I have corrected it.

    Please accept my apologies too. I cant figure out, or explain, how on
    earth I put in the strange number "0.394" instead of the 0.0161 which
    you have suggested.

    If you make a mistake and do not correct it, this is called a mistake.”— Confucius

    Thank you again.

    Nice to see you re-purpose the rain gauge. I have one in my parts bin for future use.


    Can you provide the RTC library you are using?