Wednesday, August 14, 2013

Testing with an LCD

While I was testing the different sensors on the breadboard, I put together a circuit with the BMP085 and the SHT11 and added an 16 x 2 character LCD.  I wrote code to update the screen every 2 seconds and loop between displaying data from the SHT11 and the BMP085.  It only displays the raw data from the sensors; there is no datalogging capability.  Here's the short video of it running.


As you can see, the LCD screen is using a bunch of wires. It actually uses 6 GPIO pins (and a lot of power...my cheaper phone chargers wouldn't keep up), so I probably won't be able to include it in the final version the way it is.  Adafruit does make an I2C LCD shield that would be more applicable for my project (actually this started out as an I2C shield but I goofed up the wiring and ruined the GPIO expander).  

This was just something fun for me and was a good way to show people what I'm actually trying to do.  

Bourns Potentiometer

To determine wind direction, I had been thinking of using some kind of potentiometer for some time, but none of them that I had seen could do a continuous 360 degree rotation.  Then I found a post on Instructables from msuzuki777 where he made a weather station using an Arduino (check it out here). In the instructions, he mentions the continuous-turn potentiometer that he used for wind direction. From this I ended up buying two different potentiometers from Digikey, but only one of them was accurate enough for wind measurement (the other, cheaper one had a huge deadband).  

This turned out to be the Bourns 6639S-1-103. It ended up having very little deadband and was fairly consistent on its measurements. The only issue is that the Raspberry Pi is a digital-only device and has no way to directly measure an analog input.  This is very easy to do on an Arduino, but you must use an analog-to-digital converter (ADC) on a Raspberry Pi.

Bournes Continuous-Rotation Potentiometer from Digikey

For the converter, I used the MCP3008 from Adafruit which was only a few dollars.  It is an 8-bit converter, meaning that it separates the analog voltage into 1024 steps which is plenty for a wind vane.  The ADC connects to the Raspberry Pi via SPI which is slightly more difficult to use than I2C, but Adafruit had great code written for the converter already.

MCP3008 ADC from Adafruit

The only thing left to do here is to get the whole setup attached to a wind vane. I will have to ensure that the wind vane is large enough to provide enough torque to turn the potentiometer at relatively low wind speeds.

Hall Effect Sensor

For wind speed, I decided to build my own anemometer rather than just buy one off of the shelf.  I figured I could do a satisfactory job for significantly less money than most digital anemometers cost. Basically I need to determine how many times the rotor spins in a given period of time, and then I can correlate that to a wind speed (in mph, kph, knots, m/s, etc...). 

To accomplish this, I need a momentary switch of some kind to send an interrupt signal over a GPIO pin to the Pi, but I didn't want to introduce any extra drag into the system. In this situation, a reed switch or hall-effect switch would be perfect. Both of these sensors detect the presence of a magnetic field.  I found that Adafruit had a hall-effect sensor that they had tested, and I determined that it would be perfect for my setup.  
Hall-effect sensor from Adafruit. And yeah, that's a quarter next to it... This thing is tiny!

I also acquired a neodymium magnet and tested the sensor. Adafruit came through again. This sensor was great!  There were literally no issues with bounce which should make coding easier (read more about bounce). It only requires you to connect power, ground, 1 GPIO pin, and a pullup resistor. Now it is time to integrate this thing with a set of wind cups and get it calibrated.  

Sensirion SHT11

As it turns out, it is much more difficult to find an acceptable, low-cost humidity sensor.  I tried several sensors including the DHT11, DHT22, and AM2302 before deciding that none of them would work well. They weren't particularly accurate and they were extremely difficult to interface with. Eventually I broke down and decided to spend a little more on a better sensor.  The SHT line of sensors from Sensirion turned out to be fantastic. They are very accurate for both temperature and humidity (especially the higher-end ones), and with the help of a Python package that I found online (rpiSht1x - read more here), they are pretty easy to interface with via 2 GPIO pins.

SHT11 Breakout Board from Adafruit

I currently have the SHT11 which is the mid-level sensor that Sensirion offers.  I would like to upgrade to the SHT15 but it is more expensive and difficult to find as a breakout board.  If I can find it, I would like to buy the SHT75 which has leads attached to it from the factory.  Another option is to switch over to Sensirion's newer SHT2x series that communicates to the Pi via I2C (see Sensiron's lineup of humidity sensors at their website).  These other sensors would be great in the future, but the one I have will work just fine for now. 

Bosch BMP085

The BMP085 was actually the first sensor I bought.  It is quite accurate with resolution down to 0.03 hPa.  It is also very affordable.  The chip itself is available for about $5 but since I have no way to solder surface-mount devices (SMT), I had to buy breakout boards that were slightly more expensive. Lastly, the BMP085 is easy to work with as it transmits data via I2C which is supported by the Raspberry Pi.  

BMP085 Breakout Board from Adafruit

Another (cheaper) Breakout Board from SainSmart

The documentation for the board was fantastic, especially from Adafruit.  Their tutorials were fantastic, and they actually have a whole library of code to get their sensors working on the Raspberry Pi.  For this reason, you will see that Adafruit became a go-to source for parts and documentation.

Sensors!

Over the course of the summer, I decided on and purchased the sensors that I will use for the basic meteorological observations (temperature, humidity, pressure, wind speed, and wind direction).  

