Connecting a Rain Gauge

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Naesstrom
Normal user
Posts: 23
Joined: 02 Jun 2017, 21:02

Connecting a Rain Gauge

#1 Post by Naesstrom » 06 Feb 2018, 19:54

So I bought one of those really cheap rain gauges with a tipping bucket that looks like image just below, connected one wire to ground and the other to D5 on my nodemcu board but would love to get some help on the config since I can't get it working and an inch from going completely mad here... :D
This is the model:
Image

This is how I have set it up, not sure what I should select in the Counter Type and Mode Type?
Image

The result is that the Count stays at 0 and the Total just increases for each tipping but ignores the formula?
Image

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Connecting a Rain Gauge

#2 Post by toffel969 » 06 Feb 2018, 20:03

All in all looks like it's working ok., just the formula is not working. Why I don't know.
You could work around with rules and a dummy. That would allow a local representation of rain for last h, last 24h, so on. The count value represents the count between delays. Increase delay for that purpose.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Naesstrom
Normal user
Posts: 23
Joined: 02 Jun 2017, 21:02

Re: Connecting a Rain Gauge

#3 Post by Naesstrom » 06 Feb 2018, 20:08

Thanks, and yes, seems to kind of work when I subbed to my mqtt
Image

I'll try and up the delay to 60s so that it doesn't spam my server every second tough. Still, would be great to know what the different "Counter Types" does!

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Connecting a Rain Gauge

#4 Post by budman1758 » 07 Feb 2018, 02:37

I set up a pulse counter a while ago for fan RPM. The formula you want is the count divided by the delay time times the amount of rain is in 1 bucket.
I would set your delay time to 5 minutes or so. Assuming your rain gauge is .2794 inches per bucket (which seems like a lot to me) Then the formula would be something like this:

Code: Select all

%value%/300*.2794 << using the "Count" value
That gives you the amount of rain in the last 5 minutes. You can adjust that to any time delay you need but your reading is always going to be so much rain in such amount of time. The total will keep counting up until the next reboot. The time value I could never make sense of in my setup. It was always somewhere between 1 and 4 for me with a 60 second delay. :?:

Keep in mind that your values will be lost whenever the ESP reboots. If you are looking to track rain for any length of time you might want to consider a save mechanism of some sort.
"The glass is twice as big as it needs to be".

Naesstrom
Normal user
Posts: 23
Joined: 02 Jun 2017, 21:02

Re: Connecting a Rain Gauge

#5 Post by Naesstrom » 07 Feb 2018, 07:23

Thanks @budman1758 I'll go with that formula instead!
It's not inches but mm btw, so it would compare to 0.011" :D

Using node-red to parse the data and send it off to influxdb for storing and then Grafana to show it! This is how it looked last night when playing around with it!
https://snapshot.raintank.io/dashboard/ ... lRJyDpeTl6

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Connecting a Rain Gauge

#6 Post by budman1758 » 07 Feb 2018, 08:26

Naesstrom wrote: 07 Feb 2018, 07:23 Thanks @budman1758 I'll go with that formula instead!
It's not inches but mm btw, so it would compare to 0.011" :D
That makes a bit more sense. :lol:
"The glass is twice as big as it needs to be".

TheTrumpeter
Normal user
Posts: 29
Joined: 02 Dec 2020, 15:30

Re: Connecting a Rain Gauge

#7 Post by TheTrumpeter » 10 Dec 2020, 11:49

I'm very sorry for digging out that old thread, but I could not find an answer somewhere else.

I have bought a rain gauge that looks similar to the one in the first posting.
It seems to work at a first glance, but after monitoring it for a while I see that the pulse counter rises now and then although the bucket is not moved.

I have connected one wire to GPIO34 of an ESP32, the second wire to ground. In addition GPIO34 has a pullup to 3V3.
The problem disappears if I disconnect the rain gauge.

Somewhere else I was advised to introduce some additional hw-logic (transistor and some resistors) to avoid interference.

Does anybody else face a similar problem and maybe has an easier solution?

Furthermore I see that the pulse counter does not work if I set the trigger to "LOW" although the GPIO is definitly LOW when the reed-contact closes. It is working properly for "RISING" and "FALLING". Any idea on that?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting a Rain Gauge

#8 Post by TD-er » 10 Dec 2020, 11:54

Judging the GPIO pins you use, you seem to be using an ESP32.
The support for pulse counter on ESP32 is still on my todo list as the CPU itself does have hardware support for it which we don't use yet.
This will make it much more reliable.

It sounds like you're picking up noise. Maybe a long cable?

TheTrumpeter
Normal user
Posts: 29
Joined: 02 Dec 2020, 15:30

Re: Connecting a Rain Gauge

#9 Post by TheTrumpeter » 10 Dec 2020, 12:45

