Several years ago I designed and built a weather station. At the time is was the best I could build based on the availability of the affordable sensors. Last year I upgraded my data acquisition module to a Arduino 2560 R3 microprocessor and Ethernet adapter. I had no real projects in mind when I purchased it. It was a way of learning a new skill in C programming.

After playing around on eBay I noticed that there were a lot of affordable sensors that could be incorporated with the Arduino to make a new weather station. In this article I will describe how and why I made certain decisions along the way.

The design specifications were very straightforward. Initially I wanted a wireless station that did not rely on a PC for any of the data acquisition or web page delivery. The Arduino can be programmed as a web server and I started using the feature to generate a web page for external viewing. This did create several issues:

* The web page could only be viewed by one user.
* There would be no data storage capabilities.

I rethought the design and decided to eliminate the web server feature and only use the weather station to read the data and transfer it using UDP to a notebook. The notebook would run a Visual Basic 6 application which would retrieve the UDP streams, save them to a database, and generate the graphics and data streams.

Programming of the Arduino is in C not one of my strong suits so there was a learning curve to overcome. Through the years I have programmed in most of the legacy programs along with Cold Fusion, some PHP, JavaScript and JQuery. I did learn enough C to be dangerous and am still learning. The nice thing about using the Ardunio as web server is that I could incorporate most of my programming languages in developing my application.

Since the HTML code is wrapped in a client.println wrapper you can incorporate most current technologies in your application.

My first concept was to package the entire weather station in one case and mounting it on to top of a pole. The problem with this approach was maintenance. Programs are uploaded to the Arduino through a USB port. Ruining a USB cable to make changes to the application would go against my "wireless" design. I did find a method to upload the program to the Ardunio over the network connection, but it seemed way to complicated and unreliable. I decided to break the weather station into two sections. Mount the necessary sensors on top of a pole: radar, winds peed and the rain detector. Keep the main unit separate case in a protected area, like my carport. The external sensors are connected to the main case via a 25ft cable and uses a 25 pin D Sub connector to connnect it to the main case.

The computer system hardware consists of a T400 notebook running Vista Ultimate, and Cold Fusion 4.5 Enterprise Server, Access 2000 Database and Visual Basic 6. Most of the software is fairly old but I already owned licenses for all the software so it was an easy decision to make to use them in the overall system.

All of the sensors were purchased from eBay. I was very happy with the suppliers for their fulfillment of the orders, most arriving in 3 to 4 days. I always purchased two of each sensor in case that I wired it wrong and got the blue smoke effect as well as one for maintenance. They are relatively cheap and since it would take days to get another one so having an extra one on hand seemed to make sense.

Virtuabotix DHT22 Temperature & Humidity Sensor - www.virtuabotix.com
There two versions of the Humidity / Temperature sensors: DT11 and DT22. Do not make the mistake and purchase the DT11. It's not as accurate as the DT22 and when the temperature drops below 30 Degrees F it goes bonkers. The price difference is only a few dollars more. The DT22 is very accurate and not as susceptible to temperature.

HB100 Microwave Sensor Module 10.525GHz Doppler Radar Motion Detector Amplifier Circuit- Data Sheet
The HB100 Microwave Sensor Module 10.525GHz Doppler Radar Motion Detector required an amplifier to take the millamp signal to a usable 0 to 5v analog signal. All the parts are available at Radio Shack and is fairly easy to build. When connected to the amp the sensor delivers a base 2.5 volt signal. When an object approaches the sensor the voltage increases from 2.5 to 5 volts in reference to the speed of the object approaching and decreases from 2.5 to 0 volts as the object moves away. I am not sure if it will pick up anything mounted on the top the pole, but I wanted to add it anyway.

Hall Effect Magnetic Sensor Module - There are numerous suppliers of several different types. If eBay doesn't have any listed just Google 'Hall Effect Magnetic Sensor Module' to find other suppliers. Some Hall Effect Sensors require very strong magnets to trigger the IC. I picked up two Rare Earth Magnets at Radio Shack Part No - 64-1895.