The ones I decided on are:
1.) Bosch BMP085 - Pressure and Temperature
2.) Sensiron SHT11 - Humidity and Temperature
2.) Melexis Technologies Hall Effect Sensor - Wind Speed
4.) Bourns Inc. Potentiometer - Wind Direction

Basically, I tried to incorporate sensors that fulfilled three requirements.  These were affordability, accuracy, and ease of use.  I will go through each of the sensors individually in the posts to follow!

Update!

Its been over three months since my last blog post, but I assure you that this project is still alive and well!

In the meantime I've been volunteering at the National Weather Service in Hastings, NE, working at Midwest Independent Soil Samplers, and doing other fun, summer stuff.  Needless to say, this has kept me pretty busy, and I have hardly had time to work on the station (let alone blog about it).

Fortunately though, I have had some spare time now that the summer is winding down to dig in to my project.  My next several posts will update you with the things that I have accomplished on the station.  

Saturday, May 11, 2013

Goals!

Alright, so now its time to dig in to what I want to do with this project!

Basically, my ultimate goal is to affordably replicate the basic functionality of the official automated airport weather stations.  Doing this will allow me to have observational data for my exact location at a higher temporal resolution (airport sites typically only report a few times per hour at most; I would like to have 1-minute observations).  Furthermore, by developing a low-cost system, the station could be more easily adopted to provide better spatial resolution for surface observations, to create a mesonet, or even to build portable observation pods.

Here is some information on airport weather stations.  Most of the sites are designated as AWOS or ASOS.  These sites are run by the National Weather Service, the Federal Aviation Administration, and the Department of Defense.
ASOS Site

Here is a breakdown of the different parameters that I would like my station to measure (in order of importance):
  1. Temperature
  2. Barometric Pressure
  3. Humidity
  4. Wind Speed
  5. Wind Direction
  6. Precipitation
  7. Lightning
  8. Soil Temperature
  9. Soil Moisture
  10. Solar Radiation
  11. Photography (webcam or still-shots)
There are a few other considerations that I will try to work into my station:
  1. Battery power
  2. Solar power
  3. Real-time clock
  4. Portability
  5. Long-term data logging
  6. Data relay via internet
  7. Data relay via cellular connection
  8. Data relay via radio (APRS)

Who am I?

Okay, I'll keep this post short because you guys probably aren't too concerned with getting to know me, but I think having a little bit of background on what I know and where I'm from would be good.

I am studying meteorology at the University of Nebraska-Lincoln and I am in my senior year.  I have some programming experience, but I haven't done any extensive embedded systems programming. Therefore, I will be relying heavily on information and code from others and modifying it to serve my purpose.

Since I promised to keep this short, I won't add any more personal information.  If you want to know more, follow me on Twitter @aaronmangels, comment below, or send me a message.

Me with our new dog Cooper.

What is the Raspberry Pi and why did I use it?

I've never heard of Raspberry Pi...What is it?
For those of you who are unfamiliar with the Raspberry Pi, it is a credit card sized, Linux computer that was designed by the Raspberry Pi Foundation in the UK.  This nonprofit foundation designed it in an effort to get schoolchildren interested in computers and programming.  They initially released a batch of 10,000 "Model B"boards for $35 apiece, and they quickly (within an hour) sold out.  Since then, they have been able to maintain a steady supply of boards and have released a "Revision 2" and a cheaper "Model A" version for $25 (their original pricing goal).

Okay, Cool! So what can it do?
At the heart of the Raspberry Pi is a 700 mHz ARM11 processor.  The foundation describes it to be roughly equivalent to an old 300 mHz Pentium II processor, but with much better graphics.  Because of the Broadcom GPU that is included on the board, the Pi can decode 1080p video and is about graphically equivalent to the original Xbox.  Also, the Model B board includes 512 mb of RAM along with 2 USB ports, an ethernet port, HDMI and composite video ports, and a header of GPIO (General-Purpose Input/Output) pins.  (The Model A has 256 mb of RAM, 1 USB port, and no ethernet.)  

Why did you decide to use it?
Getting a full-featured computer at such a low price and small form factor just seemed too good to pass up, so I quickly snatched up on of the Model B Revision 1 boards.  I thought initially I could make a set-top box for media streaming/viewing, but the lack of Netflix support killed that idea.  I didn't do much with it for a few months, but then I realized that it would lend itself well to a homebuilt weather station.
The ARM11 processor is more than fast enough, and it consumes very little power (~2W) so I could possibly run it off of battery/solar power.  The GPIO pins allow me to interface directly with almost any sensor you can think of.  Essentially, the Pi is giving you most of the same interfaces as an Arduino for the same price, but the Pi is an complete computer while the Arduino isn't.  With such huge interest in the Pi, there is already a large and expanding user base to test and write code for the different sensors I will be using.  Most importantly, its cheap! So when I screw up, I don't have to break the bank to replace the system.

Raspberry Pi (Model A)
Here's a picture of my Model A that I just got.  (My Model B is busy at the moment)

If you want to learn more about the Raspberry Pi, visit the foundation's website at raspberrypi.org.  

First Post!

Hello, my name is Aaron Mangels and welcome to my (first ever) blog.  
If the title of my isn't obvious enough, I will be building a weather station based around the Raspberry Pi.  I already have been tinkering with it for several months, but now I'm finally able to devote enough time to the project to actually go somewhere with it (and blog the process). 
Thanks for reading, and hopefully you will find it useful and interesting!