A wind direction sensor using a vane and potentiometer with Arduino is a fundamental component of any complete DIY weather station. Knowing wind direction helps farmers predict rainfall patterns, assists drone operators in choosing safe flying times, and provides valuable microclimate data for rooftop solar panel positioning across India. This guide covers the working principle of wind vanes, how to wire a potentiometer-based wind direction sensor to Arduino, and how to display compass directions accurately.
Table of Contents
- How Wind Direction Sensors Work
- Types of Wind Vane Sensors
- Wiring a Potentiometer Wind Vane to Arduino
- Arduino Code for Wind Direction
- Converting ADC Values to Compass Directions
- Calibration for Indian Conditions
- Logging Wind Direction Data
- Frequently Asked Questions
How Wind Direction Sensors Work
A wind vane consists of a rotating fin assembly mounted on a bearing. The fin aligns itself with the prevailing wind direction. A transducer converts the rotational position of the fin to an electrical signal. The most common transducer types are:
- Resistive (Potentiometer): The vane shaft is mechanically coupled to a 360-degree rotary potentiometer. Wind rotation changes the resistance, which changes the voltage at the wiper. Simple, cheap, and works with any ADC.
- Reed switch array: Used in commercial weather stations (like Davis Vantage). Multiple reed switches trip as a magnet rotates, giving discrete 8-direction or 16-direction output. More reliable long-term but more expensive.
- Hall effect encoder: Uses a magnetic encoder for true 360-degree digital output. Highest accuracy and longevity but requires specialised ICs.
- Optical encoder: Uses a slotted disc and photointerrupter. Very accurate but sensitive to dust and moisture—problematic in Indian conditions.
For DIY builds, the potentiometer approach is the most accessible and costs ₹50–₹200 for a suitable 10K 360-degree rotary potentiometer.
Types of Wind Vane Sensors
Several ready-made wind direction sensors are available for hobbyist projects:
- Sparkfun/Generic Wind Vane (reed switch): 8-directional output using 8 reed switches and a switching resistor network. Popular in Raspberry Pi weather station kits. Costs ₹800–₹1,500.
- RK100-02 Wind Direction Sensor: Industrial 4-20mA or 0-5V output, IP65-rated, 360-degree continuous rotation. Costs ₹2,500–₹5,000. Best for permanent outdoor installations.
- DIY Potentiometer Vane: Build your own using a 3D-printed or aluminium fin, a bearing, and a 360-degree potentiometer. Total cost ₹200–₹500.
- Digital Wind Vane (SPI/I2C): Newer products from DFRobot and Adafruit using magnetic encoders with I2C output. Easier to code but more expensive (₹2,000–₹3,000).
Wiring a Potentiometer Wind Vane to Arduino
For a resistive potentiometer-based wind vane, the wiring is straightforward. The potentiometer has three terminals: two end terminals and one wiper terminal.
| Potentiometer Pin | Arduino Pin |
|---|---|
| End Terminal 1 | 5V (or 3.3V for ESP32) |
| End Terminal 2 | GND |
| Wiper | A0 (Analog Input) |
For the reed switch type (like the Sparkfun wind vane), connect one terminal to 3.3V or 5V through a 10K pull-up resistor, the other to GND, and the signal wire to an analog pin. The switching resistor network inside the vane creates different voltage levels for each of 8 or 16 wind directions.
Arduino Code for Wind Direction
// Wind Direction Sensor with Potentiometer
// Reads analog value and converts to compass direction
const int WIND_DIR_PIN = A0;
const int NUM_READINGS = 10; // Average multiple readings
// Calibration values - adjust for your specific potentiometer
const int POT_MIN = 0; // ADC value at 0 degrees (North)
const int POT_MAX = 1023; // ADC value at 359 degrees
String getCompassDirection(float degrees) {
const char* directions[] = {
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
};
int index = (int)((degrees + 11.25) / 22.5) % 16;
return String(directions[index]);
}
float readWindDirection() {
long total = 0;
for (int i = 0; i < NUM_READINGS; i++) {
total += analogRead(WIND_DIR_PIN);
delay(10);
}
int avgADC = total / NUM_READINGS;
// Map ADC value to degrees
float degrees = map(avgADC, POT_MIN, POT_MAX, 0, 359);
return degrees;
}
void setup() {
Serial.begin(9600);
}
void loop() {
float windDegrees = readWindDirection();
String compass = getCompassDirection(windDegrees);
Serial.print("Wind Direction: ");
Serial.print(windDegrees, 1);
Serial.print(" degrees (");
Serial.print(compass);
Serial.println(")");
delay(1000);
}
Converting ADC Values to Compass Directions
A standard compass rose divides 360 degrees into 16 named directions (N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW). Each direction spans 22.5 degrees. The getCompassDirection() function in the code above maps a degrees value to the nearest 16-point compass direction.
For the common reed-switch wind vane (8 directions), each direction has a specific resistance value in the internal resistor network. Map these resistance/voltage values to directions:
| Direction | ADC Value (5V, 10K pullup) |
|---|---|
| North | ~790 |
| NE | ~406 |
| East | ~461 |
| SE | ~98 |
| South | ~185 |
| SW | ~157 |
| West | ~541 |
| NW | ~666 |
Calibration for Indian Conditions
Calibration is critical for accurate wind direction readings. In India’s hot, humid conditions, potentiometer resistance can drift with temperature. Follow this calibration procedure:
- Mount the vane on a level surface with the fin pointing true North (use a compass app on your phone)
- Record the ADC value — this is your North reference
- Rotate the vane 90 degrees clockwise (East) and record the ADC value
- Continue for South (180 degrees) and West (270 degrees)
- If the ADC values are evenly spaced, your potentiometer is linear and a simple map() function works
- If values are not evenly spaced, create a lookup table with interpolation
Repeat calibration during summer (April-June) and monsoon (July-September) to account for seasonal resistance drift. A well-calibrated vane should be accurate to within 5-10 degrees.
Logging Wind Direction Data
Wind direction data is most useful when logged over time to identify prevailing wind patterns. For Indian locations, the prevailing winds shift seasonally: southwest monsoon winds in June-September, northeast winds in November-January, and variable conditions in between. Log at least 12 months of hourly data before drawing conclusions about your site’s wind patterns for applications like turbine siting or drone operation planning.
When logging wind direction, use circular statistics (mean circular direction, circular standard deviation) rather than standard arithmetic mean. A simple arithmetic average of 350 degrees and 10 degrees would give 180 degrees (South), which is completely wrong — the true average is North (0/360 degrees). Use the atan2() function with sin/cos decomposition for correct circular averaging.
Frequently Asked Questions
How do I align a wind vane to true North vs magnetic North?
Most compass apps on smartphones show magnetic North. True North (geographic North) differs from magnetic North by the magnetic declination angle, which varies by location in India. For most Indian locations, magnetic declination is approximately 0 to 5 degrees East, which is small enough to ignore for hobbyist applications. Use the declination.gs website to find the exact value for your location if you need precision.
Why does my potentiometer wind vane give erratic readings in the monsoon?
Moisture ingress into the potentiometer causes erratic resistance changes and noisy readings. Use a sealed potentiometer (IP65 rated) or apply conformal coating to the potentiometer body. Alternatively, mount the electronics inside a sealed enclosure and use a longer shaft extension to connect the fin to the potentiometer through a sealed bearing. Silicone-sealed industrial potentiometers rated for outdoor use cost ₹400–₹800 from automation component suppliers.
Can I use a magnetometer (compass IC) instead of a mechanical wind vane?
Yes, this approach uses a small magnet on the wind vane shaft and a fixed magnetometer IC (like the HMC5883L or QMC5883L) to detect the magnet’s orientation. It avoids mechanical contact and is more reliable long-term. The QMC5883L module costs around ₹50–₹100 and communicates via I2C. However, this approach requires careful magnetic shielding from nearby motors or metal structures that could interfere with the magnetometer.
What is the minimum wind speed needed to turn a DIY wind vane?
This depends on the bearing friction, fin weight, and fin surface area. A well-designed vane with quality bearings (ABEC-5 rated) should respond to winds above 1 m/s. Poorly balanced vanes with high-friction bearings may need 3-5 m/s to move reliably. For reference, the Beaufort scale defines Force 1 (light air) as 0.3-1.5 m/s — the threshold where a wind vane should just begin to respond.
How do I integrate wind direction with a weather website or mobile app?
Upload wind direction data from ESP32 to ThingSpeak, InfluxDB, or a custom REST API. Display it using a wind rose chart (a circular chart showing frequency of winds from each direction). Chart.js with the chartjs-chart-windrose plugin creates excellent wind rose visualisations for web dashboards. For mobile apps, MIT App Inventor or Flutter with a canvas widget can render wind direction displays using your ESP32’s data via MQTT or HTTP API.
Add comment