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.