โ 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.
×