erratic output from Adafruit anemometer

I've been playing with the Adafruit cup anemometer, which has a nominal output of 0.4 t 2 VDC. It looks good on an ordinary meter, but when I sample the output with my Uno or Zero, the numbers jump all over the place. The Arduino, of course, has a much faster response than the meter.

With stationary cups, I see an average of about 130 counts in the readings, but there'll be an occasional reading of 65, sometimes 150, etc.

Has anyone else checked one of these anemometers and found this kind of behavior?

Does someone know how the anemometer is producing its output? My next step is to take it apart, but I'd like to avoid that.

What voltage are you using to power it? How is it wired to the Arduino? The UNO (5V) and Zero (3V3) should give you different average readings.
Post your code (in code tags - use the </> icon)
If all else fails, ask in the Adafruit forums.


Both the Arduinos and the anemometer are powered by a bank of lead-acid batteries (nominal 12.6 VDC) that also powers my ham radio station and various other stuff. So it's stable, clean, ripple free power.

I only need to compare the readings at A0, so the code is simple. I used the 3.3 V output as the analog reference for the Uno, and commented out that line for the Zero.



const int analogInPin = A0;

int count = 0;

void setup() {
   analogReference( EXTERNAL );

void loop() {

  count = analogRead( A0 );
  Serial.print("counts = " );                       
  Serial.println( count );      



I haven't yet joined the Adafruit forums - wasn't aware they existed. So I'll do that soon if I can't get this resolved here.

Thanks for the tip.

Are you providing the external 3V3 voltage reference on the AREF pin? If not, you should be using DEFAULT. Ooops. Nope, you've said you're using the 3V3 output as the reference on the UNO.


Got an o-scope? I couldn't do without mine in situations like this.

I too wish I had an oscilloscope.

I did stop by a friend's house a week or so ago for a quick check. We weren't sure what we were looking for, but we did notice some very low ripple (probably pcik-up of AC from the ether) and sporadic odd blips. They weren't at regular intervals (nor are the "irregularities" I'm getting with the Arduino), but they looked to be packets of waves of a few kHz frequency lasting a short time. We couldn't get trigger and sweep settings that gave us a stable view.

Perhaps a capacitor on A0 would smooth the input.


I am suspicious that your ham station is perhaps part of the problem - do these strange readings happen when you are transmitting by any chance ? If the wires to the anemometer are not shielded, all sorts of strange things can happen (and if your luck is like mine, they will just happen to be 1/4 wave tuned antenna). I would definitely consider the low pass filter on the output - something with maybe a 1 or 2 second time constant would be a good starting point.

I have not tried these measurements while my station was on the air, so the problem isn't RFI.

I've tried simple RC filters on A0 with little to no effect. R values from 4700 to infinity (no R) and C values from 0.01 uF to 100 uF (my first shot was in fact a 1-s time constant filter).

I'm still quite surprised that 100 uF had no effect(!)

The fact that putting an RC filter on A0 has no effect on the strange readings (it should at least change things) makes me think that perhaps the problem is not with the signal on A0, but in how you are reading it. There are some timing issues with reading an analog input but I don't have enough experience with this chip yet to be familiar with them - I have just seen them mentioned here before. I know on the PIC processors, after you initiate a conversion, you have to wait a brief period before reading the output of the A/D converter for the results to be stable. I would have expected that with say a 100uf from A0 to ground and a 5k resistor from the anemometer to A0 you would have seen a difference if that was where you were getting the fluctuations.... you may be looking under the wrong rock. What happens if you put a fixed voltage into A0 and run your same sketch - do you get variations in the readings then?

Add a 5k1 (or 5k6) resistor between 3.3volt and Aref. Aref also drops to ~2.8volt.
Add a smoothing cap from A0 to ground (47uF?).
This sketch will give a stable readout by simply adding (averaging) 64 A/D values.

// anemometer
// use 5k1 or 5k6 resistor between 3.3volt and Aref to protect Aref circuit

unsigned int total; // max 64 readings
float windSpeed;

void setup() {

void loop() {
  for (int x = 0; x < 64; x++) {
    total = total + analogRead(A0); // add each value to a total
  // connect 2.0 volt to A0 and calibrate here to 50m/s
  windSpeed = total / 800.0; 
  Serial.print("Wind speed = ");
  Serial.print(windSpeed, 1); // one decimal place
  Serial.println(" m/s");
  total = 0; // reset

I'll try the simple checks suggested by gpsmikey late today.

I've already tried connecting a fresh alkaline AA cell to A0 (on both the Uno and Zero) and the results are very steady and about as expected - 500 counts, with a slight +/- fluctuation of a few counts. Much less than the many tens of counts I get with the anemometer. I figure it's reasonable jitter for an A/D converter.

Getting a stable readout by averaging doesn't meet the needs of a weather station. I intend to (and have already written some code to) collect 600 samples at 1 second intervals to maintain a 10-minute running average wind speed. The problem comes when I try to extract statistics of shorter duration - like a 3-second gust. I end up with ridiculous results like a 0 mph wind with gusts to 8 mph.

I'll try the 5K resistor from A0 to AREF on the Uno.

So many rocks, so little time ...

While there are some airflow sensors (Doppler, ion based etc.) that have very fast response times, the type you are using with the spinning cups has a much longer time constant and typically takes several seconds to respond correctly to brief gusts etc. Trying to read 1/2 second (or even 1 second) gusts etc. is not going to give you accurate information. Yes, the numbers will change, but it takes longer than that for the spinning mass to change speed to match the wind. It would be interesting to see the output of the anemometer with a scope and see what is going on. Perhaps that is something that should be considered as an addition to your ham shack? There are some fairly nice little scopes out there these days that are digital and while they are not as good as a good analog for some applications, something like the DS1052E (which I have) works quite well for lots of applications and is compact. It even has the ability to save a trace as a bmp on a flash drive (USB).

The problem apparently is a ground loop or noise pickup by the ground/common leads.

I had approx 1-foot cliip leads between the end of the cable from the anemometer and the Arduino(s). When I eliminated the clip leads and made a more-direct connection to A0 and GND, the steadiness of the readings improved enormously. When I added the clip leads back to the GND lead, the erratic readings returned. This did not happen when I added the clip leads back to the signal lead.

This behavior also does not occur with clip leads and a small battery (as I noted in an earlier post). So I'm not completely sure what's going on here, but it's convenient to blame "a ground loop".

Thanks to all who commented and got me thinking about this in different ways.

BTW, I own 3 spectrum analyzers, but no oscilloscope. I've got to rethink that situation too.

Did you measure the clip lead. I had many of those short multi-coloured test leads go open circuit.

Don't think you have to worry about reading the pin 64x. That happens faster (~6.5mSec) than the anemometer can change rotation speed. 64 reads, and reducing results to 9-bits (50.0 m/s) will drown the odd wrong reading. Remember that the A/D result depends on two things. Voltage on the analogue pin and Aref. Both have to be stable. Leo..

I did NOT think to check the clip leads, so I did just now. They test out fine - good continuity, and no problem when I jiggle or pull on the leads.

I don't consider averaging bad readings in with 64 other readings - or however many - to be a solution, so that was never an option for me. The objective is to get accurate readings, not just steady ones. I was seeing occasional readings of 85, 90, 170, and 180 mixed in with a large number of about 130 +/- maybe 10. I can accept that jitter, but not those outliers.

Thankfully, the outliers are no longer there, and I'm satisfied with the readings.

The good news is that the Adafruit anemometer seems to be behaving fine. I would caution other potential users, though, that you MUST calibrate this anemometer. Except for the point 0 windspeed, 0.4 Volts, the calibration info provided by Adafruit seems to bear no relation to reality.

Also, the same anemometers are available from Ebay sellers (they come from China, of course), but I didn't find any prices better than Adafruit's price. I chose to support Adafruit.

Sounds good. There will always be some wiggle in that sort of data, but not the "outliers" you were seeing.