sparkfun / Weather_Shield

Barometric pressure, temperature, humidity and light sensing weather shield for Arduino.
https://www.sparkfun.com/
Other
69 stars 67 forks source link

Instantenous wind speed reported as 0 or NaN #15

Closed chopsuei3 closed 9 years ago

chopsuei3 commented 10 years ago

I set up my Redboard and Weathershield, and attached my weather sensors via the RJ-11 jack.

I compiled and uploaded the code, and receive accurate temperature, humidity and pressure readings. I also receive accurate wind direction readings.

But the wind speed (instantaneous) returns either 0 or NaN.

Here is the example serial monitor output when spinning the anemometer -

$,winddir=45,windspeedmph=nan,windgustmph=0.0,windgustdir=0,windspdmph_avg2m=0.0,winddir_avg2m=0,windgustmph_10m=0.0,windgustdir_10m=0,humidity=41.9,tempf=78.4,rainin=0.00,dailyrainin=0.00,pressure=100737.25,batt_lvl=4.42,light_lvl=0.30,#

$,winddir=45,windspeedmph=0.0,windgustmph=0.0,windgustdir=0,windspdmph_avg2m=0.0,winddir_avg2m=1,windgustmph_10m=0.0,windgustdir_10m=0,humidity=41.9,tempf=78.5,rainin=0.00,dailyrainin=0.00,pressure=100735.50,batt_lvl=4.42,light_lvl=0.28,#

I commented out lines 335 to 337 to try debugging a bit. When I do this, the WindSpeed is printed twice, once as 0 and once as the correct speed.

$,winddir=225,windspeedmph=0.0,windgustmph=0.0,windgustdir=0,windspdmph_avg2m=0.9,winddir_avg2m=36,windgustmph_10m=12.1,windgustdir_10m=225,humidity=42.3,tempf=77.7,rainin=0.00,dailyrainin=0.00,pressure=100745.75,batt_lvl=4.42,light_lvl=0.33,# Loop call:

Windspeed:5.48 Wind clicks:0 calcWeather call:

Windspeed:0.00 Wind clicks:0

$,winddir=225,windspeedmph=0.0,windgustmph=0.0,windgustdir=0,windspdmph_avg2m=1.0,winddir_avg2m=38,windgustmph_10m=12.1,windgustdir_10m=225,humidity=42.3,tempf=77.6,rainin=0.00,dailyrainin=0.00,pressure=100742.25,batt_lvl=4.42,light_lvl=0.30,# Loop call:

Windspeed:4.53 Wind clicks:0 calcWeather call:

Windspeed:0.00 Wind clicks:0

Further research reveals that get_wind_speed() is called twice, once in the main loop and once within calcWeather(). I added a few debug readings, and I believe the correct WindSpeed is printed within the main loop. For some reason, the get_wind_speed() called within calcWeather() returns 0.

Am I missing something obvious?

It seems like the problem is related to the averaging of wind speed values over time.

I used the code directly from here.

Please help, thanks. Let me know if there are more questions.

Thanks!

elmills commented 10 years ago

I am finding the same issue. I am completely new to this type of project, but I see that the 10 minute average seems correct, but the 2 minute average and the instantaneous values dont seem correct.

Thanks

TechRep commented 9 years ago

I got the same problem, have you been able to figure out the issue?

nseidle commented 9 years ago

It looks like javacasm found the error. See https://github.com/sparkfun/Weather_Shield/pull/17/files#diff-0 It requires the change of one line

 //Calc the wind speed and direction every second for 120 second to get 2 minute average
float currentSpeed = windspeedmph;

However, I'm still not seeing windgustmph change. Very odd.

nseidle commented 9 years ago

Hmm, I think I found it. calcWeather() was zeroing out the values when it shouldn't. This sketch: https://codebender.cc/sketch:116056 should be fixed now. I will update the repo shortly.