Tinkering‎ > ‎

Arduino Climate Station

posted Nov 3, 2014, 9:39 AM by Ted Bibby   [ updated Nov 13, 2014, 1:33 PM ]
I wanted to learn about Arduino's and see if I could make a cheaper climate station using some anemometers I had laying around. The economically priced Arduino (~$20) may prove to be a useful data logger for multiple systems in the future.

  • Arduino Uno
  • Met One 010C Wind Speed Sensor
  • Met One 020C Wind Direction Sensor
  • 12 V power supply

In brief, after finding versions of code floating around the internet I was able to program my Arduino to show a real-time display of wind speed and direction as simulated in my office. The wind direction sensor was very easy to calibrate and decipher the output signal from the device because the output voltage signal from the Met One instrument was directly correlated to direction/position of the wind vane. I have my wind vane set to output a range of 0-2.5 volts for 0 to 360 degrees rotation. There is also an option to change the voltage output form the wind van to 0-5 volts depending on your requirements. The code below should be adjusted as such depending on your configuration.

The output signal from the wind speed sensor was much more difficult to calibrate and get working properly. I tried to compare my reading to a handheld kestrel and feel confident that the same reading are recorded but I did not have a standardized way of generating a constants wind speed and so the reading the from kestrel varied depending on it's position and the rotation the the met one anemometer cups was only a function of one side of the instrument. The computer fan I rigged up to rotate the sensor blew unevenly.

I wired in a back-lit LCD display with a pontentiometer knob to control contrast of the display. I used another pontentiometer to control the output voltage coming from the speed sensor. The speed sensor is designed to output a 12 volt pulse proportional to the rate of rotation. This was the tricky part. I used the pontentiometer to reduce the voltage coming form the sensor because the Arduino is not designed to receive 12 volt signals. It probably won't hurt it, but I didn't want to chance it. The other key piece of information here is the conversion from pulse rate to an actual wind speed (distance/time) and required me calling Met One (which has great customer service) and getting them to send me the technical manual for the speed sensor. I'll attach that information below.

// Direction, Speed and LCD

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 7);
const byte BUTTON = 2;
float elapsed, diff, start;
float windspeed;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  digitalWrite (BUTTON, HIGH);  // internal pull-up resistor
  attachInterrupt (0, pinChange, RISING);  // attach interrupt handler
  start = millis();
   // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("Deg   -&-   Mph");
// Interrupt Process
void pinChange ()
  elapsed=millis()-start;         //gets the full period (in ms) of rotation 
  windspeed=(1.789*(1/elapsed))+1;//2.5/(elapsed/1000);   //gets freq from ms then * by 2.5 to get mph (according to hardware spec)
  start=millis();                 //resets the counter

}  // end of Interrupt Loop

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValueDir = analogRead(A0);
  int sensorValueSpd = analogRead(A5);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltageDir = sensorValueDir * (2.5 / 1023.0);
  float voltageSpd = sensorValueSpd * (12 / 1023.0);
  // convert coltage to degrees, 0 & 360 = North, 90=East, 180= South, 270=West
  float degree = voltageDir * (720 / 2.5); 
  // print out the value you read:
  // create a string of variables
 int MyPrintln(float voltageDir, float degree, float voltageSpd, float windspeed);
// print the variables in that string
  Serial.print(" Volts_Dir  ");
  Serial.print(" Degrees     ");
  Serial.print(" Volts_Spd ");
  Serial.print(" Mph ");
// print to LCD screen

  // set the cursor to column 0, line 0
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(1, 0);
    // print the wind vane degrees:
    // print the wind vane degrees:
  lcd.print("  Mph");
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(1, 1);
    // print the wind vane degrees:
    // print the wind vane degrees:
  lcd.print(" Deg.North");
Met one 010C user manual is attached below. Page 6 has the transfer functions required to convert pulse rate to distance/time.

Ted Bibby,
Nov 3, 2014, 9:43 AM