Weather Station and the Raspberry Pi

USB to RS-485 Adapter
USB to RS-485 Adapter

One of the weaknesses with my weather stations was that they did not have the ability to accept incoming connections. This made remote debug a bit difficult, if not impossible. Basically, you program the thing, and hope there are no glitches. Surprisingly, this worked for many years with the occasional reset, but I finally decided to spend some time making some improvements to this aspect of the weather station system.

Originally, my weather stations consisted of an outdoor unit, which acted as a hub for all the outdoor sensors. The hub communicated with an RS-485 to Ethernet bridge (Arduino+Ethernet shield) inside the house near the router. This allowed long runs, and the ability to easily chain multiple hubs together on the RS-485 bus. I decided to keep the RS-485 bus model, and built a USB to RS-485 bridge to replace the Arduino and Ethernet shield that I used previously. The new USB adapter uses an FTDI chip and is compatible with most Mac, Linux, and Windows computers out-of-the-box. I was really happy to avoid the use of drivers. This adapter also features transient protection and other features that most cheap USB to RS-485 adapters do not have. This was important considering the long cable run out to the weather station. And, because the weather station hub runs at 3.3V and uses little power, the entire system can be powered from the USB port which provides 5V down the line.

I took this new USB adapter and hooked it up to a Raspberry Pi. Using a Python script I whipped up in a few minutes I was able to completely replace the functionality of the older Arduino-based system. While I haven’t added any new functionality yet, the Raspberry Pi allows for a lot more possibilities with its huge memory space, and the ability to SSH and VNC into it remotely. This solves the old problem of remote troubleshooting, which was basically impossible before. Local logs are also generated using the Python script to record errors and weather data in the event of an internet outage or other failure. I’m very happy with this improvement.

Lightning Sensor

Over the last year or so I’ve been working on a lightning sensor system for my weather station. I originally found a circuit published by Charles Wenzel that I thought looked interesting, and I decided to give it a try. The circuit worked quite well. So well, in fact, that it picked up lights turning on and off around the house. It also goes wild when the stove-top in the kitchen is used. I guess the stove has a noisy PWM circuit or something. I made a PCB for the circuit, and integrated it into my weather station and have let it run for a few months now.

Weather Station Data
10 Days of Weather Data

As the summer draws near a flaw in this design has presented itself. The flaw is severe temperature instability. Hotter temperatures increase the sensitivity of the system, and on hot days the thermal noise of the circuit causes a significant amounts of false triggers. This will be addressed in an upcoming design change in an attempt to reduce the number of false triggers.

The event on May 4th was an actual lightning storm and strikes were observed by persons in the area. Note the large drop in barometric pressure preceding the rise in lightning strike counts.

Ultrasonic Anemometer Part 2 – Signal Path

Since we’ve established the methodology behind how we will approach making these wind speed measurements, it’s time to begin the design. The design of this system was inspired by several other individuals who have also designed and built their own ultrasonic anemometers. Here you will find their own reports documenting their efforts:

The Signal Path

The first thing I chose to tackle was designing the overall flow of signals. Because the design has four transducers I needed either four transmitters and receivers, or, a way to select the appropriate signals and route them to one transmitter and receiver. In order to minimize cost and size I chose to build one receiver and transmitter and use a multiplexer to route the signals to the correct destination.

Ultrasonic Anemometer
Signal path for ultrasonic anemometer

The transmitter in this case is simple. I determined that the impedance of the transducers was approximately 680 Ohms at 40kHz. This allows me to drive them directly from a pin of the micro-controller at either 3.3 or 5 volts without cause for concern since most micro-controllers can source and sink around 20mA, or more. Additionally, the multiplexer will have some resistance, which should also protect the micro-controller. Because the transducers are tuned circuit driving them with a square wave directly from the micro-controller seems like it should be acceptable at this point. The transducer will filter out most of the harmonics in the square wave. I will re-evaluate this later in the design process.

Side note: In order to determine the impedance of the ultrasonic transducer I connected a variable resistor in series with the transducer. I then applied a voltage with a signal generator set to 40kHz. Next, I adjusted the variable resistor until the voltage amplitude was equal across the resistor and the transducer. At that point the impedance of the resistor and transducer were equal. Using a simple multi-meter I measured the DC resistance of the variable resistor which yielded a result of 680 Ohms. While this doesn’t provide the whole story regarding the impedance of the transducer, it does give enough information to move forward with the initial design. Plus, it’s very quick and easy to do with only basic equipment.

