Wind Site Survey Station with ESP32 - Proteus Simulation: the ESP32, the cup anemometer, the wind vane and the OLED

Wind Site Survey Station with ESP32 - Proteus Simulation

40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the Wind Site Survey Station with ESP32 - Proteus Simulation, the seventy-first project of our IoT Projects series. If you have searched for an ESP32 anemometer and wind vane project, how to measure turbulence intensity and wind power density, how to average wind directions correctly, or a Proteus simulation of a weather mast, here is a complete one. Before anyone puts up a wind turbine, the site is measured for months: how strong the wind is, how gusty, where it comes from, and how much energy it really carries. This ESP32 does that survey with a cup anemometer and a wind vane, and shows the numbers a turbine designer looks at.

Two of those numbers hide classic traps. The energy in the wind grows with the cube of the speed, so the power of the average wind is not the average power of the wind: a gusty site carries more energy than its mean speed suggests. And wind directions cannot be averaged like ordinary numbers: the average of 350 and 10 degrees is north, not south. In this tutorial, we will go through the circuit, count the anemometer's pulses with an interrupt, decode the vane's sixteen resistances, work out the turbulence intensity, the gust factor, the power density and the energy pattern factor, average the direction with vectors, and estimate what a small turbine would make. Then we run the simulation in a steady wind, a gusty wind, a wind that wanders around north and a wind that shifts. At the end, you can download the project with the sketch and every library file.

NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the wind site survey station with ESP32 in Proteus simulation:

Wind Site Survey Station with ESP32 - Proteus Simulation: the ESP32, the cup anemometer, the wind vane and the OLED
Figure: The wind site survey in a Proteus simulation: a gusty wind measured.
Wind Site Survey Station with ESP32: the working Proteus simulation, an animated view of the project's main steps
Figure: The project working in the Proteus simulation (an animation of the main steps).

What Does This Wind Survey Station Do?

  • Measures the speed: a cup anemometer gives a pulse for every bit of rotation; the ESP32 counts them with an interrupt and turns the count into metres per second with the maker's line.
  • Measures the direction: a wind vane closes one or two of eight reed switches, each with its own resistor; the ESP32 reads the resistance and finds which of the sixteen directions it is.
  • Describes the wind: over the last 30 seconds, the mean, the standard deviation, the turbulence intensity, the gust and the gust factor.
  • Weighs its energy: the wind power density from the mean of the cubed speeds, compared with the power of the mean speed: their ratio is the energy pattern factor.
  • Averages the direction properly: as vectors, with a steadiness number, next to the plain average of the angles to show why that one fails.
  • Estimates a turbine's yield: what a small 0.5 m rotor would make there, in watts and in watt-hours a day.
  • Shows it all: a 0.91" OLED and a dashboard with the sixteen sectors on a laptop or a phone.

It is a great project for learning interrupts, sensor decoding, a little statistics and the physics of wind energy together. In the simulation, the anemometer's pop-up shows the cups, the pulses on its output and the Beaufort scale, and its chips give a steady or a gusty wind; the vane's pop-up shows the vane, its reed switches and its sixteen positions, and its chips make the wind steady, veering, shifting or wandering.

Components Used in the Proteus Simulation

All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file.

The parts of the wind survey station and their library posts
PartProteus deviceLibrary postConnection
ESP32 DevKit V1ESP32 DEVKIT V1ESP32 DevKit V1 Library for ProteusU1, ESP32_Wind_Survey.hex, TEP-WiFi 192.168.1.101
Cup anemometer (pulse output)WINDSPEEDSENSORTEPAnemometer Wind Speed Sensor Library for ProteusAN1: VCC +5V, OUT through the divider to D27
Wind vane (16 positions)WINDVANETEPWind Vane Direction Sensor Library for ProteusWV1: SIG to D34 with a 10k pull-up
SMD resistorsRESISTORSMD1206TEPSMD Resistor LibraryR1 10k pull-up, R2 10k / R3 20k divider
SSD1306 OLED 0.91" 128x32OLED12832WHITEADVTEPOLED 128x32 Library for ProteusOLED1, I2C at 0x3C
Laptop WiFi MonitorLAPTOP WIFI MONITORLaptop WiFi MonitorPC1
Mobile WiFi MonitorMOBILE WIFI MONITORMobile WiFi MonitorMOB1

