How to wake up an Electron if it rains

Hi,

I’m using an electron to control the weather with Photon weather station. I’m sleeping the machine during 15 and wake up again.

System.sleep(SLEEP_MODE_DEEP, sleepPeriode, SLEEP_NETWORK_STANDBY);

During this time of sleep, maybe can rain, but how the machine is sleeping, nobody has the rain report.

I’m using int RainPin = D2; for Rain sensor…but:
1º is it possible to wake up the electron when it rains?
2º Is it possible to wake up the electron in sleeping time only wake up read the rain and store till next connection?
3º how to solve this problem if rains all day?

Anybody has managed a situation like that?

thank’s for your help/comments

Eduard

I have done something pretty similar to this with Photon, but it turned out to be very complicated. There is lots of state management of network and power that turns the processor up and down on demand. For my application sleeping was not practical, so I ended up getting the CPU down to <10mA during normal operation with throttling.

Sure, if you have a sensor (maybe with additional circuitry) that can produce a rising edge on the WKP pin. What weather station, and rain sensor are you using?

Not exactly sure what you mean by this, but sounds like it should be possible.

What problem? What do you want to happen if it rains all day?

1 Like

Hi @Ric again it’s a pleasure have a discussion with you :wink:

1º I’m using the photon wetaher shield: https://www.sparkfun.com/products/13674

2º Is it possible to read values and store the values after rain and store into retained values? Whe the Electron will be up again read the internal and send the rain values

3º If it rains all the time, the electron will be up all the time, no? so, the batt will be out of charge …and this will be a problem :slight_smile:

Thank’s for your help

Eduard

Assuming that you're using the tipping bucket rain gauge in the Weather Meter, you will need some external components to do what you want. Since that type of rain gauge produces a signal every .01 inches of rain, you could be getting a lot of signals over a day long rain. You could use a CMOS counter chip like the CD4020 (and a 16 to 1 mux/demux chip like the CD4067 to read it), or a low power microcontroller (ATtiny85 maybe) to accept and store the individual rain events.

Sure, you can do this. You could either use an array to store the values, or create a string that you concatenate with each new data point. A string would probably be easier to send (via a publish for instance). If you use the external circuitry that I mentioned above, you probably won't need to do this anyway. When the Electron wakes up every 15 minutes, just read the counter, reset it, and send the data.

Hi @Ric

Thank's for your help I really appreciate. I'm not an engineer and I'm learning by myself, did you have where I could learn how to store and read this counts in a ATiny85?
We could do that when the bucket moves the ATiny85 stores this info and when the Electron wakes up reads the ATiny and reset the counter.

What do you think?

Thank you very much

Regards from frozen Barcelona

After reading more about the ATTiny85, I don’t think that’s the easiest or best way to go. The problem is how to program it. It can be done with an Arduino, or a dedicated AVR programmer ($20 on SparkFun), I don’t know if anyone has managed to do it with a Particle device.

I would go with a simple counter ic and a parallel in-serial out shift register to read the count value. A counter like the CD4024 (7 bits) or the CD4040 (12 bits) should be fine. Even with seven bits (count up to 127), that would give you the ability to measure up to 1.27 inches of rain in the 15 minutes the Electron is asleep. These counters count up by one every time the data line goes from high to low, and the count shows up on the 7 or 12 output lines. In order to use as few pins as possible on the Electron, you could feed that parallel data from the counter to a CD4021 shift register, then read it out serially to the Electron when it wakes up (Here’s an article showing how to use the 4021 with an Arduino). The CD4021 is an 8 bit register, so you could use it with the 4024, or read the lower 8 bits of the 4040.

The rain gauge outputs a momentary switch closure using a magnetic reed switch. Those are notoriously “bouncy”, so you would would want to de-bounce the input using an rc network like is shown in this article. You don’t need the extra protection of the Schmitt trigger input shown in that article because the inputs on the counters already have those.

debounce-sch

In the image above (taken from the article above), the switch would be replaced by the two wires from your rain gauge, and the “to microcontroller” connection would go instead to the data line of the counter. Like the Arduino, the Particle devices have a shiftIn() command that you can use to clock in the data from the shift register. I think this would be the simplest and cheapest way to count your rain gauge pulses while allowing the Electron to sleep.

I wouldn’t even bother with the external counter. What I would do is use SYSTEM_MODE(SEMI_AUTOMATIC) and wake up with cellular off. The amount of power you’d need to wake up, increment a 0.01” bucket tip in retained memory and go back to sleep is negligible. Aggregate these over time and quantity so you wake up and publish at reasonable intervals.
(This is reasonable for rain unless you live in a rain forest. Not true for wind, wind will need an external controller.)

1 Like

Hi guys,

Thank you very much, right now I’m in a middle of nowhere installing some units, I’m coming back tomorrow night and I will see your answers.

Thank’s again

Eduard

Hi

I am trying to do the exact same thing. Have you found a way? Thanks in advance

Hi Guys,

I just received the pcb that I made in China. I just included a cd4021 shifter as mentioned @Ric.
Thank’s @Ric it works perfect, the shifter records the steps and when the arduino or particle wakes up reads the pin and after reset the values…and sleep again, it works perfect!

Thank’s is an incredible the world of shifters.