OC
OceanRemote
Low-code IoT platform
โ† Back to Course

Anemometer and Wind Vane - Wind Speed and Direction

Anemometer and Wind Vane - Wind Speed and Direction

๐Ÿ’จ Anemometer and Wind Vane - Measure Wind Speed and Direction

๐Ÿ’จ What You'll Learn:

  • ๐Ÿ“ก Measure wind speed using an anemometer (reed switch type)
  • ๐Ÿงญ Optional: Add wind vane for direction (8 directions)
  • ๐Ÿšซ Know when it's safe to spray pesticides (wind < 15 km/h)
  • ๐ŸŒพ Protect crops from wind damage

๐Ÿ”Œ Anemometer Wiring

Anemometer (Wind Speed)          ESP32
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•          โ•โ•โ•โ•โ•โ•โ•โ•
Red (VCC)              โ”€โ”€โ”€โ”€โ”€โ–บ    3.3V
Black (GND)            โ”€โ”€โ”€โ”€โ”€โ–บ    GND
Yellow (Signal)        โ”€โ”€โ”€โ”€โ”€โ–บ    GPIO34 (interrupt pin)

โš ๏ธ Add 10kฮฉ pull-up resistor between VCC and Signal if not built-in
    

๐Ÿ“– Wind Speed Code

#define WIND_PIN 34

volatile int pulseCount = 0;
float windSpeed = 0;
unsigned long lastCalc = 0;

void IRAM_ATTR pulseCounter() {
    pulseCount++;
}

void setup() {
    Serial.begin(115200);
    pinMode(WIND_PIN, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(WIND_PIN), pulseCounter, FALLING);
}

void loop() {
    if (millis() - lastCalc >= 5000) {
        // Calculate km/h (calibrate factor for your anemometer)
        windSpeed = pulseCount * 0.34;
        
        Serial.printf("๐Ÿ’จ Wind: %.1f km/h\n", windSpeed);
        
        if (windSpeed > 30) {
            Serial.println("   ๐Ÿšซ DO NOT spray - extreme wind");
        } else if (windSpeed > 15) {
            Serial.println("   โš ๏ธ Spray with caution - drift risk");
        } else if (windSpeed > 5) {
            Serial.println("   โœ… Safe to spray - light breeze");
        } else {
            Serial.println("   โœ… Ideal conditions - calm");
        }
        
        pulseCount = 0;
        lastCalc = millis();
    }
    delay(100);
}
    

๐Ÿงญ Optional: Wind Vane for Direction (Analog)

#define WIND_DIR_PIN 35

const char* directions[] = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"};
const int thresholds[] = {500, 1000, 1500, 2000, 2500, 3000, 3500, 4000};

String getDirection() {
    int val = analogRead(WIND_DIR_PIN);
    for (int i = 0; i < 8; i++) {
        if (val < thresholds[i]) return directions[i];
    }
    return "N";
}

void loop() {
    String dir = getDirection();
    Serial.printf("๐Ÿงญ Wind direction: %s\n", dir.c_str());
}
    
๐Ÿ’ก Calibrate Your Anemometer:
  • Each anemometer has a unique pulse factor
  • Default: 0.34 km/h per pulse/sec (many Chinese sensors)
  • To calibrate: Hold anemometer out car window at known speed, count pulses
  • Factor = Known speed รท Pulses per second
โš ๏ธ Spraying Safety Rules:
  • โŒ Never spray when wind > 15 km/h (chemical drift)
  • โœ… Best spraying times: Early morning (5-8 AM) or evening (6-9 PM)
  • ๐ŸŒฌ๏ธ Spray downwind, walk away from sensitive areas
  • ๐Ÿ“ Use coarse droplets in windy conditions (less drift)
๐ŸŽฏ Quick Reference:
  • ๐Ÿ’จ Wind < 5 km/h: โœ… Ideal for spraying
  • ๐Ÿ’จ Wind 5-15 km/h: โš ๏ธ Spray with caution
  • ๐Ÿ’จ Wind > 15 km/h: ๐Ÿšซ DO NOT spray
  • ๐Ÿงญ Wind direction helps avoid drift onto neighbors
๐Ÿ’ก Key Takeaways:
  • Apply these concepts directly to your farm or project.
  • Take notes on important details for the quiz.
  • Use the button below to track your progress.