Arduino Rain Gauge Calibration


Introduction: Arduino Rain Gauge Calibration

About: Recovering Physicist.


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.



    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest
    • Clocks Contest

      Clocks Contest

    17 Discussions


    4 months ago

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


    8 months ago

    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?

    2 replies

    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?

    1 reply

    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.


    1 reply

    Hi Ahmad,

    Thank you for taking an interest in this Instructable.

    1. I used the adafruit library from github, the link is below.

    In that page, there is a pink-horizontal-bar. Just below that to the right is the "Download ZIP" button. Click there to get the RTC library.

    2. The Wire.h library as seen in
    has been used to provide connection to the RTC using the two
    connections SDA and SDC. It is called the I2C protocol. It reduces the
    connecting wires specially if you have many I2C devices like LCD display
    with I2C, RTC with I2C, etc. Any device that has pins labelled SDA and
    SDC uses I2C protocol/procedure 'usually' and for using them the wire.h
    library must be included in the sketch.

    Do let me know if you need any further clarifications.


    Thank you for the reply.

    For the RJ11, which the one I think been using the Wire.h library, I don't have to use a separate wire to connect the reed sensor to the arduino. I directly connect the wire to 2 digital input terminal. For that, I managed to get the 1 and 0 in the serial monitor of arduino or is this an incomplete step?

    In the response above you said "Wire.h has been used to provide connection to the RTC using the two connections SDA and SDC." However you are not using any external RTC devices. So do you mean has been used to provide connection to the Arduino using the two connections SDA and SDC?

    If possible, can we communicate in other kind of medium, perhaps email or facebook? I'm in the middle of doing this kind of project and would like to ask your guidance along the way. Here is my email in advance,


    Thank you for coming forward and raising your much justified queries.

    I used the RJ11 for connecting/disconnecting the my rain collector
    conveniently, nothing else. As you have meant, you can connect the
    arduino directly to the reed sensor/magnetic switch.

    2. One more
    point (maybe you already know) about the magnetic switch connection. You
    would observe that whenever the switch gets connected, +5V lands
    directly on D2 of arduino and it interprets the signal as 1. On the
    other hand if the same switch is open, the D2 gets a voltage of 0V from
    the ground (GND) via the 15K resistor. The interpretation is 0. The 15K
    resistor ensures that there is no short between the +5V and GND when the
    switch is closed. Without this extra bit of connection the arduino's D2
    pin may be puzzled as to what is the input whenever the switch is open.

    3. I am truly sorry that I limited my clarification about RTC (which I looked up from another sketch, my bad). This particular sketch used the RTC library to keep time, it was "software form". And wire.h followed.
    (other times you may use an actual RTC to keep the time and yet other
    times an ntp via internet can keep the time). It uses the clock of the arduino to
    give us the time (i think) and gets reset every time the arduino is
    powered off. I think I may have exhausted my knowledge about RTC:) Time keeping was required to measure rainfall during the last
    hour or total rain for the day. They both get reset every hour and every
    night respectively.

    4. Like you I am also a newbie and self
    taught. If you want to show your data over the internet, you may like to
    use some sort of Ethernet shield like
    or GSM shield for SMS (i declare ignorance). At present I am using an
    Ethernet Shield for my weather station which is still in trouble
    shooting phase. My weather station reports.

    For facebook (i declare ignorance again) some sort of FTP should be done, but I am not the guy:)

    Very nicely done. I like the well-written thorough documentation.

    By the way, I am currently rebuilding my weather station. After many years of use, the ethernet cable has deteriorated and was no longer functional. (I did not use outdoor cable and it was out in the weather. Anyway, my basic sensors will be the same but am hoping to make it wireless.

    Be interested to see how your weather station progresses.

    Lazy Old Geek.

    1 reply