Weather/Security system using SNMP.


Thread Starter


I’m building a weather station and home security system based on open systems, open architecture, and network based standards. (Yes, I know I can get off the shelf weather stations and security units for one third the price and none of the effort, but they are closed systems).

For the purpose of this project, It’s important to be able to take readings every 30 seconds, and place data into a MySQL database. All readings and interrogation will be a standard network management server interrogating an Ethernet I/O server using SNMP. Once the data is in the database, it is simple for me to post this to a web page and post real time results. Currently, I have the Ethernet I/O controller happily posting to the Network Management Server simple things like Contact open/Close, counting closures etc. and the Management Server is happily sending out Emails/text messages when programmable thresholds have been reached. In addition, all the appropriate red light/green light eye candy stuff is occurring on the management server reflecting the status of the Ethernet I/O controller in near real time.

There are two pieces missing from my project;
1: Anemometer
2: Wind Direction.

I am an IT guy, not a controls guy, so I understand everything right up to the point where I actually attach a sensor to the I/O server. The Ethernet I/O server has analog input options for:

I’ve figured out how to report back to the NMS using a 9 volt battery and a potentiometer, with the analog I/O setting on 0-10v. From that process I figured out that a J type thermocouple with a transmitter for 4-20ma conversion is the way to go to record temperature. Unbelievable amount of time researching and figuring out I need a transmitter for the thermocouple, but that’s another story.

I’m not stumped on the anemometer or wind direction, but I’m seeing myself building 9VDC generators and getting bearings from a child’s motorized toy car. It will require much trial and error and weather proofing. I would like to short circuit this process with something more robust than scraps I’ve picked from a toy store. My question is;

Is there a short cut solution to the anemometer and wind vane problem knowing the analog input specifications I have to deal with? I’m thinking that process control guys deal with this simple problem every day, but for me, it’s a real pain to think about.

Thanks in advance for any advice/assistance you may have.

curt wuollet

For the anemometer, I would use a sensor that triggers once per revolution and a 555 timer set up as a one shot with the time set so that the output would be always on at the highest likely wind speed. In other words the one shot time would be 1/pps at the highest wind speed. Then a large resistor and say, a 1uF capacitor would integrate the pulses into a dc voltage that represents the average speed. This should be as accurate and linear as it needs to be and the 555 will run on convenient voltages. This is a standard PWM setup. Check on any of the many 555 application sites for ckts. For the wind direction, a pot or slidewire setup is really the way to go without special equipment. Removing the stop from a high quality pot should get you a fairly good readout and you can face the small dead spot towards the least common wind direction. If just ordinal points are adequate, one way would be sensors and resistors that form a crude D/A which you can handle with your DC inputs.


cww An itinerant automation and controls guy.

The system architect is me. If I had to retrofit into legacy applications I may think about OPC. However, I’m reasonably encyclopedic on server/web/database/SNMP technologies, and IP networks are so ubiquitous, that dealing with another layer of abstraction is painful. If the manufacturers of Ethernet I/O systems came up with a product line of common plug n play sensors for the analog inputs, the average IT guy like myself would not be too uncomfortable building control logic with a network management system, and proceed to control objects with that information. There are many free open source Network Management Systems that faithfully log all data, save it in a SQL/ODBC database, allow web access, and allow user defined logic to control (Stop/Start/Attentuate) SNMP compatible ethernet I/O controllers.

The only painful part for me is getting the information into the SNMP compatible Ethernet I/O controller. My knowledge of sensors and hardware compared to that of the others on this forum is infantile at best. I'm still getting over the fact that i need a transmitter to get my thermocouple device to talk 4-20ma so i can calibrate my ethernet I/O controller so I can log the temperature. I would have thought that stuff would be plug and play...I live and learn.


