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.

12 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
  5. Do you have any documentation for the software you've done for the Acu-rite 5n1 hardware - sdr_433 and the modules to capture to SQL? I'm using Linux here (I don't know what you run) and do want a better way to track things like rainfall and wind (for good personal reasons, I don't expect or plan to 'publish' the data - but dislike the way it's handled by the Acu-rite hardware).

    ReplyDelete
    Replies
    1. I documented the entire thing right here on this blog. Prowl around a bit and you'll see it. It's a bit aged now, but the ideas all still work.

      Delete
  6. I was hoping that there was a software switch that changed the output format. I may try JSON in the future, but right now to do anything with the data, I have to spend time editing the file down to get rid of all the stuff I don't need (basically turning it into .csv format). I know I can put the output through jq, but if there is a way to directly output in a straight text format (like .csv or .tsv), that would be very useful - I can then have the data go right into Libreoffice Calc and handle it that way (that's how a lot of the data I work with is dealt with - that and I use the statistical software "PAST").

    (I need to learn SQL, but have way too many 'pans on the fire' right now - and trying to get info from the weather station is taking me away from other things!)

    BTW - I did go through and learned a couple of things about your rtl_433 software, but nothing found (so far) about overriding short and long values.

    ReplyDelete
    Replies
    1. If you don't want to use json, do what I did and change it to whatever you want When I first worked with it I just printed the values. Later to make some things easier in three or four years when I worked on it again, I switched to json.

      I'm not married to json, it's just a great way to document exactly what things are for debugging an changing later when you don't remember what the heck it was you did.

      Delete