Proteus Simulation of the Wind Survey: the Circuit

Wind site survey Proteus simulation circuit: ESP32 DevKit V1, a cup anemometer, a wind vane, three resistors and an OLED
Figure: The complete circuit of the wind survey station on an A3 Proteus sheet.
The connections of the wind survey station
PartPinsESP32 / supply
AN1 anemometerVCC / GND / OUT+5V / GND / PULSE
R2 / R310k PULSE to ANEMO, 20k ANEMO to GNDANEMO to D27
WV1 vaneSIG / GNDVANE (D34) / GND
R110k VANE to +3.3Vthe pull-up
OLED1SDA / SCL / VCCD21 / D22 / +3.3V

The anemometer needs 5 to 24 V, and its output pulses swing up to its supply, so 5 V pulses would be too much for an ESP32 input. R2 and R3 divide them by 1.5: 5 V x 20k / (10k + 20k) = 3.33 V. The vane is only a resistance between its two wires, so a 10k pull-up to 3.3 V turns it into a voltage on D34, an ADC1 pin that keeps working while Wi-Fi is on. Both sensors have their pins on the bottom edge of their plates. The OLED shares the I2C bus on D21 and D22.

How the Wind Survey Station Works

Counting the Cups

Inside the anemometer a magnet on the cups' shaft passes a sensor, and the output gives a pulse train whose frequency follows the wind. The maker's line is wind speed = 0.5 + 0.169 x the pulses in one second; under 0.5 m/s the cups do not turn. Worked example: at 8 m/s the sensor gives (8 - 0.5) / 0.169 = 44.4 pulses a second, one every 22.5 ms. The ESP32 counts the rising edges with an interrupt, so no pulse is missed while it serves the dashboard, and once a second it turns the count into a speed. Counting whole pulses in one second gives steps of 0.169 m/s; at a steady 8 m/s the count alternates between 44 and 45, which shows up as a standard deviation of about 0.08 m/s even in a perfectly steady wind.

Decoding the Vane

The vane carries a magnet over eight reed switches, and each switch has its own resistor: 33k north, 8.2k north-east, 1k east, 2.2k south-east, 3.9k south, 16k south-west, 120k west and 64.9k north-west. Between two switches the magnet closes both, and the two resistors in parallel give eight more values, sixteen in all. Worked example: north-north-east closes north and north-east, 33k x 8.2k / (33k + 8.2k) = 6.57k. With the 10k pull-up to 3.3 V, north gives 3.3 x 33 / (33 + 10) = 2.53 V. The ESP32 turns the voltage back into a resistance and picks the nearest of the sixteen on a logarithmic scale, because the resistors are spread over two decades and a fixed tolerance in volts would be far too tight at the low end and far too loose at the high end.

Turbulence Intensity and Gusts

Every second the ESP32 stores a speed and a direction, and keeps the last 30. From them: the mean, the standard deviation, and their ratio, the turbulence intensity TI = sd / mean. A smooth wind over the sea may have a TI under 10 %; a gusty wind over rough land 20 % or more, and turbines are designed for a given turbulence class. The gust is the highest 3-second mean, the usual definition in wind engineering, and the gust factor is the gust divided by the mean.

The Power in the Wind, and the Trap of the Mean