TD-er wrote: 10 Dec 2020, 11:54 Judging the GPIO pins you use, you seem to be using an ESP32.
Yes, as written above. In detail it's a DevKitC (or at least it's labelled as a DevKitC).
TD-er wrote: 10 Dec 2020, 11:54 The support for pulse counter on ESP32 is still on my todo list as the CPU itself does have hardware support for it which we don't use yet.
This will make it much more reliable.
Sounds great.
I want to have my automatic watering control running in spring, as of now I plan to use the soil moisture sensors for evaluating the demand of water, the rain gauge is just an add-on to see if the moisture is plausible.
Unfortunately it does not sound like the pulse counter with HW-support will be ready by then?
TD-er wrote: 10 Dec 2020, 11:54 It sounds like you're picking up noise. Maybe a long cable?
Currently the cable is approx. 3m, I have already tried placing the rain gauge somewhere else where the whole length of the cable is needed, but it does not make a difference. At the end it has to be approx. 7m long, as the gauge will be placed on top of the garage and then be approx. 7m away from the control unit.
I've also tried different pull-ups and also switching to HIGH instead of LOW, but the problem is still there. I see that the counts often happen together with switching on some lights in the house, one time early in the morning I could reproduce it by switching-on my IT-equipment, but when I tried it again I could not see the counter rising again.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting a Rain Gauge

#10 Post by TD-er » 10 Dec 2020, 13:45

The last few months have been more about actually fixing stuff and improving, instead of bug hunting as we have had no idea for quite a long time what was causing issues.
So it is not that unlikely supporting the specific ESP32 features will be done in the next few months.
For example in the last 2 weeks I've been working on improving/adding specific PWM related features of the ESP32, which are done in software on the ESP82xx.

But I doubt adding support for the hardware specific pulse count features of the ESP32 will fix your issues.

What I think is happening here is that your GPIO pin picks up some peak signals from noise or switching of appliances you mentioned.
This means the signal level actually does change and what the HW pulse count options of the ESP32 may fix is not missing a pulse.

What you need to do is one or more of these:
- increase the "debounce time"
- For longer cable: twist the wires so a signal received will be cancelled out by the next twist in the cable.
- Make it harder to switch state (more on that below)

About making it harder to switch state.
You can try to keep the signal high when not counting a pulse, so it will be connected to GND when a pulse must be counted.
For example by using a relatively strong pull-up and let the switch draw it to GND.
Still there is no current flowing when the switch in the sensor is not closed, so you may also want to place a resistor with a relative high value over the sensor itself (at the sensor location) to draw a small current through the long wires.
For example a pull-up resistor of 2k2 and a resistor of 10x that value over the sensor. (just some value, doesn't matter a lot, as long as the ratio between both values is large enough)
Then any noise picked up must have quite some energy to change the state of the signal as there is already some current flowing.

TheTrumpeter
Normal user
Posts: 29
Joined: 02 Dec 2020, 15:30

Re: Connecting a Rain Gauge

#11 Post by TheTrumpeter » 10 Dec 2020, 14:49

TD-er wrote: 10 Dec 2020, 13:45 About making it harder to switch state.
You can try to keep the signal high when not counting a pulse, so it will be connected to GND when a pulse must be counted.
For example by using a relatively strong pull-up and let the switch draw it to GND.
That's what I've already tried, I've had pullups down to 3k already.
TD-er wrote: 10 Dec 2020, 13:45 Still there is no current flowing when the switch in the sensor is not closed, so you may also want to place a resistor with a relative high value over the sensor itself (at the sensor location) to draw a small current through the long wires.
For example a pull-up resistor of 2k2 and a resistor of 10x that value over the sensor. (just some value, doesn't matter a lot, as long as the ratio between both values is large enough)
Then any noise picked up must have quite some energy to change the state of the signal as there is already some current flowing.
I could give that a try, but have to get some additional resistors next week, currently I have not bigger than 10k here and don't want to go down below 3k for the pullup.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting a Rain Gauge

#12 Post by TD-er » 10 Dec 2020, 15:59

You can also add some 10k's in series :)

TheTrumpeter
Normal user
Posts: 29
Joined: 02 Dec 2020, 15:30

Re: Connecting a Rain Gauge

#13 Post by TheTrumpeter » 10 Dec 2020, 20:06

TD-er wrote: 10 Dec 2020, 15:59 You can also add some 10k's in series :)
Yes that's clear, but I have only one 10k left, 2 more 5k5 and then only 3k3 or stronger. So I would need plenty of them in series, so I wait until next week and grab some really weak ones.

User avatar
Andrew Mamohin
Normal user
Posts: 95
Joined: 12 Jun 2020, 08:30
Location: Belarus, Gomel
Contact:

Re: Connecting a Rain Gauge

#14 Post by Andrew Mamohin » 05 Apr 2023, 20:59

This is an old thread, but maybe it will be useful for someone. I bought myself a reed switch rain gauge and experimented with it for a while.
I achieved good performance without false pulses when I put a non-polar 0.01 microfarad capacitor between the microprocessor pin and the power supply minus.
This is how the scheme turned out:
дождемер.jpg
дождемер.jpg (9.59 KiB) Viewed 2964 times
Andy.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Connecting a Rain Gauge

#15 Post by TD-er » 05 Apr 2023, 21:35

This can also be used for any other switch with relatively long wires.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 28 guests