This wind logger project was designed to help a friend who wants to log wind speed for one year. It uses an inexpensive cup anemometer from Biral (see photo, left) available here in the UK. The anemometer contains a reed switch with rotating magnets which produce two switch closures per revolution of the cup assembly. It can be connected to produce a varying frequency output, whose frequency 0 - 100Hz corresponds to windspeeds of 0 - 40m/s.
The second part of the system is the datalogger from Sparkfun electronics in the US. The datalogger can log analogue inputs or serial data onto a standard SD memory card up to 1GByte. The output is a plain text file.
The problem is how to interface the anemometer pulse output to the datalogger? Biral do sell anemometers with an analogue output however they are typically five times the price of the more simple unit. So I designed a simple interface using an ATtiny2313 AVR microcontroller to count the pulse frequency and output a serial data stream of ASCII characters to the datalogger.
SPONSORED LINK: COMMERCIAL WIND LOGGER:
The ATtiny2313 circuit diagram is shown right (courtesy of John VK6JY). The crystal is 5.0688MHz between pins 4 and 5, which also have a 20pF capacitor to ground. There is a 10K resistor from the RESET pin 1 to +Vcc. The anemometer reed switch is connected between PORT D, bit 2 (pin 6) and Gnd. There is also a 10nF capacitor between +Vcc and Gnd; and a 1K resistor in series with a 2mm LED connected between PORT B, bit 0 (pin 12) and Gnd. This LED flashes once per rotation of the anemometer cup assembly in order to indicate correct operation of the system. Power for the ATtiny2313 is provided by the 3.3V on-board regulator of the datalogger.
The 5.0688MHz crystal frequency was chosen because it provides easy division in the ATtiny2313 for both the required 9600 baud serial data clock, and determination of suitable measurement intervals. The ATtiny2313 reads the PORT D, bit 2 (pin 6) input at a rate of 3.96kHz. This is used to debounce the anemometer reed switch (all mechanical switches produce multiple transitions at the instant of switching, which would cause false triggering). The number of input pulses is counted in software in a 16-bit counter for a period of 400 seconds. The resulting value is between 0 and 40,000 corresponding to average wind speeds of 0 - 40m/s at a sample rate of 400 seconds (9 readings per hour). This value is converted to ASCII with a decimal point in the appropriate position, and sent to the datalogger followed by a carriage return (CR) and line feed (LF) character. The output text file looks something like this:
01.132 02.217 01.747 01.302
CLICK HERE for the assembly program listing (thanks John VK6JY for beautifying it for me!) CLICK HERE to see an example output text file.
Initial setup of the system is simple. The reed switch of the anemometer is connected to the two pins on the circuit board (see photos below). Note that the anemometer also contains a heater which should be powered by 24V 1A DC to allow operation in cold weather. The datalogger requires a power supply of 3.6V to 7.5V at 80mA to be connected.
A standard SD-card should be formatted in FAT16 format and inserted into the datalogger. The datalogger automatically writes a configuration file on the SD-card, which you can check by removing the SD-card from the datalogger and inserting into your PC's cardreader. NO CHANGES ARE REQUIRED to this configuration file: the default settings are fine for this project. The SD-card can then be put back in the datalogger and power switched on. Read the datalogger datasheet for more information.
When datalogging is complete, the STOP button must be pressed on the datalogger board. THIS IS VERY IMPORTANT! It is needed in order to ensure that the last buffer is correctly written to the SD-card and the file is properly closed. The file name on the SD-card starts at LOG0.TXT with successive datalogging sessions creating files named LOG1.TXT, LOG2.TXT and so on.
The datalogger text files can be loaded directly in Excel (etc) and the chart shown to the right is an example trace obtained during an overnight wind speed logging session.