Using an Arduino with a Tipping Bucket Rain Gauge
HTML-код
- Опубликовано: 27 окт 2018
- I create all this content for the greater good with everything licensed under Creative Commons. At the same time your support is genuinely appreciated- tips are welcome via this link:
www.buymeacoffee.com/mmaker
NOTE: Update posted 1/8/2020: • Argent Weather Station... (start at minute 14:31)
UPDATE 2/18/2020:
--- At minute 7:20, I revisited this code based on correspondence with Argent Data Systems and a review of libraries prepared for their hardware. If I set the debounce constant to 15, and then multiply it by 1000 on line 56 of the code, this eliminates the problematic bounce demonstrated at 7:35. With this edit, the code does execute successfully with the bounce filtered out. In response, I updated the sketch "weatherStationMod3_g" available on www.modestmaker.com/arduino/pa... under "Chapter 9" with these edits.
--- The successful code modification and tests suggests I can use a reed switch in a tipping bucket rain gage coupled with an Arduino without needing to incorporate an RC circuit and a Schmidt trigger, or replacing the reed switch with a Hall Effect Sensor. However, these alternatives are mechanically and electrically sound while simplifying the code.
--- At minute 8:29, I incorrectly stated: "Interrupts.... generally should not be used with timers that take more than a microsecond to execute". That is incorrect - I should have stated "millisecond" rather than "microsecond".
-- At minute 8:55, I incorrectly state there is a delay in my interrupt function. This is incorrect - there is no delay in the interrupt function shared in my code.
In this video, I reverse engineer how tipping bucket rain gages work, and then demonstrate how to integrate an Arduino for counting tips, which can then be translated to rainfall depth. I then demonstrate software and hardware remedies for filtering out bounce noise associated with the reed switch used in these instruments. UPDATE: Please see January 1, 2020 correction posted in comments section.
Schmitt trigger used in this demonstration available here: www.digikey.com/product-detai...
Images used for gauge explanation came from these links: www.researchgate.net/figure/W...
and
www.explainthatstuff.com/howr...
Details on assembly your own gauge available here (wireless component not necessary):
www.allaboutcircuits.com/proj...
Code uploaded here:
modestmaker.com/arduino/part2... Наука
Very nice, I came to just find out if a rain gauge could be used with an Arduino - I actually learned more than I thought I would. thank you
Wonderful - glad it helped! I'm still learning myself - I've posted an update here: ruclips.net/video/KHrTqdmYoAk/видео.html
Wow amazing Informations and cool Video
Glad you liked it!
Hi ModestMaker, great video and explanation!
Hope you can clarify one question I've got. At 8:09 you said that you found out that it [fixing bouncetime to calibrate 1 count / tip] was not a stable solution over longer periods of time. How did you found out? Over which timespan? Many thanks!
I tested this approach over the course of just a few minutes using different delays, and it eventually compounded tips regardless of the constant. I subsequently learned that delays of more than a few microseconds in an interrupt function is just not a good idea.
With no disrespect, I would use a Hall Effect Magnetic Sensor Module as it has debounced built-in so that would solve all your problems and be very reliable as there are no moving parts but you will need three wires and if it is a long way away you could get voltage drop on the cable but I used one for a security switch circuit that worked very well, Love your channel have joined as you are covering the current sensor INA219 that I want to use to monitor current in a colloidal silver generator I want to make, Thanks Bob in the UK
Thanks Bob. I am in total agreement. I was not familiar with Hall Effect sensors until after I posted this video and have since picked up a few on eBay. These old rain gauges can be easily hacked for the same, and I hope to post an update shortly. I am a little distracted these days with my kids who've asked me to build stuff for them instead of work ;) Cheers!
Update posted with Hall effect sensor demo: 1/8/2020: ruclips.net/video/KHrTqdmYoAk/видео.html
Awesome stuff! I subscribe.
Thanks interesting lesson, and can I use a Hall sensor with magnet on a Arduino pin 3 ?
Yes. This is explained /demonstrated in subsequent tests, cued here: ruclips.net/video/KHrTqdmYoAk/видео.html
Hi, great job you do. I like to ask you what happen in the 13:48 minute? why can not see the counts 10, 12, and 15? in the quick and rapid move
I suspect the baud rate on the serial terminal couldn’t keep up with the action, but I closely monitored the total count and can confirm it was correct.
Hi! Thank you soo mucho for this video. Step-by-Step guide, have it?
Unfortunately not for rain gages, but I do have this which contains some background on microcontrollers and environmental monitoring in general - see description of video: ruclips.net/video/jEO_OjcrRfM/видео.html
UPDATE 2/18/2020:
--- At minute 7:20, I revisited this code based on correspondence with Argent Data Systems and a review of libraries prepared for their hardware. If I set the debounce constant to 15, and then multiply it by 1000 on line 56 of the code, this eliminates the problematic bounce demonstrated at 7:35. With this edit, the code does execute successfully with the bounce filtered out. In response, I updated the sketch "weatherStationMod3_g" available on www.biod101.com/arduino/part2.html under "Chapter 9" with these edits.
--- The successful code modification and tests suggests I can use a reed switch in a tipping bucket rain gage coupled with an Arduino without needing to incorporate an RC circuit and a Schmidt trigger, or replacing the reed switch with a Hall Effect Sensor. However, these alternatives are mechanically and electrically sound while simplifying the code.
--- At minute 8:29, I incorrectly stated: "Interrupts.... generally should not be used with timers that take more than a microsecond to execute". That is incorrect - I should have stated "millisecond" rather than "microsecond".
-- At minute 8:55, I incorrectly state there is a delay in my interrupt function. This is incorrect - there is no delay in the interrupt function shared in my code.
Field tests have not yet been conducted. Thanks for your patience as I become better acauainted with these instruments and electronics.
Thanks for the info. I have a 20+ year old Dallas One Wire weather system that I am converting to Arduino. I have a tip bucket rain gauge and I was not sure how to integrate it into Arduino. I gave up on Dallas One wire sensors and went with Adafruit BME280 for Temp, Humidity and Barometer on a I2C bus. Very simple and works great. I added a Ethernet shield onto a Arduino Mega 2560. It records the weather sensor data to the SD card on the shield. I can read the data file over my network. The last sensor to add is the rain gauge.
Sounds great! Hope it works out. If you deal with heavy rains, make sure to check out the accuracy check on these tipping buckets. ruclips.net/video/iR331RDdPW4/видео.html . I will be experimenting with a strain gage shortly to measure weight as an alternative. I just need to figure out how to empty the gage between storms.
The Schmidt trigger used in the demonstration is out of stock on Digikey, is there a reasonable alternative?
I have some in stock I can drop off at SRO (assuming this is Jason Elliot), but you might try a Hall effect sensor as a simpler alternative.
There is a solution to debounce with the microcontroller.
You just have to wake up the µC with the Interrupt. Then perform the debounce in the loop() function. After that you can go to sleep again.
Using this way you have a much easier and cheaper setup.
Thanks - if you have some code you might share, I'd be glad to test it and post.
@@ModestMaker I can send you an example, how can I contact you?
The code should be relatively short - can you post it as a comment?
This should work (not tested)
#define RAIN_PIN 2 // interrupt pin
#define DEBOUNCE_TIME 15 // time * 1000 in microseconds required to get through bounce noise
unsigned long timer;
volatile unsigned int rainTrigger = 0;
volatile unsigned long lastTrigger = 0;
volatile bool stateChanged = false;
void setup() {
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(RAIN_PIN), countingRain, RISING);
pinMode(RAIN_PIN, INPUT);
nextCalc = millis() + CALC_INTERVAL;
}
void loop() {
timer = millis();
if(stateChanged)
{
bool Value = digitalRead(RAIN_PIN);
if(!Value)
{
stateChanged = false;
}
else if((timer-lastTrigger)>=DEBOUNCE_TIME
{
rainTrigger += 1;
stateChanged = false;
Serial.print("Total Tips: ");
Serial.println(rainTrigger);
}
}
}
void countingRain() {
lastTrigger = millis();
stateChanged = true;
}
But I would recommend you to send the microcontroller into deep sleep. Then you could easily run this on battery.
One more hint: The debouncing you used (and the one I did too) is not a true debouncing. It debounces only the rising edge and not the falling edge. For this use case this should not be a problem but for others it might be.
Where did you get the tipping bucket from?
please increase the volume speaker...
nice explanation, thanks
Ok next time.thanks!
How do you calibrate the rain fall in relation to the area of the collection bucket surface area?
Great question! I cover the calculations and accuracy checks in this video, which I've cued of your convenience: ruclips.net/video/iR331RDdPW4/видео.html
@@ModestMaker well done, thanks very much
Can u please explain,How was the arduino protected from rain in the field?
Usually, just by embedding my electronics in a weather proof enclosure - like this one ;) ruclips.net/video/93ipPhr7QtQ/видео.htmlsi=hM7NnXB3yc_QcpZL&t=1. Advance to minute 17:50 for more about the enclosure.
hey is there any way that i can contact you ask you about this project because i need help for my final year project
I have an update to this video you might check out here:ruclips.net/video/KHrTqdmYoAk/видео.html
Where do you get this rain bucket?
it was borrowed from work. I think you can find these on eBay occasionally.
Hi sir, have u finished his project?
I'll attached it to an REM shortly - have been working on a remote air quality monitor that I can attach to my bike, so it has had me a little distracted ;)
Just finished the latest post: ruclips.net/video/jaRye_8i2q8/видео.html; will come back to this next.
Hello sir can i ask you your coding can put in blynks app
Sorry for not replying sooner - I am not familiar with blynks.
CODE LINK IS DEAD, please update it.
You can find it here: modestmaker.com/arduino/part2.html . Thanks for the heads up - video description updated.
can you give me a free downloud of arduino uno software please peter
www.arduino.cc/en/software - it's free for download online.
hear is a rain gauge for under 100 bucks
... and one that you now have an understanding of how it works!
At 10:43, you misstated the RC formula. When using microfarads, you need to use megohms, not kiloohms. T=RC uses seconds, ohms and whole farad's. Since you are using millionths of farads, you need to use millions of ohm's. I'm not good at explaining this, I apologise for that.
That said, you can denounce the switch in software, you just have to do it at main level, not in the interrupt handler.
You are correct. Thank You!