Thanks much. Hardware/silicon is not my area of expertise. I did google the 555 timer chip (never heard of it before) and am amazed by the number of projects that exist for it. Based on what I’ve seen, I think I can breadboard something together, and solder a magnet to the anemometer axle to produce the pulse. Calibration of the object will be to drive down the street on a windless day at known speeds and note the output. I suspect sizing the resistor and capacitor to output between 0-10vdc for me at least will be trial and error.

As for the wind direction, I could build a crude A-D unit but that would consume 8 DI’s. I think I’d be better trying my luck with a good potentiometer. Knowing that my choices of input are 0-20ma, 4-20ma, 0-150mv, 0-500mv, 0-5v, 0-10v, is there any specific type and value of rotary POT that you can recommend? I can Macgyver it from there.

Different sensors have different physical characteristics, so you need signal conditioning if you want to go into a common type of analogue input. There are analogue inputs which take thermocouples directly, but then those can't be physically compatible with your 4-20ma or 0-10V devices. That's just the laws of physics.

What I/O hardware are you using that uses SNMP? That is somewhat unusual. There is a lot of hardware which uses Modbus/TCP, which is the closest thing we have to a common open standard in industry. A lot of hardware in industry however uses proprietary protocols, which has created a big market for software and hardware to convert between them.

I realize that you already have your hardware, but for future reference you might want to look at an open source project that I have at: "". That includes Mobus/TCP drivers written in Python, and various servers and clients which use web and AJAX techniques.

As far as voltage versus current inputs is concerned, voltage inputs are for when the distance between the sensors and the analogue inputs is fairly short. If you have to go a considerable distance (e.g. tens of meters), then voltage drop and electrical interference can become a problem. That is what 4-20ma are meant to deal with. Generally, voltage inputs are easier to deal with, while current loops are more complex designs but inherently compensate for voltage drop and are less susceptible to noise.

If you are going to hack together your own sensors though, I think you are going to want to try to stick with voltage readings if at all possible.

As for using switches for wind direction, I believe that Curt mentioned D/A not A/D. Look up "binary weighted DAC" to see how this works. This gives you an analogue signal. You would need a magnet (or magnets) on the rotating element of the wind vane, and a series of hall effect (or reed) switches on the stationary part.

6 to 8 bits of resolution is the maximum you can get out of this sort of thing. If you had for example 6 sensors then you could turn on 1 or 2 sensors at a time (2 would be on when half way between sensors) and be able to resolve a dozen positions. So, that would be 30 angular degrees of resolution.

The advantage of this over a pot is that there is no friction, so it wouldn't wear out and it would work better with a small vane in light winds.

curt wuollet

Intuitively, I'd say find a quality conductive plastic element linear taper pot and remove the stop. But, you mistook my intent on the D/A idea. It would not take 8 inputs if you had say 8 switches and each switch had a different value resistor that it switched to a summing junction or simply another resistor to ground. By selecting your resistors, you could have each ordinal present a different voltage to a single analog input. Lets say you had 12 volts. With a 1k summing resistor, a 200 ohm resistor would give you 10 V for N, A 333 ohm resistor would give you 9 V for NE, a 500 ohm 8 V for E, etc, etc. If you can overlap the switches, you could even interpret the values with two adjacent switches on. Or you could do a R/2R network with binary switching, but that might be overkill. :^)

cww An itinerant automation and controls guy.

curt wuollet

Oh, And by the way, DigiKey and the usual suspects sell small cheap rotary encoders that are used with the resistor idea in place of pots these days. I don't know if they make an 8 bit/rev model, but it's something to think about.

Now you all have me thinking. 4 years ago I was asked to present temperature read outs and airflow status from roof top handling units, and present the data on the LCD of Cisco 7900 series telephones. I was told at the time that the info was controlled through BACNET/Alerton and info was presented real time on a web page. Initially I thought I could screen scrape HTML code off the web server, but when I tried to put this into practice, the Alerton HMI software was just a JAVA blob, rendering it unscrapable. If I had to do that over again, I believe the MBlogic project at sourceforge would have been a great place to start. Unfortunately, other projects took over, and that phone project fell by the wayside. That looks like a great project and should keep many independent consultants employed.