Designing the receiver in this system was the most difficult part of the hardware design process. I will start to cover that process in the next entry in this series.

Remote Weather Station Installation

IMG_0292
QI2C485 in enclosure

Over the Thanksgiving holiday I was on vacation with family in Spokane where I installed an improved remote weather station. This entire operation is mainly a learning experience, but at the same time offers significant insight into the trends and patterns in the weather. The objectives of this mission were to design and build a weather station that offered accurate and precise weather reporting, in an package that could be deployed without too much difficulty at multiple locations around the world.

The foundation of the system is the processor board I recently finished: the QI2C485. I’ve been working on this board for a few months and after about 5 different revisions, I’ve finally completed the development of this board. The system was installed in Spokane. Following a few rounds of firmware adjustments and tweaks it has been successfully collecting data for a few days now.

Modularity was always on my mind when making this device. The main processor board (QI2C485) provides a lot of flexibility in this sense. It is essentially a RS485-I2C bridge, that has 2 I2C ports and 2 RS-485 ports. The RS-485 ports allow the board to be mounted a significant distance from any artificial heat sources, or other things that might affect weather readings. The I2C ports allow multiple sensor boards to be connected. Currently, a BME280 is connected to one of the I2C ports and is programmed to make temperature, pressure, and humidity readings every 15 minutes.

IMG_0294
Stevenson Screen

In the future, a combination brightness sensor and thermopile will be installed in the second port to make sky observations used to determine cloud conditions. Also in the works are wind speed, and rainfall sensors. The modularity of the process board will allow for easy addition of these sensors in the future, requiring only firmware modifications. The second RS-485 port on this board is designed to either terminate the RS-485 line, or allow it to pass through to other QI2C485 boards.

The QI2C485 host also includes a lightning detection circuit that will count electromagnetic pulses in the vicinity. All of this information is uploaded via a php script to an SQL database where it is currently stored for access later. It can be displayed via a php page on my website that is currently under development.

The future will likely hold an additional revision, and added modularity, but for now the current design will undergo a full test for the remainder of the cold Eastern Washington winter.

Ultrasonic Anemometer Part 1 – Math Concepts

Index


With the first stage of the weather station project nearing completion I’ve decided to explore building some additional sensors to collect more readings. One of the things that I’ve been very interested in measuring is wind speed and direction. A device that measures wind speed is called an anemometer. Wind direction is usually measured with a wind vane.

There are a few problems with traditional designs of these instruments, especially with anemometers. One of the biggest problems is that they usually have a minimum wind speed threshold. If the wind is below this threshold the device will not be able to measure it. This is usually because the wind is not strong enough to spin a propeller of some kind. To overcome the problem of low speed wind measurements I’ve decided to go with a solid-state (no moving parts) alternative. This alternative involves measuring the difference in <a href="https://en have a peek at this web-site.wikipedia.org/wiki/Time_of_flight” target=”_blank”>time-of-flight (TOF) of a sound wave across a known distance.

The overall approach to measuring the wind speed using this method will be:

  1. Create a pulse of sound at point A
  2. Measure the time it takes to arrive at point B
  3. Create a pulse of sound at point B
  4. Measure the time it takes to arrive at point A
  5. Use the difference in the two times to determine wind speed

This method will determine the wind speed in along one axis. In order to get wind direction you must measure the wind speed along another axis, then use trigonometry to calculate overall speed and direction. To make these calculation easy we will measure the wind speed in the North-South direction and the East-West direction. In doing so the equation for overall speed is

Total Speed = SquareRoot(VNS2 + VEW2

where VNS is the wind speed in the North-South direction and VEW is the speed in the East-West direction. The formula is a direct application of the Pythagorean theorem. The equation for overall direction is

Angle = tan-1(VNS/VEW)

where tan-1 is the inverse tangent function. These equations are relatively simple because of the fact that we intend to make our wind speed measurements exactly 90 degrees apart. It would still be possible to calculate wind speed and angle if we had chosen another angel, but the math would not be as simple as this.

Now that the theory is out of the way, we will begin to actually implement this method in part 2 using some cool electronics and sensors.