OC
OceanRemote
Low-code IoT platform
← Back to Course

Wind Vane - Wind Direction

🧭 Wind Vane - Wind Direction Measurement

📖 Wind Direction Code:

#define WIND_DIR_PIN 36

String readWindDirection() {
    int raw = analogRead(WIND_DIR_PIN);
    
    // Map voltage to direction (calibrate for your sensor)
    if (raw < 100) return "N";
    else if (raw < 300) return "NE";
    else if (raw < 500) return "E";
    else if (raw < 700) return "SE";
    else if (raw < 900) return "S";
    else if (raw < 1100) return "SW";
    else if (raw < 2800) return "W";
    else return "NW";
}

void loop() {
    String direction = readWindDirection();
    Serial.printf("Wind Direction: %s\n", direction.c_str());
    
    // Pesticide advice based on wind direction
    if (direction == "N") {
        Serial.println("Wind from North - Avoid spraying south fields");
    }
    delay(5000);
}
    
💡 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.