WeatherRack Weather Sensors Arduino Drivers Released

WeatherRack Weather Sensors

WeatherRack Weather Sensors Arduino Drivers Released

A new version of the Arduino C++ Class driver software for the inexpensive 41-tvY+gqZLWeatherRack Weather Sensors is now available on https://github.com/switchdoclabs/SDL_Weather_80422.  Support for 3.3V, the WeatherPiArduino board and the ADS1015 A/D converter has been added.  The full WeatherPiArduino article was  published in Raspberry Pi Geek magazine in September 2014.  A second article talking about the lightning detector will be published in April 2015.  The Raspberry Pi Python drivers are up next.

WeatherPiArduino

To the right is the fully populated WeatherPiArduino board.  It was designed to interface

Weather
WeatherPiArduino and Lightning Tester

with the SwitchDoc Labs WeatherRack along with some auxiliary I2C units:

  • DS3231 RTC
  • Adafruit 32KB FRAM I2C breakout board
  • Adafruit ADS1015 4 Channel A/D I2C board
  • Lightning Sensor
  • Humidity Sensor
  • Barometer and Temperature Sensor (BMP180)

The WeatherPiArduino board comes with the DS3231 RTC, AT24C32 EEPROM and the BMP180.

SDL_Weather_80422 Class Library for Arduino

The SDL_Weather_80422 class library is designed to provide all the functions of the SwitchDoc Labs WeatherRack and the SparkFun Weather Meters SEN-08942 in one C++ class.

The library is easy to use and hides the complexity of the interface to the sensors.  The C++ class has two Interrupt Service Routines (ISR), one each for the anemometer and the rain bucket.  The wind vane is connected to an Analog to Digital Converter (ADC) input pin on the Arduino.  Note that the C++ class is designed to be a singleton, in other words, you only can interface one sensor package without some additional work (mostly involving Interrupts).  The article in Raspberry Pi Geek magazine discusses this in detail.

 

There are two main modes for the class.

SDL_MODE_SAMPLE

SDL_MODE_SAMPLE mode means return immediately after asking for the wind speed. The wind speed is averaged at sampleTime or since you last asked, whichever is longer. If the sample time has not passed since the last call, the class returns the last calculated wind speed. That means that you will never see changes faster than the specified sample time. This allows you to not wait for the wind speed, you can just grab the last valid reading.

SDL_MODE_DELAY

SDL_MODE_DELAY mode means to wait for the set sample time to expire and return the average wind speed at the expiration. You would use this if you want to make sure you have the latest value and your program architecture allows you to pause for the sample time before continuing. Which mode you use depends on the specific software architecture of your Arduino application.

Typically, I use SDL_MODE_SAMPLE because I can tolerate not having a current value of wind speed.

The example code for the SDL_Weather_80422 library is shown below:

/*
  SDL_Weather_80422_Library.ino - Example for using SDL_Weather_80422 Library
  For SwitchDoc Labs WeatherRack
  For Weather Sensor Assembly 80422.
  Imported by Argent Data Systems
  Created by SwitchDoc Labs July 27, 2014.
  Released into the public domain.
*/
#include 
#include 

#include "SDL_Weather_80422.h"

#define pinLED     13   // LED connected to digital pin 13
#define pinAnem    18  // Anenometer connected to pin 18 - Int 5
#define pinRain    2   
#define intAnem    5
#define intRain    0

// for mega, have to use Port B - only Port B works.
/*
 Arduino Pins         PORT
 ------------         ----
 Digital 0-7          D
 Digital 8-13         B
 Analog  0-5          C
*/


// initialize SDL_Weather_80422 library
SDL_Weather_80422 weatherStation(pinAnem, pinRain, intAnem, intRain, A0, SDL_MODE_INTERNAL_AD);


uint8_t i;




float currentWindSpeed;
float currentWindGust;
float totalRain;
void setup()
{ 
  Serial.begin(57600);  
  

 Serial.println("-----------");
 Serial.println("WeatherArduino SDL_Weather_80422 Class Test");
 Serial.println("Version 1.0");
 Serial.println("-----------");
      
      
      weatherStation.setWindMode(SDL_MODE_SAMPLE, 5.0);
      //weatherStation.setWindMode(SDL_MODE_DELAY, 5.0);
      totalRain = 0.0;
}


void loop()
{
  Serial.println("----------------");

  currentWindSpeed = weatherStation.current_wind_speed()/1.6;
  currentWindGust = weatherStation.get_wind_gust()/1.6;
  totalRain = totalRain + weatherStation.get_current_rain_total()/25.4;
  Serial.print("rain_total=");
  Serial.print(totalRain);
  Serial.print(""" wind_speed=");
  Serial.print(currentWindSpeed);
    Serial.print("MPH wind_gust=");
  Serial.print(currentWindGust);
  Serial.print("MPH wind_direction=");
  Serial.println(weatherStation.current_wind_direction());
  

  
  delay(1000);
  
  
}

When you run this, you should get a result similar to this:

-----------

WeatherArduino SDL_Weather_80422 Class Test
Version 1.0

-----------
----------------
rain_total=0.00 wind_speed=13.20MPH wind_gust=12.40MPH wind_direction=90.00
----------------
rain_total=0.00 wind_speed=9.60MPH wind_gust=9.48MPH wind_direction=90.00
----------------
rain_total=0.00 wind_speed=10.20MPH wind_gust=9.23MPH wind_direction=90.00
----------------
rain_total=0.00 wind_speed=11.10MPH wind_gust=9.84MPH wind_direction=90.00

2 Comments

  1. I know this might be way off topic but I love this idea and wanted to share. I grew up in the shadow of a small town airport and most aiports have things called Automated Weather Observing Systems. The main part of this was that the stations also transmitted voice data too. I think it would be cool to do with a Pi2 is make it speak the weather. Maybe use low powered FM band or maybe as an add on for a 2 meter repeater.

    Love the project and let me know if you ever need any beta testers 😀

    • Kevin,

      Great idea for a project. You can do all of that with a WeatherPiArduino, sensors and a Raspberry Pi and a small FM transmitter (look at the Ramsey FM30 – been using it for years).

      The next project here with weather is a Pi based solar powered weather station.

      John

1 Trackback / Pingback

  1. WeatherRack Weather Sensors Arduino Drivers Released – SwitchDoc Labs | TOL

Comments are closed.