The power of the wind through one square metre is half the air density times the speed cubed: the wind power density. At a steady 8 m/s that is 0.5 x 1.225 x 8 x 8 x 8 = 314 W per square metre. But a real wind changes, and because of the cube the strong moments count far more than the weak ones. Worked example: a wind that blows 4 m/s half the time and 12 m/s the other half also averages 8 m/s, but the mean of the cubes is (64 + 1728) / 2 = 896, and the power density is 0.5 x 1.225 x 896 = 549 W per square metre, 75 % more than the 314 of the mean speed. The ratio of the mean of the cubes to the cube of the mean is the energy pattern factor (EPF); real sites are often near 1.9. So the ESP32 cubes every sample first and averages afterwards.

Averaging Directions

Directions live on a circle, and the plain average of the angles fails wherever the wind crosses north. Worked example: 350 and 10 degrees, two winds a little either side of north, average to (350 + 10) / 2 = 180 degrees, due south. The right way treats each direction as a unit vector: sum the sines and the cosines, and take atan2 of the sums. For 350 and 10 degrees the sines cancel, -0.174 + 0.174 = 0, the cosines add, 0.985 + 0.985 = 1.97, and atan2(0, 1.97) = 0 degrees, north. The length of the summed vector divided by the number of samples, here 1.97 / 2 = 0.985, is the steadiness R: 1 for a wind that never changes direction, near 0 for one that comes from everywhere. The ESP32 shows both averages, so the difference can be seen in the simulation.

What a Small Turbine Would Make

Multiply the power density by a rotor's swept area and its power coefficient and the result is the turbine's output. The survey uses the small turbine of our earlier wind projects: a 0.5 m rotor, 0.196 square metres, with a power coefficient of 0.25. Worked example at a steady 8 m/s: 0.25 x 314 x 0.196 = 15.4 W, or 369 Wh in a day if the wind kept blowing. The same arithmetic shows why the energy pattern factor matters: a gusty site at the same mean speed gives the turbine proportionally more.

The Arduino Code Explained

The sketch is ESP32_Wind_Survey.ino, written in the Arduino IDE for the ESP32 DevKit V1. It uses WiFi and WebServer for the dashboard and Adafruit SSD1306 for the OLED. The vane's sixteen resistances, in the order of the directions:

const float OHMS[16] = {33000, 6570, 8200, 891, 1000, 688, 2200, 1407, 3900, 3136, 16000, 14118, 120000, 42103, 64900, 21876};

The anemometer's pulses, counted by an interrupt:

void onPulse() { pulses++; }
  attachInterrupt(digitalPinToInterrupt(ANEMO), onPulse, RISING);

Once a second, the count becomes a speed with the maker's line:

  vNow = c > 0 ? 0.5 + 0.169 * c : 0;

The vane: the voltage back to a resistance, then the nearest of the sixteen on a log scale:

  float r = R_PULL * mv / (V_SUP - mv);
  for (int k = 0; k < 16; k++) { float d = fabs(log(r / OHMS[k])); if (d < bd) { bd = d; best = k; } }

The turbulence intensity and the energy pattern factor:

  ti = mean > 0.5 ? sd / mean : 0;
  epf = mean > 0.5 ? m3 / (mean * mean * mean) : 0;

The power density from the mean of the cubes, the right way:

  pd = 0.5 * RHO * m3;                                              // W/m2: the right way

The gust: the highest mean of three seconds in a row:

    if (k + 2 < n) gust = max(gust, (vs[a] + vs[b] + vs[c]) / 3);

The directions as vectors, and the plain sum of the angles for comparison:

    sx += sin(a); sy += cos(a); sa += ds[k] * 22.5; hist[ds[k]]++;
  vecDir = atan2(sx, sy) * 180 / PI; if (vecDir < 0) vecDir += 360;
  steady = sqrt(sx * sx + sy * sy) / n;

And the small turbine's output:

  turbine = CP * pd * AREA;

