I had so many sensors and lcd's going that interrupts messed up my program big time so all I did was go in to each sensor function and check. I set my windspeed function up such that if it didn't produce one period in a given time to break out of the loop and report no wind to the display. This made my code run soooo much better. Interrupt is great if you don't have many other functions running (like a print to lcd function)
For those curious, cup anemometers over sample the wind speed by anywhere from 5 to 7% SO if you need hyper accurate data remember to apply a correction.
if the wind sensor circuit always bounces the same you can compensate for that in programming where you ignore signals for a micro second. that shouldn't effect the result unless you get wicked fast wind speed unheard of on earth.
I usually fix relay float problems in software tbh.. it depends on the timescales involved.. Arduino is fast enough to continuously read input in the 5 microsecond range .. That is more than enough to detect the non floating bit.
Great video, fantastic explanation, thnx! . . . but . . . using your sketch I don't get consistent, repeatable results. I've set up my anemometer on a stable base. set up a fixed air flow (old hair dryer anchored to a bench), I get very variable results, even with a stable physical setup (I don't really acre what the output is, as long as its stable, then I can calibrate from there). Thnx again for your great video, much appreciated, and advice would be great. billd
I dont get why in the comment it sais Falling event but you set it to Rising `attachInterrupt(interruptPin, anemometerISR, RISING); //setup interrupt on anemometer input pin, interrupt will occur whenever falling edge is detected`
Something wrong bro, attachInterrupt(interruptPin, anemometerISR, RISING); => I think it must be: attachInterrupt(digitalPinToInterrupt(interruptPin), anemometerISR, RISING);
haha... i know what they're for... just thinking i could program it with an arduino to do what i want... if i get one with the directional dohickey, if the wind is X and the direction is Y, then close, otherwise, the wind will sort of 'defect' off the panels. i'm surprised there are not more youtube videos for this purpose.
I can't answer for all Anemometer, but the 3rd wire on mine is not connected to anything. My guess is they are using some standard connector that has 3 wires but they only use 2.
By value do you mean forward voltage drop? You can use any standard diode but you do want to make sure that the forward voltage drop is not so high that it reduces the voltage of the pulse so much that it is lower than the "high" threshold of whatever digital pin you are using to detect the pulse. I typically just make sure the forward voltage drop is
Thank you very much for the quick reply. I initially used a Fairchild 1N4001 diode, that is typically used as an AC rectifier, and got some unexpected results. I changed it to a small LED and your program works fine on the Uno, as written. I want to use the anemometer to close my patio awning when the wind speed hits a predetermined threshold, e.g. aSetting >20 mph, and trigger a relay. I also want to use the Adafruit Feather Huzzah and relay wing, instead of the Uno, because 1) small size of the microprocessor and relay, and 2) wifi capability to transmit the data to a Raspi Pi and display. I notice that your code compiles and loads to the feather huzzah, but I am not getting anything on the serial monitor other than a couple junk characters? I will try to modify the code to get the feather to work... wish me luck.
Rectifier diodes are typically made for pretty high forward currents and this application is fairly low current so maybe that is the issue. I don't have any experience with the Huzzah, but the strange characters sounds like a baud rate setting mismatch. Sounds like an interesting project, good luck on it.
Thanks. The Feather Hazzah and wings are pretty cool, and the on-board wifi is a nice feature, like the new Raspi Zero. I checked the baud rate mismatch, and the outputs, just to see if the program was working but not printing correctly. It does send the junk message to the serial monitor every 1.8 seconds. I can write my own code to send messages to the serial monitor and it works as expected. I'm not sure if the Adafruit Huzzah supports interrupts, or if I need a library to correctly access the GPIO pins? I will attempt to find out from Adafruit . I've looked at a few Arduino IDE sketches for the Huzzah on GitHub, but there is not a lot to choose from. P.S. I like your channel and your obvious expertise. I've "borrowed" your code numerous times for projects, e.g. nRF24L01 radio code for robotics projects.
The Hazzah has an ESP8266 on it which I believe supports interrupts so the Hazzah should support interrupts. Glad you found the content on the channel useful and I put the code out there for others to use.