Build a Wireless “Tipping Bucket” Rain Gauge, Part 3—Receiver, PICAXE, and LCD
Here's a rain gauge that empties itself and that you can read from your easy chair. Best of all, you can build it, yourself.
Here's a rain gauge that empties itself and that you can read from your easy chair. Best of all, you can build it, yourself.
This article is part 3 in a series of three detailing the construction of a wireless tipping bucket rain gauge.
Part 1 described the mechanical construction of the bucket and the housing for it. The electrical connections and the instructions for the transmitter portion of the wireless controls were defined in part 2.
Part 3 focuses on the receiver, the PICAXE 08M2 microcontroller, and the LCD (liquid crystal display) that will be used to show the rain data results.
For the best understanding of the project, you should read both parts 1 and 2 prior to this article. In addition, this article presupposes a working knowledge of using PICAXE microcontrollers, but, as you can read here, they are easy to learn.
This is the third in a series of three articles; each includes its own parts list. The parts required for completion of the project are listed in the following table.
|Part Ref.||Description||Source||Item No.|
|R1||Resistor, 1/4W, 22k Ohms||Digi-Key||22KQBK-ND|
|R2, R3, R4||Resistor, 1/4W, 10k Ohms||Digi-Key||10KQBK-ND|
|R5||Resistor, 1/4W, 330 Ohms||Digi-Key||330QTR-ND|
|C1||Capacitor, ceramic, .1uF, 50V||Digi-Key||399-9797-ND|
|LED1||Diode, Light Emitting, Red, T1 3/4||Jameco||333973|
|SW1||Switch, Momentary Pushbutton||Digi-Key||450-2038-1-ND|
|U1||Microcontroller, PICAXE 08M2+||PHAnderson.com||PICAXE 08M2+|
|J1||Jack, 3.5mm, 3-Conductor||Digi-Key||CP1-3533NG-ND|
|RFR1||Receiver Module (part of Xmtr/Rcvr Pair) 315 MHz||On-line/Off-shore||See text|
|N/A||Breadboard, Solderless, 400 Contacts||Digi-Key||377-2094-ND|
|N/A||Wire, Insulated, Solid, 22 AWG, Assorted Colors||Jameco||2153705|
|N/A||Power Supply, Regulated, 5VDC, 500mA (min.)||A/R||See text|
|N/A||16x2 LCD & SMDLCD117 Bundle, 2400 Baud||Modern Device||See website|
There are at least two versions of the 315 MHz keyfob transmitter and receiver modules; the differences between the old and new versions of the transmitter were explained in part 2. Although functionally equivalent, the PCB layouts and pinouts of the old and new versions of the receiver are significantly different, as shown in the following photograph.
As you can see, both modules have seven pins along the bottom edge, including four pins (D0 - D3) which go high whenever one of the four ABCD buttons on the transmitter is pressed. However, the correlation between the physical location of each pin and the button it represents is completely different from the old version to the new.
In addition, the power pins are not labeled identically; the positive power pin is labeled VCC on the old module but is labeled 5V on the new. Both modules have a VT pin, which goes high whenever any one of the ABCD transmitter buttons is pressed. Both receivers have a single solder pad for the antenna connection.
Either module will be fine for this project as long as you remember the differences in the pinouts and make allowances for those differences in your wiring and assembly. This article is based on an old model receiver, and you will have to "translate" all instructions regarding the receiver connections if you are using a new model receiver.
The first step in building the receiver circuit is to cut a 9-inch length of insulated 22 AWG wire, strip 1/8 inch of insulation from one end, and solder it in the antenna pad on the receiver module.
Simplicity is one of the main features of the receiver circuit as shown in the schematic diagram.
The receiver module is represented in the upper left of the drawing and the pins are shown in the same left-to-right order as they appear on the actual PCB assembly. Thus, the only connections required to the receiver are as follows.
- Pin 3, labeled "D1" on the PCB which corresponds to the "C" button on the transmitter, is connected to pin C.3 (leg 4)* on the PICAXE 08M2 as well as to LED1 through a 150-ohm resistor.
- Pin 5, labeled "GND" on the PCB, is connected to the Com node.
- Pin 7, labeled "VCC" on the PCB, is connected to the +5V supply.
- The antenna pad is connected to the antenna.
Switch SW1 is a pushbutton switch which will be used to reset the rain gauge reading to zero. PH1 represents the connection to the external serial LCD for displaying rainfall data.
* If you have forgotten, or maybe never knew, the difference between "pin" and "leg" numbers on PICAXE chips, you should read this article.
Solderless Breadboard Assembly
The photographs below show the solderless breadboard assembly. Note that wire colors in the photographs agree with the wire labels on the schematic drawing above.
Follow the photos and the circuit diagram to construct your own assembly. You will need a well filtered and regulated 5VDC power supply. Complete plans for the one shown in the photos are located here.
The LCD (liquid crystal display) used in this project is a 2x16, which means it has two rows of characters with 16 characters in each row.
In addition, it is has a "serial" interface instead of "parallel." That means that the data to be displayed is sent in a string of bits one after the other, a feature which is made possible by a serial to parallel converter that attaches to the rear of the LCD printed circuit board. The benefit of serial over parallel is that a single microcontroller pin is all that must be dedicated to getting data to the display.
The serial to parallel adapter used in this project was designed by the late Peter Anderson and has become very popular with µC enthusiasts of all kinds.
In the photo below, you can see the only three wires necessary to use the LCD: black is common, red is +5V, and white is the signal lead.
The parts list provides ordering information for the serial adapter (be sure to get the 2400 baud version) but if you are interested in learning more about serial LCDs, this article should be informative.
The obvious way to write the code for this project is to have the microcontroller (1) count the number of times the bucket tips, (2) calculate how much rainfall each tip total represents, and (3) display the results on the LCD. Easy, right?
Unfortunately, the entire PICAXE family is math challenged; in fact, not one of them has floating point math capabilities, so step two is a problem.
Perhaps there are clever ways to manipulate the data and get correct answers from the PICAXE, but a much easier way for this project is to simply take the calculations off-line to an Excel spreadsheet, part of which is reproduced here, and which is available below for downloading.
There are two data points that you must enter into the spreadsheet: the volume of your tipping bucket and the ID (inside diameter) of the top of your funnel. Excel can then do the heavy lifting.
If you followed the components list in part 1 of this series, the ID of the funnel is already correct at 3.5 inches—but if you used a different funnel, simply measure the top of it and enter the inside diameter in the appropriate cell.
Measuring the capacity of your tipping bucket is only a little more difficult. One way is to place the assembly on a level surface and use a syringe calibrated in cubic centimeters (aka milliliters) to drip water into the funnel until the bucket tips, and record the amount of water it took to reach the tipping point. Repeat the process a few times on both sides of the bucket, average the readings, and enter the bucket capacity. Don't forget that you can make small changes in bucket capacity by using the adjustment screws on the bottom of the assembly.
Once that is done, each tip total beginning at 0 will show in the columns labeled "Calculated Rain" and "Rounded Rain". The rounded numbers are of primary interest because they should be entered in lines 36 through 418 of the actual PICAXE code, as shown in lines 36 through 54 below.
The code is well commented and should be easy to understand, but if there are parts that you aren't sure about, especially the use of the case select operation, have a look at this article.
Notice that the program provides 95 case selections to choose from. Each case represents one bucket tip total, and 94 of them provide the corresponding rainfall total to display . . . at least they will after you enter the corresponding digit data from the spreadsheet.
Of course, if your bucket holds exactly 5 cubic centimeters and the inside diameter of the top of your funnel is 3.5 inches, the work is already done. But if your bucket is larger or smaller, or your funnel is something other than 3.5 inches ID at the top, you will need to enter three digits in 94 of the 95 cases. It won't take as long as you think, but be sure to measure your bucket capacity and funnel carefully and enter the correct data in the code.
Installation and Operation
The outside assembly should be located in an open area a few feet off the ground to keep it out of the dog's way. It should be as level as possible and the adjustment screws on the bottom should be accessible.
A wooden post is preferred over metal if the antenna will be hanging down in close proximity to the post. You might want to orient it so that the clear plastic cover is visible from your favorite window, and you can see the LED light as the bucket tips. There is no on/off switch; just be sure that the 9-volt battery is fresh and properly connected.
The communication range between the outdoor and indoor assemblies should be quite good. Testing has shown it to be over 75 yards in the open, but a wall or two in between will reduce that somewhat.
The inside assembly should be located wherever it is convenient to see and where the AC-to-DC power supply can be plugged in. You may find that you want to modify the code as part of the calibration process but, when that's all done, you can remove the programming jack and its wires from the solderless breadboard. If you decide to make it a long-term addition to your decor, your significant other might be pleased if you put it in a nice box.
Operation couldn't be simpler. Turn on the power to the receiver assembly and wait for rain. Press the reset button to set the tips back to zero. The maximum number of bucket tips accounted for in the code is 94, which should correspond to about 3 inches of rain. If the tip count reaches 95, the counter will reset to zero and start again.
Electronically, there isn't much that can go wrong with the system, but there are some mechanical issues that may crop up.
- Applying beeswax to the inside of the bucket areas will reduce the tendency for drops of water to stick to the bucket and not be dumped when the bucket tips.
- During hard rains, water may run into the bucket with so much force that it overflows the bucket in which case the gauge will under-report the amount of rain. A small piece of window screen wire inserted into the top of the spout of the funnel will help slow down the flow rate.
- During very light rains, the water may fill the bucket so slowly that it doesn't tip as soon as it's full, which will also cause the gauge to under-report the amount of rain. A shot of silicone lubricant to the pivot pin on both sides of the bucket should help the bucket tip more easily. Don't use oil because it could attract contaminants and then restrict the tipping action even further. If silicone doesn't solve the problem, you may have to remove the bucket from the pivot pin and smooth the edges of the holes in the bucket and the pivot points on the pin. Fine tuning the tipping point with the adjustment screws may also be required; turn the screws clockwise to make the bucket tip more easily.
- If you determine that your gauge is consistently wrong when compared to a quality glass tube rain gauge placed nearby, you will need to recalibrate your bucket gauge by changing the bucket volume in the Excel spreadsheet, and modifying the PICAXE code accordingly. For example, suppose that you observe that the bucket gauge reports 1.01 inches of rain and a quality glass tube rain gauge reports 1.2 inches of rain over exactly the same time period. That would mean that your bucket volume in the spreadsheet would need to be increased by 18.8%; if it was 5 cc., you should increase it to 5.94 cc.
What Else Could You Do?
If you'd like to take your project to the next level, you could:
- make another receiver module (or several) for your neighbors or other rooms in your castle
- add an ESP-01 Wi-Fi module to report the rainfall to your computer or the internet
- change the display (and the code) from a 2 line by 16 column to a 4 line by 20 column
- add a real-time clock in order to reset the count every night at midnight
- modify the code to keep a running average of the time between bucket tips and calculate the rainfall rate
- other good stuff that only you can think of
Have fun and be creative!
Oh, and don't let the neighbors see you standing out in the rain watching the bucket tip back and forth. They won't understand.
Give this project a try for yourself! Get the BOM.