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