I built several prototypes starting off with bread boarding each sensor separately so I could make sure I received the sensor results that were expected. Most of the sensors I used have Arduino libraries obtainable from Arduino or by searching Google.

A word of caution. About half of the code examples out there including on the Ardunio site may not work as described. I ran into many compiling errors and had to either change the code or find other code examples. Since there are many different versions of the Ardunio boards and the code is open source examples do not necessarily work on all microprocessors and the authors do not always tell you that the are specific to any one board type.

Many sites providing examples only post parts of code making it difficult to use particularly if certain libraries are required. For example I wanted to see if I could use a frequency library for my wind speed assembly. It just plain didn't work. The library had multiple errors on compile. After an hour or two I abandoned that thought and wrote my own code. An other example of code that just didn't work was the Ardunio use of interrupts. Maybe I was just not implementing them correctly based on my limited C code experience, but after reviewing about a dozen sites I could not get it to work. In the end I found that the code I wrote worked pretty well.

The main assembly the consists of the Arduino Mega 2560 R3 board with the Ethernet Shield, a terminal block to connect the exterior sensors and supply multiple terminals for power and ground connections. The Mega board provides one 5V connection so I had to build a terminal block to provide power and ground to all the sensors. I did purchase a set of jumper wires with female pin connectors and male pin posts to connect the sensors. Since most of the sensors have pin headers on the boards it makes keeps soldering down to a minimum. The wiring may look chaotic however using the pin connectors and jumper wires makes it easy to change the sensor pins without any soldering.

The upper case houses TP-Link TL-WA701ND Access Point (removed from the case) . Wires from the terminal block were soldered to a DB25 connector mounted to the upper case. This connector supplies 5v and ground to the exterior sensors and the return sensor signal wires.

I had an air quality sensor installed but the processing time took too long. So I removed it. Instead I am using the second Arduino to monitor a light monitor with a threshold output to detect lightning, a sound monitor to detect thunder and a vibration sensor to detect earthquakes. Granted there aren't a lot of earthquakes in North Carolina but it there is one I am hoping to record it. I am also using it to bring in the data for the four microwave Doppler readings and send them to the vb6 app via a UDP packet.

Three holes were cut into the side of the upper case to accommodate the Humidity / Temperature, Barometric Pressure sensor. light sensor and the sound sensors. Initially I had them in the inside of the case but it caused inaccuracy in the readings. By moving them to the outside of the case resulted in better accuracy. I used 1" PVC elbows to protect the sensors from any outside exposure.

The exterior assembly consists of the Rain Detector, the Microwave Doppler Sensors, Microwave Doppler Amplifier and the Wind Speed assembly. The amp board also provides the terminal strips for powering the other sensors.

The mast sensors includes an expanded microwave Doppler sensor array. I started out with a unidirectional northern exposure sensor. I expanded it to include 4 sensors: North, East, South and West. I have one amplifier board and instead of building 3 more I decided to try and a different approach. Using 4 Opto22 solid state relays I connected them to each sensor. The outputs were combined to the single amp board. The second Arduino 2560 with 4 control lines. The code cycles between each relay, collects the signal, sets it to a unique variable (north, east, south and west). The variables are combined into a string and sent via UDP the VB6 application.

After looking at available Wind Speed sensors most were priced outside what I wanted spend on this project. I had designed and built one for my previous weather station but it had it's limitations. Several years ago I tore apart two VCRs and found that the tape heads had a really super bearing assembly. It rotates with very little friction, spins forever and takes very little force to get it spinning.

A Hall Effects sensor senses magnetic fields when it comes in close contact with a magnet. It was perfect for a no contact way of measuring rotation. The one I purchased can provide either an analog (0 to 5v) signal or digital signal (On/Off). Reading it as an analog signal was too erratic so I set up the Arduino to read it as a digital signal. The sensor was mounted in the lower part of the 1 1/2" PVC pipe caps. When the top part of the bearing rotates it spins the magnets past the sensor triggering an on/off signal. The sensor requires a very strong magnet to activate. I found that 3/16" Rare Earth Magnets (64-1895) from Radio Shack worked best.

