Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.6.6 (build 3082) - 1 June 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

See the Wiki to download the software or click on the Downloads link in the Forum Banner.

Using WH1080 wind sensors with custom weather station

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

Using WH1080 wind sensors with custom weather station

Post by shrx »

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 04 Feb 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

Post by Charlie »

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: 182
Joined: Sun 13 Jan 2013 8:04 pm
Weather Station: WeatherDuino Pro2 PLUS
Operating System: Windows 7
Location: Cercal CDV - Portugal
Contact:

Re: Using WH1080 wind sensors with custom weather station

Post by Werk_AG »

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
Do it Yourself - The freedom to use the weather instruments you want.

Image

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

Re: Using WH1080 wind sensors with custom weather station

Post by shrx »

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 11 Nov 2013 11:29 am
Weather Station: custom
Operating System: OS X
Location: Slovenia

Re: Using WH1080 wind sensors with custom weather station

Post by shrx »

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 here 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: 182
Joined: Sun 13 Jan 2013 8:04 pm
Weather Station: WeatherDuino Pro2 PLUS
Operating System: Windows 7
Location: Cercal CDV - Portugal
Contact:

Re: Using WH1080 wind sensors with custom weather station

Post by Werk_AG »

After a quick look at your code, you need at least init your weather instruments once.
Try call void setupWeatherInts() on setup section.
Do it Yourself - The freedom to use the weather instruments you want.

Image

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

Re: Using WH1080 wind sensors with custom weather station

Post by shrx »

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

Post Reply