1733 Anemometer

Computer Interface

(and code)

Acquires wind speed data from the 1733 anemometer interface (read first).

Max Carter

A computer can be used to gather, store and display data from the 1733

Working example:

Click the refresh button for a snapshot of current wind speed as read by the interface.

The Interface Circuit

The serial interface in Figure 5 is one way to get wind speed data into your computer. It's based on the easy-to-use PICAXE microcontroller. Two of the chip's analog-to-digital converters read the voltage on either side of the shunt resistor and report the readings to the computer via the computer's serial port (or USB port with adapter).

Figure 5

*Or serial/USB adapter if no serial port is available. (Also called a FTDI adapter.)


Interface (in black box) mated with (blue) FTDI adapter

The red/black wire is 5 volt power from the computer. The black/white wire is the current loop. The silver FTDI cable plugs into a USB port on the computer. The adapter shows up in Device Manager as a COM port (typically COM5).

Program for Figure 4 PICAXE Microcontroller Interface

These chips are easily programmed. The program (in PICAXE Basic) is shown in blue below. Copy and paste the code to the PICAXE Programming Editor and program the chip:


	SerIn 3, N2400, ("c="), b0	'gets first character after qualifier ("c=") 
						'from computer
	if b0 = "s" then  
	gosub get_speed	'calls up "get_speed" subroutine below
	goto main

	ReadADC10 1, W2		'gets voltage on I/O 1 (pin 6)
					'this is one side of the shunt resistor.
	ReadADC10 2, W3		'gets voltage on I/O 2 (pin 5)
					'this is the other side of the shunt resistor
	SerOut 0, N2400, (#W2, 32, #W3, 13)	'sends data to computer
							'(data, space, data, CR)
Programming the 08M2
The 08M2 must be plugged into a programming board to load the program. You don't really need to buy such a board since building one for the 08M2 is easy enough, requiring only a 8-pin DIP socket (or solderless breadboard), a 9-pin female D-connector and a couple of resistors.

RS-232 DE9 connector08M picaxe programming circuit

Get the free programming software and learn all about PICAXE microcontrollers at www.picaxe.com.

Retrieving and Processing the Data

Any number of programs written in any number of languages could be used to retrieve and process the data from the interface, so long as the program can access the computer's COM ports. The data is retrieved by sending "c=s" to the interface. The protocol is 2400/8/1/N. The interface will respond with two decimal numbers between 0 and 1023 that represent the two voltages at the inputs (one from either side of the shunt resistor). The numbers are separated by a space and end with a carriage return, like so: <voltage one><space><voltage two><carriage return>. The processing algorithm should first subtract the two numbers, then multiply the result by the scale factor .488 to convert to tens of millivolts (ie, MPH or m/s). [Note: The scale factor is derived by multiplying the power supply voltage, usually 5 volts, by 100/1024. See line 166 in the code below for more on this.] The data can then be used in whatever manor - saved to a file for plotting on a graph, passed directly to a web server, peak/average, etc.

For example, "get_windspeed.pl"

The as-built anemometer interface is connected to the server that hosts this web site. Below is the Perl code the server invokes to retrieve the data from the interface when the refresh button in the red box above is clicked. [The server then sends the data to your browser for display.] The code can be used standing alone [web server not required] or as the basis for just about any wind speed data processing algorithm you can think of. Be sure to read all the comments.

Here's the Code

Requires late-model ActivePerl installation


Download and install the Community Edition (free), here

Then get module:

  • Win32-SerialPort
Installing Perl Modules
  • Open command window [run CMD from start menu]
  • navigate to the perl\bin directory [type cd\perl\bin <enter>]
  • type ppm <enter> [allow Package Manager to load]
  • click left button (View all packages)
  • select (highlight) packages to be installed (Win32-SerialPort)
  • click 'mark for install' button
  • click 'run marked actions' button

Copy and paste the code (in blue) to your favorite text editor. Name and save the file with .pl extension (get_windspeed.pl) to a location on the computer (ex., c:\anemometer).


#the very first line (must be line 1) is required if the code is used with a web server (Apache, etc.),
#tells the server where Perl is, the line must start with "#!", must use forward slashes, see also line 20*

#open serial port

use Win32::SerialPort;

$Sport = new Win32::SerialPort('COM5');  #this creates an "object", "class" or something, named $Sport; 
						#in this case, addresses port COM5; change to port whatever

$Sport->baudrate(2400);		#configures serial port

#print "Content-type: text/html\n\n";   #tells browser HTML to follow; *UNCOMMENT THIS LINE IF USED WITH A WEB SERVER

$stoptime = time + 2; #gets computer time (seconds), adds 2 sec
			#this is the length of time the program is allowed to run

sub get_speed($)  {		#subroutine "get_speed"

	$Sport->write("c=s");	#writes $cmd to serial port (sends command to picaxe)

	$_='';			#clears $_  (sets to 'nothing')

	do {

sub no_resp  {			#No response subroutine



	if (time >= $stoptime)  {		#if current time greater than stoptime,

	no_resp;				#calls no_resp subroutine above


	$_ .= $Sport->read(1);	#reads serial port chr   (".=" is concatenate operator,
		 					#concatenates new chr with previous chrs in the string)

	while (!/\r/);    	#until carriage return (\r) received

	return $_;		#ends do-while loop, returns $_ value


$_= get_speed ("");		#calls the get_speed subroutine above

$_ =~ (s/\r//);			#gets rid of the CR

@accum = split(' ',$_);		#converts $_ (default variable) to an array

$speed = ($accum[1] - $accum[0]);	#calculates the difference

$speed = ($speed * .506);	#This is the voltage scale factor; converts 0-1023 to tens of millivolts.
						#The scale factor is determined by multiplying the power supply
						#voltage (as measured with a digital multimeter) on the PICAXE chip by
						#100/1024.  The power supply voltage in this case measured 5.18 volts. 
						#Thus, 5.18 x 100/1024 = .506. If you don't have a digital multimeter,
						#use 5.0 in the calculation; the scale factor in that case is .488
$speed = int($speed + .5);		#returns integer (rounded to nearest whole number)

print "$speed MPH";

Checking the Code

The code can be checked from the Command Line:

  • Open the command line window (run CMD from the start menu)
  • Navigate to the location where you saved the program (c:\anemometer, for example).
  • At the prompt, type perl get_windspeed.pl <enter>.

It should look something like this:

Note: If wind speed comes out as a negative number, reverse the current loop leads at the input to the computer interface.

Schematics produced with DCCAD.

Related Page

1733 Anemometer Interface

Data Logger

USB-Based 8-Channel Data Acquisition Module

Other PICAXE Stuff

Communicate with the PICAXE

PC Communicates with the PICAXE and the INTERNET

PICAXE Outside Temperature/INTERNET Project

Dead-Man Alert System