I was considering using the typical wind speed generators cup system to catch the wind when I came across a model airplane propeller in one of my 'junk' bins. I mounted it to the plastic top of a spray paint can. The spray paint can top fit perfectly onto the bearing covering the upper and lower bearing joint without interfering with the roration. This was important to keep the weather from getting in between the joint. After I mounted it outside on the pole the propeller seemed to work at least up to 10 mph winds without calibration. I will have to monitor it to see if I require more calibration.

As mentioned previously the coding was problematic since the reading of the wind speed could impact the real time data display of the other sensors. I tried frequency code as well as interrupts and it just didn't fit. I have always found that the simpler the code the better. After playing with the code I found that a simple counter script sampling a two second span with a 1 millisecond delay is fairly accurate and does not interfere with the real time display.

The Ardunio is programmed to retrieve the sensor data, perform any conversions, create the html code and display the data to the internal web site. The Arduino is set up as a web server with an internal IP. It can deliver the web page directly to the internet.

A little bit of history on how the final design and build was accomplished.

Multiple user support

Issue: The Arduino documentation states that it can support 4 simulations connections but I never seemed to work. All I could obtain was one connection at a time. Since I wanted to visit the site from my cell phone and allow access to others to visit as well. I came across a modified Ethernet library that supposedly fixed the issue but it wasn't reliable enough.

Solution: Use the VB6 app to obtain the data and generate an HTML page for outside users. FTPO would be used to migrate the page to an external web site.

Data and Graph Storage

Issue: Where do I store the data and save the weather data graph?

Solution: There is an Arduino mySQL library to write data to an internal or external database. I spent hours trying to get it to work but consistently ran into connection issues. Unfortunately the multiple attempts to connect to my outside database locked the database for a minimum of 4 hours. I decided that if multiple attempts to use my external database would lock it out it wasn't a reliable way to store data.

The Ethernet shield comes with a mini SD car slot, but on the Mega 2560 board it requires some pin bypassing to get it to work with the Ethernet port. So Both options were ruled out.

VB6 was used for storing the data and graph generation.
Data Transfer

Issue: Typically the data could be sent to the PC via the USB or and auxiliary Serial Port via a cable. Initially I tried using the built in USB port on the Arduino connected to my PC. This was going against my initial design requirements of being totally wireless but was a tradeoff I was willing to make at least for a temporary fix. The Arduino would send a comma separated data string to the PC via the USB port. Unfortunately the Arduino Mega 2560 has a problem of the USB port hanging from time to time. I purchased a separate USB adapter and ran it off one of the Mega 2560 three serial ports. This improved the performance but hung after a few hours of running it hung.

Solution: The Arduino sends a UDP packet containing the sensor data over the wireless Internet connection to my wireless router. The VB6 app reads the assigned port and translates the data packet into useable data.

The VB app first writes the data to an Access Data base. It then reads the data back for the past 24 hours for the current date. The graph is generated for a 24 hour period. When the graph is completed it is saved to a file on the local system. The application then generates html code and written to a VB6 list. The list is then written to a file on the local system.

Now the issue was how to get those two files to the outside server. I played with several FTP classes for VB6 but ran into issues where one of them actually deleted all of the files on my server taking a few hours and a phone call to my hosting company.

I have been programming in ColdFusion for over 10 years so I decided to use two features that CF offers: FTP and Scheduler application. I wrote a program that takes the two files and transfers then to my outside server. I then set up transfer schedule to run the application every fifteen minutes.

The result is a web page that does not have the restrictions of one user.

External Web Page

VB6 Application

Data Analysis Web Page

Using a program called Active Webcam the latest images captured from the webcams are transferred to an external server via FTP. I initially planned to transfer the wireless IP cam directly from the web server code but my internet provider blocks most ports.

I have three webcams runing. Two Wireless Night Vision cameras and one regular webcam.

Website, paintings and images displayed on this website are the property of John R. Havrilla, Chapel Hill, NC and are protected under United States Copyright Law. Any use without the express authorization of John R Havrilla is expressly forbidden. Violators will be prosecuted to the full extend of the law.