Tech stuff for the Farm

I wanted to learn about the how our specific piece of land is impacted wind, rain, and sun.  So I decided that it was a good time to get back into some electronics, and for the first time since attending CVTC, some embedded electronics.  A lot has changed since I attended classes back in 1988 - 1992.  Mostly regarding the price one pays for more complex sub-systems and even components.  I still recall the basics, but am very much out of practice in applying them.  I still have many of the text books that we use when I was taking courses in electromechanical technology, which is handy for those times when I know that I know something, but can't remember it. Must be an age thing.  At any rate, I decided to build a small weather station to monitor the climate as it impacts the farm.

Mostly, I am interested in solar and wind energy.  Questions like:

  • How many days of full sun does the farm receive?
  • How much wind blows through our land?
  • What is the average speed of the wind?
  • What direction does it usually come from?
  • How much rain do we get in our little micro-locale?
If one is interested in these alternative energies like I am, these are reasonable questions to ask.  One can go on line of course and get data that is relevant to the area.  But in Grant Country, what happens on the neighbors place may very well be very different from what happens on ours.  The Driftless Area by our Farm is interesting in that the hills and valleys channel the wind.  Our proximity to the Mississippi also impacts when and what type of weather we experience.  So, to me, it makes sense to gather data relative to our little patch of God green earth.  Thus, the weather station.  

One can go buy a ready to go weather station for anything from $600.00 - $3000.00.  I, however, wanted to see if I could undercut that price a bit and at the same time re-educate myself in the basics of electronics as well as learn about the new cool stuff available these days.  Additionally, it has been a long time since I have had reason to work at the component level, and this little project provides the opportunity.  So the weather station has been my winter project.  I have done substantially better than $600.00, having spent around $300.00 on components and parts and tools.  Factoring out the tools, the whole things cost a bit more than $200.00.  I made a lot of mistakes along the way, being distracted with other things.  But overall, it has been a cool project.

The basic requirements were:
  • That it be built to last at least one full year
  • That it measure accurately enough to make the data usefull
  • That it be reliable enough to provide a full years worth of data without many gaps
  • That the data be available remotely
  • That it be placed where there is not a lot of interference from buildings (thus must be powered off grid)
  • That it be affordable
  • That it be scalable in that I can add more sensors if I deem it necessary without too much redesign
After some digging around, the basic design incorporated the following hardware:
  1. Switchdoc Labs WeatherRack
  2. Raspberry Pi 2b
  3. Arduino Pro Trinket 5V
  4. A full length proto board
  5. A small solar panel
  6. A good termperature sensor
  7. Two XBee S1 radio modules
  8. Two Xbee Adapter Kits
  9. Small Solar Panel
  10. A Solar LiPo charger
  11. A DC Step-Up/Step-Down converter
  12. A Luminosity Sensor
  13. And a few resistors, capacitors
Subsequently, it was a matter of connecting the sensors to the Pro Trinket and writing the programming to gather the data, getting the XBee radios working ( a royal pain), and writing a short script in Perl on the Raspberry Pi to receive and store the collected data. Sounds easy, and for the most part it is.  However, there are some caveats to 'easy'.

Two areas are still less then optimum from my point of view: Power and communications.  Matching a solar panel with a battery and ensuring that what is delivered to the controller and company is less than a straight forward proposition.  Getting XBee's to behave properly is also a bit of a challenge.  I am not satisfied with either of these sub-systems at this point, but they are working and I need to get this deployed shortly, so am going to settle with it as is for now.

The programming was not difficult.  There are libraries for most of the sensors which leaves one only to mess with timing and general formatting on the controller.  There is a Perl module called Device::Serial which handles receiving data on a serial port to which the XBee is connected, and the rest is just parsing and storing the data.  I keep the code on a gitub repository located at WeatherRack2. The Raspberry Pi runs an Apache Web Server which allows one to view the data.  Currently, it is very basic, just showing an interactive graph of the data points over time.  I chose to use a javascript library called CanvasJS which makes use of HTML5 components exclusively and looks like the following:

The whole thing put together, though not yet hardened for outdoors looks like this:

Next up: I want to load up the bee hives that will be going to the Farm with some sensors so that I can monitor hive health on an on-going basis.  More on that later.