← Back to Course
Anemometer - Wind Speed Measurement
💨 Anemometer - Wind Speed Measurement for Safe Farming
💨 What You'll Learn:
- 📡 Measure wind speed using a reed switch anemometer
- ⚡ Calculate wind speed from pulse counts (km/h, mph, m/s)
- 🚨 Set up high wind alerts for spraying safety
- 🌾 Protect crops from wind damage and lodging
Wind speed affects pesticide spraying, crop lodging, evapotranspiration, and irrigation efficiency. An anemometer helps you make safer, smarter decisions - never spray pesticides in high wind, and protect young crops before storms arrive.
🔧 Types of Anemometers
- 🌪️ Reed Switch Anemometer ($15-25): Most common for DIY. Magnet passes reed switch each rotation → electrical pulse. Works with ESP32 interrupts.
- 🔄 Hall Effect Anemometer ($20-35): More durable, no moving contact. Better for long-term outdoor use. Higher accuracy.
- 📡 Ultrasonic Anemometer ($100-300): No moving parts, highest accuracy. Professional use. Expensive for most farms.
- 💨 Cup Anemometer ($10-20): Simple mechanical design. Affordable but less accurate at low speeds.
💡 How Reed Switch Anemometer Works:
Each rotation of the wind cups = one electrical pulse. More pulses per second = higher wind speed. Calibration factor converts pulses per second to km/h.
Example: 10 pulses per second × 0.34 = 3.4 km/h wind speed.
🔌 Anemometer Wiring Diagram
═══════════════════════════════════════════════════════════════════════════════
REED SWITCH ANEMOMETER WIRING
═══════════════════════════════════════════════════════════════════════════════
Anemometer (3-wire) ESP32 Dev Board
═══════════════════ ══════════════════
Red (VCC) ──────────► 3.3V
Black (GND) ──────────► GND
Yellow (Signal) ──────────► GPIO35 (interrupt capable)
⚠️ IMPORTANT: Use a pull-up resistor (10kΩ) between VCC and Signal
if your anemometer doesn't have one built-in!
┌─────┐
│ │
│ 10kΩ│
│ │
└──┬──┘
│
3.3V┼──────────────────────► Anemometer Red
│
├──────────────────────► Anemometer Yellow (with pull-up)
│
GND ┼──────────────────────► Anemometer Black
═══════════════════════════════════════════════════════════════════════════════
ESP8266 ALTERNATIVE PINS
═══════════════════════════════════════════════════════════════════════════════
For ESP8266: Use D1 (GPIO5), D2 (GPIO4), D3 (GPIO0) or D5 (GPIO14)
Avoid GPIO16 (D0) - wake pin only
Recommended: GPIO5 (D1) - stable interrupt support
═══════════════════════════════════════════════════════════════════════════════
⚠️ Anemometer Calibration - IMPORTANT!
- ❌ Different anemometers have different pulse factors! The 0.34 factor is an example.
- ✅ How to calibrate: Drive at known speed (e.g., 30 km/h car) while holding anemometer out window. Count pulses per second.
- ✅ Formula: Wind Speed (km/h) = Pulses per second × (Known Speed ÷ Pulses)
- ✅ Example: At 30 km/h you count 50 pulses/sec → Factor = 30 ÷ 50 = 0.6
📊 Wind Speed Classification & Farm Actions
| Wind Speed (km/h) | Classification | Farm Actions |
|---|---|---|
| 0-5 km/h | 🟢 Calm | ✅ Ideal for spraying. Normal irrigation. |
| 5-15 km/h | 🟢 Light Breeze | ✅ Safe for spraying (with coarse droplets). |
| 15-25 km/h | 🟡 Moderate | ⚠️ Spray with caution - drift risk. Increase irrigation for evaporation. |
| 25-35 km/h | 🟡 Fresh Breeze | ❌ DO NOT spray pesticides. Secure young plants. |
| 35-50 km/h | 🔴 Strong Wind | 🚨 Emergency: Support tall crops, delay irrigation (high evaporation). |
| > 50 km/h | 🔴 Storm/Gale | 🚨 CRITICAL: Secure everything, stop field work, evacuate if necessary. |
💡 Why Wind Speed Matters for Spraying:
- 🌬️ Wind > 15 km/h: Pesticide drift = chemical lands on non-target areas (neighbors, water sources)
- 💨 Wind > 25 km/h: 50-80% of pesticide can miss target = wasted money + environmental damage
- ✅ Best spraying conditions: Early morning (5-8 AM) or evening (6-9 PM) when wind is calmest
- 🚫 Never spray when wind > 25 km/h: Illegal in many countries, dangerous to applicator, ineffective
📖 Complete Anemometer Code with Alerts
/*
* Anemometer - Wind Speed Measurement with Alerts
* Measures wind speed and provides safety recommendations
*
* Components:
* - Reed switch anemometer (or hall effect)
* - ESP32 board
* - 10kΩ pull-up resistor (if needed)
*/
#include <WiFi.h>
#include <HTTPClient.h>
// ========== PIN DEFINITIONS ==========
#define WIND_PIN 35 // GPIO35 (interrupt capable)
// ========== CALIBRATION FACTOR ==========
// Measure: Count pulses per second at known wind speed
// Factor = Wind Speed (km/h) ÷ Pulses per second
const float WIND_FACTOR = 0.34; // Example: 0.34 km/h per pulse/sec
// ========== ALERT THRESHOLDS ==========
const float SPRAY_MAX_WIND = 15.0; // Max safe wind for spraying (km/h)
const float HIGH_WIND_WARNING = 25.0; // High wind warning (km/h)
const float STORM_WARNING = 50.0; // Storm force wind (km/h)
// ========== GLOBAL VARIABLES ==========
volatile int pulseCount = 0;
float windSpeed = 0;
float maxWindSpeed = 0;
float minWindSpeed = 999;
float avgWindSpeed = 0;
unsigned long lastSecond = 0;
unsigned long lastLog = 0;
int totalPulses = 0;
int logCounter = 0;
// ========== INTERRUPT SERVICE ROUTINE ==========
void IRAM_ATTR pulseCounter() {
pulseCount++;
}
// ========== CALCULATE WIND SPEED ==========
float calculateWindSpeed() {
return pulseCount * WIND_FACTOR;
}
// ========== CHECK SPRAYING SAFETY ==========
bool isSafeToSpray() {
if (windSpeed <= SPRAY_MAX_WIND) {
return true;
}
return false;
}
String getSprayRecommendation() {
if (windSpeed <= 5) {
return "✅ Perfect conditions. Safe to spray any pesticide.";
} else if (windSpeed <= 10) {
return "✅ Good conditions. Use medium to coarse droplets.";
} else if (windSpeed <= 15) {
return "⚠️ Caution. Use coarse droplets. Check drift direction.";
} else if (windSpeed <= 25) {
return "❌ NOT recommended. High drift risk. Wait for calmer wind.";
} else {
return "🚫 DO NOT SPRAY! Wind too high. Postpone spraying.";
}
}
// ========== UPDATE STATISTICS ==========
void updateStatistics() {
if (windSpeed > maxWindSpeed) maxWindSpeed = windSpeed;
if (windSpeed < minWindSpeed) minWindSpeed = windSpeed;
totalPulses += pulseCount;
logCounter++;
avgWindSpeed = (totalPulses * WIND_FACTOR) / logCounter;
}
// ========== DISPLAY WIND REPORT ==========
void displayWindReport() {
Serial.println("\n╔══════════════════════════════════════════════════════════════╗");
Serial.println("║ 💨 WIND SPEED REPORT ║");
Serial.println("╚══════════════════════════════════════════════════════════════╝");
Serial.println("\n📊 CURRENT WIND:");
Serial.printf(" 💨 Speed: %.1f km/h\n", windSpeed);
// Visual wind indicator
int bars = (windSpeed / 10) + 1;
if (bars > 10) bars = 10;
Serial.print(" 📊 [");
for (int i = 0; i < 10; i++) {
if (i < bars) Serial.print("█");
else Serial.print("░");
}
Serial.println("]");
Serial.println("\n📈 STATISTICS (Last " + String(logCounter) + " readings):");
Serial.printf(" 🔼 Max: %.1f km/h\n", maxWindSpeed);
Serial.printf(" 🔽 Min: %.1f km/h\n", minWindSpeed);
Serial.printf(" 📊 Avg: %.1f km/h\n", avgWindSpeed);
Serial.println("\n🎯 SPRAYING RECOMMENDATION:");
Serial.println(" " + getSprayRecommendation());
if (windSpeed > HIGH_WIND_WARNING) {
Serial.println("\n⚠️ HIGH WIND WARNING:");
Serial.println(" - Secure young plants and tall crops");
Serial.println(" - Check irrigation system for wind drift");
Serial.println(" - Postpone any outdoor burning");
}
if (windSpeed > STORM_WARNING) {
Serial.println("\n🚨 STORM WARNING:");
Serial.println(" - Evacuate fields if necessary");
Serial.println(" - Secure all equipment");
Serial.println(" - Move livestock to shelter");
}
Serial.println("\n══════════════════════════════════════════════════════════════\n");
}
// ========== SEND TO OCEANREMOTE ==========
void sendToOceanRemote() {
if (WiFi.status() != WL_CONNECTED) return;
HTTPClient http;
http.begin("https://api.oceanremote.net/device/state");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String data = "token=YOUR_TOKEN";
data += "&wind_speed=" + String(windSpeed);
data += "&max_wind=" + String(maxWindSpeed);
data += "&spray_safe=" + String(isSafeToSpray() ? "YES" : "NO");
http.POST(data);
http.end();
}
// ========== SETUP ==========
void setup() {
Serial.begin(115200);
// Configure wind sensor pin
pinMode(WIND_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(WIND_PIN), pulseCounter, FALLING);
Serial.println("========================================");
Serial.println("💨 ANEMOMETER WIND MONITOR v2.0");
Serial.println(" Wind Speed Measurement System");
Serial.println("========================================\n");
Serial.printf("⚙️ Calibration factor: %.2f km/h per pulse/sec\n", WIND_FACTOR);
Serial.printf("⚠️ Spray safe threshold: %.0f km/h\n\n", SPRAY_MAX_WIND);
}
// ========== LOOP ==========
void loop() {
// Calculate wind speed every second
if (millis() - lastSecond >= 1000) {
windSpeed = calculateWindSpeed();
updateStatistics();
// Display every 10 seconds
if (millis() - lastLog >= 10000) {
displayWindReport();
sendToOceanRemote();
lastLog = millis();
}
// Reset pulse counter for next second
pulseCount = 0;
lastSecond = millis();
}
delay(10);
}
📖 Case Study - Anemometer Prevents Pesticide Disaster:
A large farm in South Africa installed an anemometer connected to their weather station:
- 💨 Morning wind: 8 km/h → Safe to spray
- ⚠️ Alert triggered at 11 AM: Wind increased to 28 km/h
- 🚫 Action: Spraying crew stopped immediately
- 💰 Savings: Prevented $2,000 worth of pesticide drift onto neighboring farm
- ⚖️ Avoided: Potential lawsuit and environmental fine
"The wind monitor saved us from a major mistake. We would have sprayed in dangerous conditions without it." - Farm Manager, South Africa
💡 Anemometer Placement Tips:
- 📍 Height: Mount at 2-3 meters above ground (crop canopy level + 1m)
- 📍 Location: Open area, away from buildings, trees, and structures that block wind
- 📍 Orientation: Ensure cups rotate freely (no obstructions, level mounting)
- 📍 Maintenance: Clean moving parts every 6 months, check for debris
- 📍 Lightning protection: Not recommended for storm monitoring - unplug during lightning
🎯 Key Takeaways:
- ✅ Wind < 15 km/h: Safe for spraying pesticides
- ✅ Wind 15-25 km/h: Spray with caution only (coarse droplets)
- ✅ Wind > 25 km/h: DO NOT spray - high drift risk
- ✅ Calibration factor: Unique to your anemometer - measure and set correctly
- ✅ Interrupt pins: Use GPIO32-39 on ESP32 for reliable pulse counting
- ✅ Always check wind before spraying: Prevents waste, environmental damage, legal issues
💡 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.
×