Having paid attention to the wise people of this forum, I have ordered a selection of silicon, and also a windvane with the mechanical parts of an anemometer built in, which includes a reed switch. Now I don't have to worry about the mechanical problems of bearings, weather proofing, robust qualities etc.

<b>For the anemometer,</b> I think the key suggestion was the 555 timer chip (I know nothing about silicon). However, the bread boarding looks simple enough and i should be able to trouble shoot it with a multi-meter. For calibration, I ordered a $35.00 hand held anemometer (Probably not very accurate). The hand held unit, a hair dryer and a multi-meter should server for calibration.
<b>For the Temp Sensor,</b> I have already ordered a thermocouple with a transmitter. However, thanks to Curt Wuollet who got me looking at silicon, I came across the LM135 Temp Sensor with 1Deg Kelvin per 10mv output. Should the output not be where i want to see it, I can amplify using a 741 op amp (I'm learning). So for approximately $10, I can replicate my $140 thermocouple/transmitter combo. I'll know how well it works by the end of the month.
<b>For the windvane direction,</b> I've come to realize mechanical sensing devices (POTs) are self defeating, and again thanks to Curt, 8 reed witches, with scaled resistor values will serve to get this phase of the project off the dime.

There was a question on the hardware/software used...

1: Ethernet I/O unit is a Moxa IOlogik 2242, 4AI and 12 DIO.
2: Software is Nagios open source network management system I run it in a VMware virtual machine inside Win2k3.

3: Webserver is a win2k3 server (I'm a windows guy).
Nagios takes an SNMP read every 60 seconds (The timing resolution is a variable) and posts to a database. The webserver reads the database and presents the information as a web page. My web script is ASP.
Have a look at these guys: "" They have all sorts of educational kits, including temperature sensors. You can connect the temperature sensor to one of their controller boards, which gives you a serial output. Their controller board program in basic, and they have analogue inputs.

I know that you already have the hardware, but "do-it-yourself weather station" sounds like a project for a Parallax Basic Stamp board. That can count a few switch closures and read a few analogue signals, and send the results out a serial port. That's got to be a lot cheaper than your Moxa IOlogik so it won't matter so much if it gets hit by lightning or killed by static electric charge build up. You might need a serial to Ethernet box (depending on how far the signal was going), but at least the field device could be sacrificed to bad weather (which is something you have to keep in mind).

Also, if you put "anemometer kit" into Google, you will come up with a number of hobbyist kits, as well as wind vane kits. Wind energy web sites also have information. I notice that at least some of the wind vane kits use potentiometers so that idea does seem to have more merit than I would have thought. Some use a single potentiometer and just have a dead spot of about 5 degrees, while others use dual pots.

I'm not sure what you paid for the Moxa unit, but equivalents from Advantech (6000 series) are in the $200 to $300 range. They don't have the SNMP features, but they do have Modbus/TCP (as I notice the Moxa unit does as well), and they also have a UDP based ASCII protocol which is very simple to use. They have a high speed counter module which could count the anemometer switch closures directly. They have analogue modules which would let you read the analogue inputs. And they have serial to Ethernet converters (serial device servers) which would let you use something like the "Basic Stamp" mentioned above and connect it to Ethernet (if that is more convenient).
There actually are a few people using SNMP for remote I/O monitoring although it isn't terribly common. The telecom industry is mostly where you will find it. Our company makes a remote I/O and data logger device that optionally communicates via SNMP as well as Modbus, and I know we aren't the only ones.

I agree that Modbus is definitely more standard and usually easier to use, unless like this guy you are already well versed in NMS, in which case SNMP is pretty nice since the vendor provides the register map (MIB) already pre-written for you and all you have to do is import the vendor supplied MIB file into your NMS to start getting usable data from the device. Imagine if vendors started supplying Modbus register maps that could be directly imported into Wonderware or other HMIs - the HMI users would love it.