The OLED gets a new frame every second: the mean, the TI and the gust factor; the direction and the steadiness; the power density and the EPF; the turbine's watt-hours a day. Every 5 seconds a report line goes to the serial monitor, and a line marks each change between STEADY and GUSTY (TI above 10 %). The pages are / (the dashboard, with the seconds spent in each of the sixteen sectors) and /data (JSON), served from one handler.

How to Run the Proteus Simulation

  1. Download the project zip below and install the library files (the steps are under the download button).
  2. Open ESP32-Wind-Survey.pdsprj from the Proteus Simulation folder. Keep the HEX file and the DLL files next to it.
  3. Press Play. A steady 8 m/s from the north; after 30 s the window is full.
  4. On the anemometer's pop-up (AN1) press Gusts; on the vane's pop-up (WV1) press Gusts, then Shift.
  5. Open the Laptop or the Mobile WiFi Monitor and press Go for the dashboard.

Simulation Results: the Wind Survey in Proteus

We ran the whole story in one simulation: a steady wind, then gusts, then a wind that wanders around north, then a wind that jumps between four directions. The anemometer started at a steady 8 m/s and the vane pointed north. After 30 seconds the window was full:

Wind survey Proteus simulation in a steady 8 m/s wind: the ESP32, the anemometer, the vane and the OLED
Figure: The wind survey simulation: a steady 8 m/s from the north.
Anemometer pop-up in the Proteus simulation: 8.0 m/s, 44.4 pulses a second, 333 RPM
Figure: The anemometer at 8 m/s: 44.4 pulses a second on OUT.
Wind vane pop-up in the Proteus simulation: the wind from the north, 33 kohm, 2.53 V on SIG
Figure: The vane pointing north: 33 kohm, 2.53 V on SIG.

