Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Using WH1080 wind sensors with custom weather station

For discussion of DIY weather equipment - sensors, accessories, improvements to existing kit etc
shrx
Posts: 4
Joined: Mon Nov 11, 2013 11:29 am
Weather Station: custom
Operating System: OS X
Location: Slovenia

Using WH1080 wind sensors with custom weather station

Postby shrx » Mon Nov 11, 2013 11:41 am

Hello,
is it possible to use the WH1080 wind sensors (direction and speed) with a custom-built weather station? Is there any technical information available about these sensors, like wiring diagrams and interface instructions?

Charlie
Posts: 363
Joined: Thu Feb 04, 2010 12:22 pm
Weather Station: 1wire-Cumulus & Fine Offset
Operating System: Windows 7
Location: Whitehorse, Yukon Territory, Canada

Re: Using WH1080 wind sensors with custom weather station

Postby Charlie » Mon Nov 11, 2013 2:46 pm

Yes it's possible, and all the information is here on the forum. Start with the search button. We'll be happy to help if you have questions.

User avatar
Werk_AG
Posts: 181
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: Using WH1080 wind sensors with custom weather station

Postby Werk_AG » Tue Nov 12, 2013 10:12 pm

Yes, it´s possible :D

In this link you will find the datasheet you asked: WH1080 datasheet

At this page you can find a nice piece of code for reading this sensors with an Arduino:
Sparkfun Weather Station

I have used this info to made my custum-built weather station: WeatherDuino Pro2.
It is working since some months wihout any major problem.
I have not implemented or tested the code for the rain gauge, because I'm using another type of rain gauge.

Hope this help
Image

shrx
Posts: 4
Joined: Mon Nov 11, 2013 11:29 am
Weather Station: custom
Operating System: OS X
Location: Slovenia

Re: Using WH1080 wind sensors with custom weather station

Postby shrx » Tue Nov 12, 2013 10:59 pm

Thank you for your replies. It's great to see there are already existing solutions so I won't have to start from scratch.

shrx
Posts: 4
Joined: Mon Nov 11, 2013 11:29 am
Weather Station: custom
Operating System: OS X
Location: Slovenia

Re: Using WH1080 wind sensors with custom weather station

Postby shrx » Thu Nov 28, 2013 10:50 pm

I have received the sensors (both wind sensors and the rain gauge as well) this week and started working on them. I have used the code provided [url="http://kesslerarduino.wordpress.com/2012/06/21/sparkfun-weather-station/"]here[/url] to read data from the sensors with an arduino:

Code: Select all

// Set up the inputs and the interrupts

#define ANEMOMETER_PIN 3
#define ANEMOMETER_INT 1
#define VANE_PWR 4
#define VANE_PIN A0
#define RAIN_GAUGE_PIN 2
#define RAIN_GAUGE_INT 0

void setup() {
  Serial.begin(9600);
}
 
void setupWeatherInts()
{
  pinMode(ANEMOMETER_PIN,INPUT);
  digitalWrite(ANEMOMETER_PIN,HIGH);  // Turn on the internal Pull Up Resistor
  pinMode(RAIN_GAUGE_PIN,INPUT);
  digitalWrite(RAIN_GAUGE_PIN,HIGH);  // Turn on the internal Pull Up Resistor
  pinMode(VANE_PWR,OUTPUT);
  digitalWrite(VANE_PWR,LOW);
  attachInterrupt(ANEMOMETER_INT,anemometerClick,FALLING);
  attachInterrupt(RAIN_GAUGE_INT,rainGageClick,FALLING);
  interrupts();
}

// ---------------------
// Wind speed (anemometer)

#define WIND_FACTOR 2.4
#define TEST_PAUSE 60000
 
volatile unsigned long anem_count=0;
volatile unsigned long anem_last=0;
volatile unsigned long anem_min=0xffffffff;
 
double getUnitWind()
{
  unsigned long reading=anem_count;
  anem_count=0;
  return (WIND_FACTOR*reading)/(TEST_PAUSE/1000);
}
 
double getGust()
{
 
  unsigned long reading=anem_min;
  anem_min=0xffffffff;
  double time=reading/1000000.0;
 
  return (1/(reading/1000000.0))*WIND_FACTOR;
}
 
void anemometerClick()
{
  long thisTime=micros()-anem_last;
  anem_last=micros();
  if(thisTime>500)
  {
    anem_count++;
    if(thisTime<anem_min)
    {
      anem_min=thisTime;
    }
 
  }
}

// ---------------------
// Wind direction (vane)

static const int vaneValues[] PROGMEM={66,84,92,127,184,244,287,406,461,600,631,702,786,827,889,946};
static const int vaneDirections[] PROGMEM={1125,675,900,1575,1350,2025,1800,225,450,2475,2250,3375,0,2925,3150,2700};
 
double getWindVane()
{
  analogReference(DEFAULT);
  digitalWrite(VANE_PWR,HIGH);
  delay(100);
  for(int n=0;n<10;n++)
  {
    analogRead(VANE_PIN);
  }
 
  unsigned int reading=analogRead(VANE_PIN);
  digitalWrite(VANE_PWR,LOW);
  unsigned int lastDiff=2048;
 
  for (int n=0;n<16;n++)
  {
    int diff=reading-pgm_read_word(&vaneValues[n]);
    diff=abs(diff);
    if(diff==0)
       return pgm_read_word(&vaneDirections[n])/10.0;
 
    if(diff>lastDiff)
    {
      return pgm_read_word(&vaneDirections[n-1])/10.0;
    }
 
    lastDiff=diff;
 }
 
  return pgm_read_word(&vaneDirections[15])/10.0;
 
}

// ---------------------
// Rain gauge

#define RAIN_FACTOR 0.2794
 
volatile unsigned long rain_count=0;
volatile unsigned long rain_last=0;
 
double getUnitRain()
{
 
  unsigned long reading=rain_count;
  rain_count=0;
  double unit_rain=reading*RAIN_FACTOR;
 
  return unit_rain;
}
 
void rainGageClick()
{
    long thisTime=micros()-rain_last;
    rain_last=micros();
    if(thisTime>500)
    {
      rain_count++;
    }
}

// ---------------------
// Main loop

void loop() {
  Serial.println(getUnitWind());
  Serial.println(getGust());
  Serial.println(getWindVane());
  Serial.println(getUnitRain());
  Serial.println(" ");
  delay(10000);
}


However the serial readings are always the same, even if I manually turn the sensors which should trigger interrupts and change the internal resistance of the wind vane:

Code: Select all

0.0
0.0
270.0
0.0


Can you help me finding possible bugs in the code? I am only a beginner in coding for arduino.

User avatar
Werk_AG
Posts: 181
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: Using WH1080 wind sensors with custom weather station

Postby Werk_AG » Tue Dec 03, 2013 6:05 pm

After a quick look at your code, you need at least init your weather instruments once.
Try call void setupWeatherInts() on setup section.
Image

shrx
Posts: 4
Joined: Mon Nov 11, 2013 11:29 am
Weather Station: custom
Operating System: OS X
Location: Slovenia

Re: Using WH1080 wind sensors with custom weather station

Postby shrx » Tue Dec 03, 2013 6:35 pm

Yes, I forgot to write an update for this. It can be solved with movng everything in "setupWeatherInts" to "setup".


Return to “Homebuilt”

Who is online

Users browsing this forum: No registered users and 1 guest