PaulRB / Wemos-Weather-Station

Outdoor Weather Station with Wind Speed, direction &Rainfall sensors
56 stars 7 forks source link

Max freq/speed of anemometer pulse detector? #3

Closed colwilliamsnz closed 4 years ago

colwilliamsnz commented 4 years ago

Hi Paul, I have implemented a station using your ideas around the ATTiny85 slave device and found that the maximum anemometer frequency that can be decoded in my prototype is ~25Hz (roughly 90kph, tested using a signal generator). I wonder if you ran into this limitation at all? Struggling to make sense of it.

If I remove the sleep code I can decode beyond 60hz just fine. The current draw is 200~300uA extra in this mode so its not a huge deal, more a curiosity :)

Any clues or insight?

Thanks for sharing, its a great little project that has keep my mind nicely occupied during lockdown ;)

PaulRB commented 4 years ago

Hi, sorry for the delay in replying!

I never tested it to that extent. I estimated that it should be able to deal with higher frequencies than that. I have never noticed the readings maxing out in practice, either on average or max gust speeds. I live in a windy place, but 90Kph is rare (thank goodness), so it could be under-reading without me realising its happening. I don't even know for sure if my cheap plastic anemometer can deal with those speeds.

Plus, where my anemometer is sited, my neighbour's bushes have grown significantly over the last 2 or 3 years and are now shadowing the sensor. I need to move it, but the only other sites are so far from the house that the WiFi won't reach.

Because of this, I am re-designing the circuit. The replacement will be an atmega328 and will use an rfm95 LoRa transmitter. This should enable me to get much greater range and lower battery consumption. The prototype is powered by 3 x AAA NiMh cells and draws 15uA when not transmitting, and even when transmitting, far lower current than WiFi. I have not implemented wind direction or rain sensing for the prototype yet, so that current may go up a little.

I don't have a signal generator to test with, but I can soon rig up an Arduino Nano or something to generate test signals for the new circuit. I estimate max frequency of 50Hz should cover the highest winds we see here.

colwilliamsnz commented 4 years ago

Thanks for the update. I found the issue to be because I’d refactored the code so much (I switched it to I2C instead of serial because I couldn’t get the single wire serial working) and had the anemometer sensor bit way down in the loop…moving back to the top gets it to 60Hz+ which is plenty (I live in New Zealand windiest city but we'll fly off the hill if it gets to that ;)

It’s an inspired little idea that I’d keen to push further. I started out playing with LoRa and then discovered ESP32 and decided an all in one approach was best…power consumption its still the beast to tame and I’m thinking about starting the quest again just to see if I can eek out some more savings but using your overall slave approach for wind & rain.

Thanks again for inspiring!

PaulRB commented 4 years ago

I switched it to I2C instead of serial because I couldn’t get the single wire serial working

It took me a long time to get it working. Guess what? I switched to serial when I couldn't get i2c to work! That was my original plan, but I had problems with the master & slave getting out of sync, corrupting the data. This didn't happen immediately but occurred from a few minutes to several hours after startup, so was difficult to debug. I looked into using 1-wire Comms also (as used by ds18b20 sensors for example) but failed to get that working either, so invented my own crude "1-wire" method!

It’s an inspired little idea that I’d keen to push further.

I always advise beginners to avoid multiple MCU in the same circuit, but broke my own rule that time. In the new design, the atmega328 uses considerably less power than the attiny85 does in the current design, and there is no esp chip to run either.

Thanks again for inspiring!

Thanks for the encouragement. I must get back to working on it. Working from home during lockdown means I often don't feel like spending more time at my desk working on hobby stuff.

We hear NZ has made a much better job of dealing with CV19 pandemic than UK!