Every number agrees with the worked examples. The anemometer's pop-up shows 44.4 pulses a second for 8 m/s and the vane's 33 kohm and 2.53 V for north. The serial monitor printed:

  32.3 s  mean 8.00 m/s, sd 0.08, TI 1.0 %, gust 8.0 (GF 1.01), EPF 1.00, 313 W/m2 (the mean's 313); dir N 0 deg (plain average 0), R 1.00

That is a mean of 8.00 m/s and a power density of 313 to 314 W per square metre. In a steady wind the mean of the cubes equals the cube of the mean, so the EPF is 1.00. The TI of 1 % is only the 44 or 45 pulses of each second, as expected. The OLED and the dashboard show the same window, with 369 Wh a day for the small turbine:

OLED pop-up in the Proteus simulation: 8.0 M/S, TI 1 %, DIR N, 314 W/M2, 369 WH/DAY
Figure: The OLED in the steady wind: 314 W/m2 and 369 Wh a day.
Laptop WiFi Monitor in the Proteus simulation: the wind survey dashboard in the steady wind
Figure: The dashboard on the Laptop WiFi Monitor: 30 seconds from the north.

Then we pressed Gusts on the anemometer's pop-up, at 40.5 seconds. Within a few seconds the turbulence intensity started to climb: 3.6 % at 42.3 s, then 7.4 %, then 9.9 %. At 63.3 s the sketch printed GUSTY - TI 10.3 %, and once the whole window was gusty:

  72.3 s  mean 8.22 m/s, sd 0.94, TI 11.5 %, gust 8.3 (GF 1.01), EPF 1.04, 354 W/m2 (the mean's 341); dir N 0 deg (plain average 0), R 1.00
Wind survey Proteus simulation in a gusty wind: the anemometer turning faster and slower
Figure: The wind survey simulation in a gusty wind.
Anemometer pop-up in the Proteus simulation: a gusty wind, the cups lagging behind the air
Figure: The anemometer in gusts: the cups lag behind the wind.

The energy pattern factor rose to 1.04, so the gusty wind carries 354 W per square metre where its mean speed alone says 341. A simple rule ties the two numbers together: for a wind with small turbulence, EPF is about 1 + 3 x TI squared, and 1 + 3 x 0.115 x 0.115 = 1.04. The gust factor, however, stayed at 1.01, and this is a lesson in itself. The model's gusts are two quick waves, 3.1 and 1.3 seconds long, and the cups lag behind the air (the pop-up shows the wind at 5.1 m/s while the sensor still shows 7.2 m/s). A 3-second mean covers almost a whole wave and smooths it out, while the 1-second samples still swing. That is exactly why a gust must always be quoted with its averaging time: real gusts last longer, and over a ten-minute record the 3-second gust is typically 1.3 to 1.5 times the mean.

OLED pop-up in the Proteus simulation: TI 11 %, GF 1.00, 362 W/M2, EPF 1.04
Figure: The OLED in gusts: TI 11 %, EPF 1.04.
Laptop dashboard in the Proteus simulation: the gusty wind measured, 358 W/m2 against 344
Figure: The dashboard in gusts: the power density above the mean wind's.

Next we pressed Gusts on the vane's pop-up, at 76.3 seconds, and the wind began to wander from north-west to north-north-east. This is where the plain average fails:

  113.3 s  mean 8.27 m/s, sd 0.96, TI 11.6 %, gust 8.3 (GF 1.01), EPF 1.04, 361 W/m2 (the mean's 347); dir N 359 deg (plain average 107), R 0.93
Wind survey Proteus simulation: the wind wandering around north, the vane swinging
Figure: The wind survey simulation: the wind wandering around north.
Wind vane pop-up in the Proteus simulation: the vane swinging to the north-west, 64.9 kohm
Figure: The vane swinging to the north-west.

The vector mean says 359 degrees, north, with a steadiness of 0.93: a wind that moves around but clearly comes from the north. The plain average of the same 30 directions says 107 degrees, east-south-east, a direction the wind never came from at all. The angles just west of north are near 360 and the ones just east of it near 0, so their plain average lands in between, on the wrong side of the compass. The dashboard's sectors show where the seconds went: north 11 s, north-north-east 8 s, north-east 1 s, north-west 2 s and north-north-west 8 s.

OLED pop-up in the Proteus simulation: DIR N 359, R 0.93, the vector-mean direction
Figure: The OLED: DIR N 359 with a steadiness of 0.93.
Laptop dashboard in the Proteus simulation: vector mean N 359 deg against the plain average 119
Figure: The dashboard: the vector mean against the plain average.

Last, we pressed Shift on the vane's pop-up, at 111.8 seconds: the wind now jumps by 90 degrees at a time. Watch the steadiness fall as the window fills with the new directions: 0.70, 0.61, 0.42, 0.24, 0.14, 0.08 and finally 0.03:

  148.3 s  mean 8.29 m/s, sd 0.93, TI 11.2 %, gust 8.3 (GF 1.01), EPF 1.04, 361 W/m2 (the mean's 348); dir NE 38 deg (plain average 131), R 0.03
Wind survey Proteus simulation: the wind shifting by 90 degrees, the steadiness falling
Figure: The wind survey simulation: the wind shifting by 90 degrees.
Wind vane pop-up in the Proteus simulation: the vane jumping between directions
Figure: The vane jumping between four directions.

With the wind spread evenly over north, east, south and west (8, 6, 7 and 8 seconds), the summed vectors almost cancel. A steadiness of 0.03 says that no mean direction means anything here, whatever angle the arithmetic gives. For a wind turbine this matters as much as the speed: a rotor that has to keep turning to follow the wind loses energy and wears its yaw drive.

Laptop dashboard in the Proteus simulation: steadiness 0.08, the seconds in each sector
Figure: The dashboard at the end: the sectors of a shifting wind.
Mobile WiFi Monitor in the Proteus simulation: the wind survey dashboard on a phone
Figure: The same dashboard on the Mobile WiFi Monitor.
ESP32 serial monitor in the Proteus simulation: the survey reports every 5 seconds
Figure: The serial monitor: a report every 5 seconds through the whole run.

The run covered 148 seconds of simulation in 968 seconds on our PC. Throughout it the anemometer's and the vane's own pop-ups gave an independent check of every reading.

Download the Project Files

Click the button below to download Wind-Site-Survey-Station-ESP32-Proteus-Simulation-v1.0.zip (about 4.1 MB, without the source code of the models):

Wind Site Survey Station with ESP32 - Proteus Simulation V1.0
  • Proteus Simulation: ESP32-Wind-Survey.pdsprj, ESP32_Wind_Survey.hex and copies of the models.
  • Arduino Code: ESP32_Wind_Survey.ino, the sketch.
  • Proteus Library Files: the LIB files of the ESP32 DevKit V1, the anemometer, the wind vane, the SMD resistor, the OLED and the two WiFi Monitors.
  • Proteus Model Files: the DLL models.
  • README.txt: the installation steps, the properties, the test results and the links to every library post.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install the Project Files

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Start Proteus and open the project from the Proteus Simulation folder.

Changing the Code

Open ESP32_Wind_Survey.ino in the Arduino IDE with the TEP boards for Proteus installed, compile it, export the compiled binary and set U1's PROGRAM property to the new HEX file. The window length, the air density, the turbine's area and power coefficient, the pull-up and the resistances are at the top. In the sensors' properties, WIND and PROFILE set the wind, DIRECTION and RATE the vane's.

Ideas to Extend the Project

  • Keep the survey for longer: ten-minute means, as the wind industry does, and a histogram of the speeds.
  • Fit a Weibull distribution to the speed histogram and compare its energy pattern factor with the measured one.
  • Log to an SD card or to a server and build a wind rose from days of data.
  • Add a temperature and pressure sensor and work out the real air density instead of the standard 1.225.
  • Measure at two heights and work out the wind shear exponent.
  • Feed the survey into the wind turbine MPPT project and compare the predicted and the harvested energy.

From Simulation to Real Hardware

  • Mount high and clear: a survey mast puts the sensors at the planned hub height, away from buildings and trees that make turbulence.
  • Align the vane: point its north mark to true north when you mount it, or every direction is off by the same angle.
  • Debounce the anemometer: a reed-switch anemometer can bounce; a small capacitor or a minimum time between counted pulses cleans it up.
  • Mind the long cable: the vane's resistances are high, so a long cable picks up noise; average a few readings.
  • Survey long enough: a real site survey runs for at least a year, because the wind changes with the seasons.

Troubleshooting

  • The speed reads 0: the anemometer needs 5 V on VCC; its OUT goes through the divider to D27.
  • The direction is stuck: SIG to D34 with the 10k pull-up to 3.3 V; under 0.5 m/s the vane does not turn.
  • The TI never reaches 0: counting whole pulses in one second gives 0.169 m/s steps; a steady wind still shows about 1 %.
  • The OLED stays blank: SDA / SCL on D21 / D22, address 0x3C, VCC on 3.3 V.

Limitations of the Simulation

  • The anemometer and the vane are the libraries' models: the maker's line, the cups' lag, the sixteen resistances, and their own profiles of the wind.
  • The two sensors have their own winds: the anemometer's gusts and the vane's wandering are set separately, as two chips.
  • The window is 30 seconds instead of the ten minutes of a real survey, so that the simulation shows each change quickly.
  • The network to the laptop and the phone is simulated inside Proteus.
  • ESP32 is a product of Espressif Systems; this project is not made or endorsed by them or by Labcenter.

So, that was all about the Wind Site Survey Station with ESP32 - Proteus Simulation. I hope it helps you understand how an anemometer and a vane are read, what turbulence intensity and gusts mean, why the energy of the wind must be averaged as cubes, how directions are averaged as vectors, and how a survey turns into a turbine's yield, all tested in a simulation before you put up a real mast. More IoT projects with the ESP32 and the Raspberry Pi 5 are coming in this series. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation