This project will use PIC to measure wind speed, air temperature, and humidity. We start with some mechanics and build a device for catching wind and converting its speed into a series of impulses, whose frequency is proportional to the wind speed. The fully assembled device looks like this:
It consists of a rotor (the top part) with cups and their arms attached to it and a stator having a 1/2" thread at the end for mounting the anemometer on a deck or something. There are many similar projects on the Internet, here are some of them that gave me an inspiration:
I found the ping-pong balls used as cups in some projects are too fragile and won't survive strong winds that we sometimes get here at the Great Lakes Shore. The Easter Egg hulls are more reliable, but I could find any in stores at this time (August). However, there are plenty of semi-sphere shaped items in any grocery store. That is what I have found in Walgreens - women's nylon socks packed in almost perfect for my needs plastic cups.
The caps are of a 2" diameter and I put them on a 2" arms which are attached to a plastic round housing (see below). Each arm is made of a 1/4" aluminum round rod available in most hardware stores (I purchased a long rod at Home Depot). I drilled a 7mm hole at each end of the arm and put there a thread for #4-40 bolts (slightly less than M3). Here is the fully assembled rotor:
This was a very tricky part. I disassembled an old Maxtor 30Gb hard drive for the ball bearing. The drive uses an advanced technology, the motor coils and its controlling circuit are hidden within the rotating part. It took me quite a bit of work to take it out and remove the coils. This is what I ended up with the drive:
The bearing is just perfect, but unfortunately it cannot be directly used because the shaft is too short. To make it longer I used an aluminum spacer (called cable stop at Menards) and drilled a larger hole in it to match the hard disk shaft diameter. The hole should be a bit smaller than the shaft diameter because it is going to be mounted on the shaft with a hammer (you can see traces of my work in the photo). The other part of the spacer got threads for a #6-32 bolt. Fortunately the shaft diameter is the same to what is needed to make #6-32 threads.
The device housing is made of plastic pipe ends available in any hardware store (I got mine in Menards). It consists of three parts: the rotor (top item), the stator (the bottom part), and a cap. The rotor (to which the arms and cups are attached) is a 2" end cap, the stator is 1" to 1/2" adapter, and the cap has a 1/2" threads inside and is supposed to be attached to the stator at the bottom and also used as a fixing nut.
Most home-maid anemometers use opto-interrupters, i.e. a couple consisting of an LED and a phototransistor. Such devices are easy to reproduce, they are chip and reliable. The only disadvantage, which is crucial in my case, is that they draw several milliamperes of current. This is too much for powering the anemometer from a battery. The sensor data is going to be transmitted to a receiver at home, so a lower power consumption is an issue.
I used a Hall effect chopper A3242LUR. This IC draws only 1.5mA of current and even better Hall effect sensors are available that draw about 10μA! This sensor has an open collector output and shorts it to the ground as a magnetic field is applied. I use a set of two small 1/8" diameter magnets from RadioShack (Rare Earth Super Magnets set for $1.99). The magnets are glued to a specially machined aluminum rotor made of a 1/4" round rod of length 20mm. This part can be done in 10 minutes by filing the rod to the half of its diameter.
The center of the sensor rotor is mounted with a plastic bolt #6-32 to the bearing shaft extension (a steel bolt can be used too). Important: the chopper IC detects only the south pole of the magnets, so make sure to glue the right side of the magnets to the sensor rotor. The distance between the magnets and the sensor during the operation should not exceed 3 mm for their reliable detection.
The sensor IC is glued to the side of the stator housing. I made a small niche for it in the plastic wall of the housing with an soldering iron to prevent hitting it with a magnet.
To complete the stator assembly, put the bearing on the top of it with the sensor facing down. This way the sensor will be completely isolated (provided that a plastic closing cap at the bottom is attached. The bearing should be glued to the stator to prevent its moving and making the entire construction stable. The rotor cap with the cups mounted is fixed to the bearing shaft with a M2x12mm bolt.
Here is a test circuit for the sensor. The red and blue wires are for 5V power and the white wire (the chopper's IC output) is attached to +5V via a 10K pulling up resistor. The rest of the circuit is a DC/DC converter to get 5V out a 1.5V AA battery. The same circuit was used to figure out which magnet poles to glue to the sensor rotor part.
The sensor works very reliably and provides 2 pulses per rotation. I tested the anemometer in my garden for a short time just to evaluate its wind sensitivity. It catches reasonably week winds in almost the same range as my neighbor's industrial device. I mean that both anemometers start and stop rotating practically at the same time.
To calibrate the anemometer we used the following circuit. The Hall effect sensor is connected to the PIC at pin RB0 which can be used for initiating hardware interrupts. The number of pulses in a time unit is counted by the PIC and displayed on a 3-digit 7-segment LED. The counting time is about 4.19 sec (222μsec). The counted number of pulses is displayed for about 2 sec after which a new counting interval follows. The sequence of alternating counting and displaying repeats over and over. The entire circuit is powered from a 1.5 battery via a DC/DC converter providing 5V for the PIC, sensor, and LED.
Schematic | Test assembly | Back side |
---|---|---|
The device should be assembled on a pretty stable chassis to be used in a car test. I drove a car with a constant speed in 5mph intervals from 10mph to 40mph and my assistant hold the anemometer in hands and read the measurements. The oncoming wind at 40mph becomes noticeably strong, so we were a bit scared that we won't be able to hold the anemometer. Initially we were going to drive the car up to 45mph but had to skip the last speed because of that.
The test design is mounted on two wooden boards fixed together by an L-shape aluminum profile. The anemometer is fixed to the horizontal board with an 1/2" nut. The vertical board has a handle (I used a handle from an old table tennis pad). The test circuit is assembled on a solderless breadboard and is attached to the board by two steel brackets. The electronics is protected from the wind by several pieces of Scotch Magic tape. This is absolutely necessary to prevent the parts from falling down to the road at higher car speeds.
Most of the schematic and the code is the same as in our
Experiment with LED displays. The interrupt handling
routine (ISR) at memory address 004 is invoked every time a rising edge is
detected at input RB0. This happens when a magnet attached to the wind
catching semi-spheres passes the Hall effect sensor. The purpose of the ISR
is to increment the wind counter during the measurement interval. This
interval is distinguished by a high level at RA4 pin. Initially we
connected a LED to this pin (via a current-limiting resistor of 470Ohm) to
indicate the measurement interval. However, this LED was taken away in the
final version, since the measurement interval is clearly indicated by
shutting down the 7-segment LEDs.
Here is the complete code for testing.
After getting some feedback from people who showed an interest to this project I decided to upgrade it for a more recent microcontroller. My original intention was to put this device in my garden and let it transmit the wind data to the main station in house. However, that is what I did so far - a handheld device for occasional wind speed metering.
Schematic | Test assembly | Back side | New PCB | Back of PCB |
---|---|---|---|---|
The new device can be used as for calibrating the anemometer as well as for actual speed measuring. It works in 4 modes selected by switches S1 and S2. If S1 is on, the device counts pulses from the Hall effect sensor as it is described above (position of S2 for this mode is irrelevant and can be any). This mode is intended for calibration, see the next section. When S1 is off the devices uses the calibration table and the derived dependency of the number of pulses vs. wind speed to show the actual wind speed in km/h (if S2 is on) or m/s (if S2 is off). It is powered from 3xAA batteries and draws about 42mA of current. For longer battery life better use D-size batteries.
It is assumed that after assembling and burning in the supplied code into the PIC both switches must be turned off for calibrating your anemometer. The ICSP connector on board makes programming more convenient (I used Sullins connectors and E-Switch switches). Once the calibration is done and you got the formula as described in the next section, you should replace of the tables within the code (check functions convert1 and convert2) with your actual ones. If preferred speed units are m/h you will need to replace the table for convert1. In either case the measuring interval is still about 4 seconds and it is assumed that no more than 99 pulses will arrive from the sensor. If your sensor delivers more, reduce the measuring time to, say, 2 seconds in the software.
We took 5 measurements at each can speed and then averaged them. The results are in the table below.
Speed | Test1 | Test2 | Test3 | Test4 | Test5 | Average | Graph |
---|---|---|---|---|---|---|---|
10mph | 14 | 19 | 13 | 18 | 12 | 15.2 | |
15mph | 22 | 26 | 23 | 27 | 29 | 24.4 | |
20mph | 37 | 34 | 39 | 35 | 36 | 36.2 | |
25mph | 52 | 52 | 53 | 53 | 54 | 52.8 | |
30mph | 64 | 69 | 64 | 62 | 65 | 64.8 | |
35mph | 82 | 75 | 82 | 76 | 83 | 79.6 | |
40mph | 95 | 98 | 87 | 92 | 87 | 91.8 |
The orange curve in the above graph corresponds to the pulse number averages and the purple curve is the line approximation of the data by using the least square method. This method results in the line equation n = 2.62v - 13.2429, where n is the number of pulses and v is the wind speed. Unfortunately, this line does not pass through the origin, resulting at approximated 0 outcome at speeds below 5mph. This is partially due to a small number of magnets, hence pulses per rotation.
Solving the above equation for v results in the formula v = (n + 13.2429) / 2.62. Enter your own equation into the form below to obtain the microcontroller coding tables. Here is a table of rounded off wind speeds for my device formatted for a 2-digit display.
Enter your equation for v:
To be continued ...
Last modified:Mon, Jan 23, 2023.