Saturday, January 31, 2015

Let's Finish Off the Barometer Project.

In the last entry <link> I posted the code for my barometer; I took a simple program of a few lines and turned it into a monster that does everything imaginable.  Now, I should actually set it up to work and put it in service.  Yes, my XBee shield came in and worked fine first try, so I mounted the little breakout board on it and added four wires to connect the barometer chip to the Arduino pins and tested it.


Made a nice little package when I got it all put together, so I dismantled the Stephenson Screen on my fence and tie wrapped it inside.


I had the old temperature sensor in there for years with no problems, so I don't think I need to get any fancier than that.

One thing I did in the code that I didn't mention in the last post was how to correct the reading to adjust for sea level comparisons.  See, to make barometer reading useful around the world, weather folk adjust them for the altitude so that there is a common base for comparison.  There's some really good explanations for why and how to do this out there, so if you don't already understand this, do a quick search.

From our perspective, this is incredibly easy; just call a different routine to read the data:

float pressure = bmp.readSealevelPressure(altitude)/100.0;

This statement will get the pressure adjusted for 'altitude' and the division by 100 will convert it from Pascals to millibars.  If you want inches of mercury, just look up the conversion factor.  The Adafruit library has already got the code for the conversion, all you have to do is look up your altitude in Google Maps, or read it off a GPS at the location where you put the barometer.

I've already adjusted my house monitor code to use this device and if you look at my house display, the outside temp and barometric pressure are taken from the new set up. I was lucky enough to catch a small storm so I could compare it with the other stations in my area, and it was right on.  It's really great when a sensor does exactly what the datasheet says it will.

I really like this sensor; the temperature measurement is very stable as is the barometer.  It's a snap to read and only takes two signal wires for all of it.  Since there's room on the device for more sensors, I may think about luminance or something in the future.

All this playing with the AcuRite weatherstation has been fun, and now I'm going to look at conquering the RF signal it sends.  What I'm going for now is far, far away from what I started off to do, but isn't that how it goes?  I want to grab the RF directly and use that data along with any other sensors I need to add and bring up a separate Raspberry Pi to handle weather presentation. Remember, the code is already in GitHub for you to grab <link>.

Funny how these projects tend to take on a life of their own.

8 comments:

  1. Have you thought of replacing that duplex receptacle with one of those that has the USB charger built in? Then you could dispense with the wall wart, still have and AC plug and if you used one of the types with two USB connections you could add a second Arduino or anything else.

    Just a thought.

    Glenn.

    ReplyDelete
    Replies
    1. Y'know, it really annoys me that I DIDN'T THINK OF THAT. Totally obvious and I completely overlooked it. Thanks Glenn.

      Delete
  2. Is there some reason that the barometer must be sensed remotely? With only a 4-wire interface, couldn't the sensor be connected directly to the pi with no significant loss of accuracy? I'm a tinkerer, not a meteorologist but it doesn't seem like there should be too much variation indoors vs outdoors, unless the building is airtight and pressurized. Obviously wind speed, direction, temperature and rainfall must all be sensed remotely, but is it really necessary to do that for barometric pressure? (I love arduino and have several, but I have looked at all the pins on the pi and thought it might be much less complicated just to put the BMP directly on the pi and read it there, rather than building a separate "frontend" for the BMP

    ReplyDelete
    Replies
    1. You're totally correct. There is was no reason for me to put the barometer outside since I live in a normal home and the inside pressure is the same as the outside. However, I wanted to get a temperature reading from my Stephenson screen out on the fence post and it just seemed cool to put the device out there since it gives me temperature and barometric pressure. I already had the housing and the wall plug from the previous incarnation, so why not?

      Doing something remotely with an XBee is second nature to me now, so there really wasn't any extra work.

      Delete
  3. This is great work.
    On the receiving end, how do you handle /parse the json data sent by the xbee, so it can be used

    ReplyDelete
    Replies
    1. I use a Raspberry Pi and save it to a database. From the database, I can do any number of tthings, but right now I just present it on a web page.

      Delete
  4. Do you think an arduinoMEGA in place of a raspberry pi would be feasible?

    ReplyDelete
    Replies
    1. Absolutely. It's just something to receive the packet from the barometer and do something with it. A little arduino could do it. The processor is plenty powerful for this kind of thing.

      Delete