 #define VANE_PIN A1
 #define SOLAR_PIN A2
 #define RAIN_GAUGE_PIN 11
+#define DHTPIN            9
+#define DHTTYPE           DHT22
 
 #define RAIN_FACTOR 0.2794
 #define WIND_FACTOR 2.4

  }
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();  
  WiFi.setSleepMode(M2M_PS_H_AUTOMATIC, 1);
  
}

void loop() {


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;
}



unsigned int getWindDirection() {
  digitalWrite(VANE_PWR, HIGH);
  unsigned int adc;
  adc = averageAnalogRead(VANE_PIN);
  digitalWrite(VANE_PWR, LOW);
  /*if (adc < 380) return (113);
    if (adc < 393) return (68);
    if (adc < 414) return (90);
    if (adc < 456) return (158);
    if (adc < 508) return (135);
    if (adc < 551) return (203);
    if (adc < 615) return (180);
    if (adc < 680) return (23);
    if (adc < 746) return (45);
    if (adc < 801) return (248);
    if (adc < 833) return (225);
    if (adc < 878) return (338);
    if (adc < 913) return (0);
    if (adc < 940) return (293);
    if (adc < 967) return (315);
    if (adc < 990) return (270);
    return (-1); // error, disconnected?  */
  return adc;
}

int averageAnalogRead(int pinToRead)
{
  byte numberOfReadings = 8;
  unsigned int runningValue = 0;

  for (int x = 0 ; x < numberOfReadings ; x++)
    runningValue += analogRead(pinToRead);
  runningValue /= numberOfReadings;

  return (runningValue);
}

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;

}


double getUnitRain()
{

  unsigned long reading = rain_count;
  rain_count = 0;
  double unit_rain = reading * RAIN_FACTOR;

  return unit_rain;
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
