Showing posts tagged with raspberry pi

in weather station, arduino, raspberry pi, xbee, temperature, weather, humidity

I love learning new things, I also love monitoring things, so I decided to marry these two concepts and make a weather station from scratch. The project initially started using a number of guides, primarily a few adafruit guides like:

These two guides got me started - I dug up a Raspberry Pi I wasn't using, bought myself a breadboard, a temperature sensor (specifically the DS18B20), got some copper wire and went to work! My first attempt looked pretty much like the example provided in the TMP36 Temperature Guide and just spit out data to the terminal via a Python script.

So I could get the data, and I could display it, this was a triumph. So naturally, my next task was to do something useful with this. I fired up a MySQL server on one of my home servers and went to work. I eventually modified my original script to insert the temperature into a MySQL database. Once the data was in a database, the sky was the limit. You can see the script I currently use on GitHub.

I ended up leaving the weather station as it was for a while, the Raspberry Pi + Sensor lived in my "wiring closet" (I keep my networking stuff and servers in there, right next to the holiday decorations) and kept an eye on the temperature there. What use is a weather station that can only monitor the temperature in a closet? My next step was to add a "remote" probe in the form of a DS18B20 in a weather proof container. I wired this second temperature probe up to the breadboard and hung it just outside of my closet door to monitor the temperature of the house.

So I was happy as a clam at this point, monitoring the temperature in the closet and outside the closet. But what was the weather like outside? This expansion required quite a bit more planning and reading. What I ultimately ended up doing was buying an Arduino, Xbee, DHT11, two more DS18B20s (one with the weather coating, the other without), and a wired DHT22. The Xbee was used to communicate with the base station (the Raspberry Pi), one temperature probe hangs out the window in my bedroom along with the wired DHT22 (humidity), these probes measure the temperature and humidity outside. I also have another DS18B20 that lives in the breadboard to measure the temperature in the bedroom (why not, right?).

I then wrote a script to get the data from each probe and place it in a comma seperated format for easier interpretation by the base station. You can see that script here.

Once this was working, I added a second Xbee to the breadboard on the original Raspberry Pi, this listened for communications from the remote Xbee and wrote it to a serial port. The original script was then modified to also listen on that serial port and insert that data into the database.

At this point, I had a bunch of data and nothing to do with it, so I made a dashboard thing in Python (flask) to show the data. The repo for that code is available here.

This was one of my favorite projects thus far, the best part really is how extensible a weather station is. Since I have sensors inside and outside, I can use this data to interface with my Nest, I also considered using this to hook into a wireless humidifier (once humidity is X% turn on, turn off at Y%) and so on. If you are interested in the weather at all and want to try your hand at electronics, this is a great getting started project in my opinion.