Welcome to this tutorial for making your own rain gauge! The catch here is that we are going to model a house with its green roof. As you know, green roofs are becoming more popular because of their ability to storage water during rainfall. Although the green roof works perfect as a bassin, its potential is much bigger.
In the science of hydrology, rainfall data is inexplicably one of the most hardest parameters to measure. Even with high-tech radars, we still can't certainly tell when it's going to rain and more importantly, how much rain is going to precipitate. Green roofs can fullfil as a tool to close this data gap. Their positions are mostly ideal (there will be no interception of the rainfall) and because of the rainfall, users can determine how much water they would want to be stored at a particular moment.
To test if we can use a green roof as a rain gauge, we can build a model of a house and try to measure rainfall on it. For this, you will need a Photon and some sensors which will be mentioned later on.
Enjoy and most importantly, have fun!
Step 1: Build a House and Roof!
This is relatively the easiest step of the process! Make sure to build a house with correct measurement! Length, width and height should preferably be the same. A recommended area (length x width) would be 20 x 20 cm.
Make sure to leave one side of the "cube" open so we can put our Photon there. Then make three holes on a side connected to the open side (this is going to be our ceiling. Make the holes in a triangle form, relatively close to each other (see the photo for a better view).
The next step is to make three small cylinders. After you have done this, glue them at the same side as the holes you made in a triangle form.
The last step is to make our roof! This is easy; make sure to have the same length and width as your house, but make the height relatively small. In the example, the roofs height is four times smaller than the height of the house.
Step 2: Setting Up Photon and Pressure Sensors!
We are now done with building the house, but to measure anything, we need our sensors which is why we need a Photon!
The principle of this concept is that the at the bottom of the green roof, on top of the three cylinders, we are going to measure the pressure. When there is rainfall, this pressure will increase and with a calibration step, we can calculate the amount of rainfall!
So our photon needs to be connected to the cylinders with pressure sensors. In the example, pressure has been measured with FSR 402 sensors. Photon setups for these sensors can be found in their manual. You can glue the sensors on your cylinder. If you want to increase the sensitivity of the sensor, you can glue a small iron wire on top of the sensors.
Step 3: Programming Your Photon
The last step of our green roof rain gauge is to program the Photon. The example here is made for specific connections to certain ports of the Photon, so make sure you put your own variables in there
#define DEBUG_SERIAL TRUE
//define your topic, title and name
const String topic = "your/own/topic";
//Sensors are connected to these pins, make sure to have the same or rename them to your own input
const int analogPin0 = A0;
const int analogPin1 = A1;
const int analogPin2 = A2;
//number of seconds between uploads to the Spark Cloud. This may never be lower than 60 //because IFTTT does not allow for more triggers than 1 per minute.
const int intervalOnline = 60;
//number of seconds between uploads over the USB serial
const int intervalSerial = 10;
//number of milliseconds between measurements. This could be as low as needed, but higher values //results in a more stable behaviour of the ADC.
const int intervalMeasurement = 10000;
int measuredValue0 = 0;
int measuredValue1 = 0;
int measuredValue2 = 0;
int mean_pressure = 0;
int pres_old = 0;
int diff = 0;
int total_time = 0;
float total_rain = 0;
float added_eachother = 0.0;
String pressureString = "";
//start Serial communication
if (DEBUG_SERIAL) Serial.begin(9600);
//set the inPin to INPUT
//every intervalMeasurement milliseconds, do a measurement
measuredValue0 = analogRead(analogPin0);
measuredValue1 = analogRead(analogPin1);
measuredValue2 = analogRead(analogPin2);
mean_pressure = ((float)(measuredValue0 + measuredValue1 + measuredValue2))/3.0;
diff = mean_pressure - pres_old;
total_rain = ((diff/0.117778)/(17.0*17.0)) * 10.0;
added_eachother += totale_regen;
pres_old = mean_pressure;
pressureString = String(added_eachother,4);
total_time += 10; delay(1);
//every intervalSerial seconds, send measurement over Serial USB
//every intervalOnline seconds, publish measurement to Spark Cloud
String measurementText = String(diff, DEC);
Particle.publish(topic, pressureString, 60, PUBLIC);
Step 4: Adding Extra Features
To make your rain gauge even fancier you could add a few features. In this example, we have added a window which will close at heavy rainfall (of course relative to your own situation). Before actually closing, two red LED-lights will light up, warning people the window is closing and there is heavy rainfall. The lights are lit during the whole rain event and the window is closed. When the rain stops and is drained off the window will open and the lights will turn off.