← Back to Course
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.
×