Author Topic: Homemade Weather Station using a Raspberry Pi  (Read 74348 times)

0 Members and 1 Guest are viewing this topic.

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Homemade Weather Station using a Raspberry Pi
« on: April 23, 2014, 06:57:02 PM »
Hello all,

I have been lurking around here for some time and have acquired a great deal of knowledge. So time to give some of it back. I have started work on a custom weather station using the Raspberry Pi as the datalogger running 8 meteorological sensors. Those sensors are:
AM2315 (temperature and humidity sensor)
BMP180 (pressure)
Rainew111 (Rain gauge)
MOD-1016 (Lightning Sensor Module)
3 cup Anemometer from Gary Stofer (basically an Inspeed Vortex)
Wind vane from Gary Stofer (basically an Inspeed E-Vane)
Pyranometer build from a kit from the Institute for Earth Science Research and Education

This is a work in progress but I figured I would post my results here in case others try to do something similar.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline Skywatch

  • !!Warning!! I'm a Skywarn certified storm spotter and insane like one!
  • Forecaster
  • *****
  • Posts: 1844
  • Hakuna Matata (Timon and Pumba)
Re: Homemade Weather Station using a Raspberry Pi
« Reply #1 on: April 23, 2014, 11:50:08 PM »
Now I want to get started on one of these. Sounds like an awesome setup. Do you have pictures? This might be my next project.

PS. The Inspeed Vortex and E vane are stripped down Downeaster sensors. My friend I got my Taylor stuff from does a little bit of Downeaster.
I live in an apartment and for the moment am not a home weather watcher.

I am a storm chaser.

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #2 on: April 24, 2014, 11:13:16 AM »
Thank you for the information about Inspeed. Very nice sensors and turned out to be half of my budget on the weather station.

As for pictures, those will have to wait until the weekend but I have plenty to document the entire process. I also have code to post as well.

I also have pictures of my version of the FARS which will house the AM2315 sensor.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #3 on: April 25, 2014, 12:25:14 AM »
Some pictures of my setup thus far.


This is the test platform I made to house all the sensors during testing. This way I can move the device outside to collect data or back to the shop for modifications.


My version of the FARS. 70mm fan pulls air up through both sets of pipes. Will see how she tests.


An Orbit enclosure makes for a nice home for the electronics. The GPIO port will connect to the protoboard and from their to all the sensors.

For the software side of the house I plan on building my own driver for WEEWX. The first step though is to create code that can read all the sensors. I have pressure and winds working at this time.

Oh what have I gotten myself into.  :grin:
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline Skywatch

  • !!Warning!! I'm a Skywarn certified storm spotter and insane like one!
  • Forecaster
  • *****
  • Posts: 1844
  • Hakuna Matata (Timon and Pumba)
Re: Homemade Weather Station using a Raspberry Pi
« Reply #4 on: April 25, 2014, 04:54:35 PM »
Very nice!
I live in an apartment and for the moment am not a home weather watcher.

I am a storm chaser.

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #5 on: April 29, 2014, 11:51:18 PM »
The latest test of the homemade pyro from the Institute for Earth Science Research and Education

Red is the homemade sensor. Blue and Green are PSP sensors. Might need to check to see if mine is level. Correction factor is 5000watts/m^2/volt
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline Skywatch

  • !!Warning!! I'm a Skywarn certified storm spotter and insane like one!
  • Forecaster
  • *****
  • Posts: 1844
  • Hakuna Matata (Timon and Pumba)
Re: Homemade Weather Station using a Raspberry Pi
« Reply #6 on: April 30, 2014, 12:33:58 PM »
Cool! Is there a picture of the solar radiation sensor?
I live in an apartment and for the moment am not a home weather watcher.

I am a storm chaser.

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #7 on: April 30, 2014, 07:49:18 PM »
Yea, I have one on my phone. I will see if I can upload it tonight.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #8 on: April 30, 2014, 10:15:14 PM »
Bam!! One homemade solar sensor. The sensor next to it is a PSP which I used to calibrate mine.



I have the raw data and will analysis the data a little bit more but overall I am pleased with it. This device only has a spectral range of 700 to 1100nm vs Davis's 400 to 1100nm. It will be interesting to compare data during cloudy days or high humidity. Right now it is bone dry and not a cloud in the sky.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Re: Homemade Weather Station using a Raspberry Pi
« Reply #9 on: May 01, 2014, 07:04:18 AM »
Weathernik:

Very nice project and I know it takes time away from fiddling around with it to take pix, post, and answer questions.

Your project looks a lot like what I am planning to do with a shed full of precious sensors I have accumulated over the years but my wife calls 'junk'.

What did you use to generate the graph showing the response curve just above this posting?

Thanks. Dale
Oh, is there a reference for the Raspberry Pi that one can read an get a good idea of the work to be done, programming styles, etc. that would be of help if I considered using this device as the engine to drive all the data gathering?  Any one or two books or online material that is good, or is this just jump in and start fiddling to make progress?
ECWx.info
&
ECWx.info/t/index.php

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #10 on: May 01, 2014, 02:30:34 PM »
I love questions!!! One of the main reasons for doing this post is to answer questions and perhaps help someone along the way. Worst case I have some pretty pictures to look at.

To your questions:
The data was a screenshot from some campbell scientific software that is collecting the data. It is part of the system that I am using to calibrate my Pyro. I will be using excel to produce some better graphs so I can get the true correction factor.

Ah references... I think I have used the entire internet for this project!!! For me I started by seeing what the RPi could and couldn't do. Here is what the RPI has that is useful for building a weather station:

8 unused GPIO ports: These are digital ports so you can use them for all things digital. For building a weather station these are handy to drive LED lights and count pulses. For me I will use six of them, one for counting precip bucket tips, one for counting pulses from the wind speed sensor, one as an IRQ for the lightning sensor, one for monitoring the FARS fan's RPM, and two for LED lights (status light and lightning activity light)

2 SPI ports: SPI is just a communcation protocal. Some meterological sensors can use SPI but I would avoid it. The RPi only has two ports and doesn't support slave devices. For me I use one port for my MCP3208 (analog to digital converter, 8 ports) and the other is free.

Analog ports: The RPi has no analog ports! So you need to add some. You can get a board that has this kind of stuff or you can just get yourself a MCP3208 IC and add it to a break out board (BOB). The MCP3208 adds 8 ports. I use one for wind direction, one for the pyro (I also amp the signel with a INA122), and two to monitor the 12v(for the FARS fan only) and 5v(RPi) rails. Also I went with the MCP3208 because it is a 12bit ADC. This means it will convert voltages into values from 0 (0volts) to 4095 (3.3volts) giving it a resolution of 0.8mv. If I picked a 10bit ADC the resolution would have been 6mv. The pyro needs the resolution of the 12bit ADC hence why i picked it. The wind direction would have been fine with 10bit.

I2C: Second to analog ports (which the RPi has none hence the MCP3208) this is the most useful ports. I2C allows numerous sensors to be attached to a single set of wires (SDA, SCL) where each device has a unique address. I have the lightning sensor, temperature, humdity and pressure all using this port.

Power: The RPi has 5v and 3v3 (also known as 3.3volts). You can only drive like 50ma off the 3v3 rail but the 5v has well over 150ma. Most of my sensors use 5v (lightning, temperature/humidity, wind sensors). The only sensors using 3v3 is the pressure sensor because the BOB (break out board) was designed that way.

Network: If you get the version B you get additional Memory (RAM), an additional usb port, and a ethernet jack. For me, I use the network jack for debuging and wifi (dongle on the usb port) for production. You could use version A but will have to deal with only have one usb port and no ethernet jack.

Storage: only storage is via an SD memory chip. You will need an 8Gb chip to get the OS loaded. A very good idea to image the memory chips incase you have problems. then you could just buy another chip restore the image and you are back in business.

Programming languange: Since the OS is linux you can program in any language that works well in linux (all but VB perhaps??). RPi developers usally use python2, python3 or c++. I stuck with Python2/3 and it seems to be working well. The main issue with Python is it is slower than C++ (for various reasons). For me I am running a python script that samples all my sensors once a second and still have about 8/10 of a second left for the cpu to just sit idle.

WEEWX: This is the software that actually displays the weather data to a web page and also sends it off to Wunderground, NWS, etc... The only rub is that for a custom station you need to build a custom driver to interface it to your data. There are plenty of examples on how to do this. I picked this software as it runs on the RPi with no issues.


References:
http://www.raspberrypi.org/   For all your general questions about RPi.
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code   Here are some good code examples for a few sensors. I "stole" a lot of good ideas from there.
http://www.weewx.com/  all things related to WEEWX.
https://www.sparkfun.com/ Various BOB of sensors can be found here. Also plenty of other BOB for other common IC.  I picked up the BMP180 BOB from them.
« Last Edit: September 11, 2014, 06:00:44 PM by weathernick »
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #11 on: May 09, 2014, 12:43:07 AM »
Things are moving along. Mostly working on building the prototype station with all the sensors nicely integrated together for ease of testing.

Tested the air flow of the FARS and i am getting 4 m/s at the entrance of the inside chamber. That puts it about 4 times the air flow of a Davis and inside the range of the RM Young FARS (http://www.davisnet.com/product_documents/weather/app_notes/AN_24-temp-radiation-shield-comparison.pdf). It helps that a 70mm fan is powering this verses the small fan for the Davis. Also the computer fan is rated for 8 years of use... I will be curious how long it will work outside. For 5 dollars I can afford to burn this up every year.

I did add some code to my datalogger program to measure the fan's rotation and 12 volt power levels. That way I can disable temperature/humidity in the event the fan shuts down. That should get my attention to go fix the fan!

I have a good solid week of data from my Pyro against the calibrated references. I should be able to generate a correction factor from that data. Right now it looks to track better than 5% at this time. Naturally it still isn't a PSP so it won't track as well during cloudy conditions but we did have a dust storm during the week and the data did track well during that.

Measured temperature out in garage for 3 days before my script hit an error and crashed. Lots more debuging to do but things are looking good.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #12 on: June 18, 2014, 04:22:28 PM »
The station has now been installed outside(only pressure and lightning sensors are installed). I will upload some pictures later. Right now I am dealing with a heat issue. Turns out that having two power bricks (5v and 12v) inside the case with the Pi has resulted in the temperature getting too high. Turns out the Pi can handle the heat(80°C) but the wifi adapter is only rated to 40°C. The summer heat isn't helping either (~45°C) So I am playing around with that. Might have to break down and get a better wifi adapter.

I added a green LED light that flashes when the system is collecting values. Right now I have ran the system continuously for about a week with no problems in the core program.

We will keep moving forward.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #13 on: June 25, 2014, 10:37:45 AM »
Got Weewx configured for pressure. The rest of the variable should be easy now... but I have to install the sensors. Temp and humidity should be up today.

The site is at http://www.wunderground.com/personal-weather-station/dashboard?ID=KAZYUMA27#history
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline cburkins

  • Member
  • *
  • Posts: 4
Re: Homemade Weather Station using a Raspberry Pi
« Reply #14 on: August 07, 2014, 09:25:31 AM »
Hello WeatherNick,

I'm curious if you've connected/configured your InSpeed Anemometer to your Raspberry Pi ? 

I'm thinking about doing something quite similar, and was hoping to leverage your work.

-Chad

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #15 on: August 08, 2014, 04:38:54 PM »
I have connected the sensor. It is a little tricky with the RPi as there is no ADC on board which is needed for wind direction. I am assuming you have built or installed a ADC to your RPi. I am currently cleaning up my code and tracking down a bug with the lightning/precipitation sensor. I can post the wind code for you if you like? Those wind sensors are very nice and I am most pleased with them. They work extremely well... so well I had to place a 3 second average(wmo standard) because I was getting 1 second instant winds well above anything in the area. You will be happy with the sensor.

Nickolas
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #16 on: August 08, 2014, 04:55:52 PM »
I just realized that I haven't posted any updates on the system. So here we go.

Winds: I have moved the wind sensor to the top of my two story house and it has mad a big different in wind speed and direction. The data is now perfect and shows a SSE flow during our monsoonal surges. Wind speed actually worked too well and I was capturing 1 second gust that were well higher than anything else out there. I now do a three second average per WMO standards and that seems to match up well with the airport and other davis systems.

Temperature/humidity (FARS): This was the second sensor online and has done much better than I thought. I have also used the monsoon to help compare it to the airport and it is perfect (+- 1 degree F dewpoint) I do need to finish the code to shut down the sensor when the fan fails(which I measure its RPM).

Pressure: The first sensor installed. I get spikes in the data during power up which I could filter out, but other than that it is also perfect and matched up well with the airport.

Solar: This has to be my favorite sensor. Primary because it allows me to gauge cloud cover when i am away from the house. Also because it only cost 25 dollars to build. Its resolution is only 4 watt/m^2 but that ends up working perfectly fine.

Precipitation: Well this one is turning out to be were all my engery is going to go to. It works perfectly fine during tests but when it rains I get sporadic errors. Could be a loose wire, could be the lightning sensor interacting with it somehow... Since it rains 10 times a year I don't have a lot of opportunity to test this. Thankfully I have my manual can to measure rain.

Lightning: The sensor works fine by itself, but once I integrate it into my code it fails... Since I don't get a lot of rain it will take some time to figure this one out.

Overall I am pleased with my station. Weewx is perfect for capturing and forwarding the data and I haven't had much issues outside of a few bugs that Weewx fixed quickly. Now I have been transmitting to weather underground and CWOP for 5 weeks now with only a few data dropouts.

Nickolas
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline cburkins

  • Member
  • *
  • Posts: 4
Re: Homemade Weather Station using a Raspberry Pi
« Reply #17 on: August 10, 2014, 10:12:03 AM »
Hi weathernick, thx for the reply.   While being a very experienced software and OS guy, I'm new to small electronics.   My first project was a Raspberry Pi thermometer for my fish tank, which gets logged to a Zabbix instance running in an Amazon virtual machine.

Works great. 

Googled ADC, analog to digital converter.   Looks straightforward, I'll give that a go next.   Have any tutorial to share ?  This is what I just read :  https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/connecting-the-cobbler-to-a-mcp3008


Then I guess I should pick up one of these weather stations. 

Chad

Offline tweatherman

  • Forecaster
  • *****
  • Posts: 537
Re: Homemade Weather Station using a Raspberry Pi
« Reply #18 on: August 10, 2014, 03:03:49 PM »
Weathernick,
Just curious if you ever plan on building any of these home made custom stations for possible customers?

Thanks,
tweatherman

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #19 on: August 10, 2014, 05:15:49 PM »
I have had a few people ask me about selling such units. I think the fun would be lost if I started to sell them. Also their cost would only be a little cheaper than a davis unit. I will post whatever information people need to play around with such systems but I will leave selling weather stations to the pros.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline tweatherman

  • Forecaster
  • *****
  • Posts: 537
Re: Homemade Weather Station using a Raspberry Pi
« Reply #20 on: August 10, 2014, 05:48:00 PM »
I understand.

Thanks,
tweatherman

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #21 on: August 11, 2014, 11:59:15 AM »
Chad,

If I had to do things over again I would have just gotten a ADS1015 or ADS1115 breakout boards. All that is needed is a little soldering and you are good to go. 12bit will give you 4096 values which is wind direction to the tenth.

Looks like Adafruit also has code examples for the chips as well. Their shipping is high so make sure you get everything you need on the first try or shipping will kill you. A mistake I had to learn.

Did you get your sensor from Inspeed? if so what version did you get?

Nickolas
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline cburkins

  • Member
  • *
  • Posts: 4
Re: Homemade Weather Station using a Raspberry Pi
« Reply #22 on: August 12, 2014, 10:57:22 AM »
Thanks Nick,

I'm a new father, so my hobby time is a bit limited right now, and I've only recently discovered the joy of small electronics.   So haven't yet ordered my InSpeed :)

Did some googling on the the ADC boards you recommended.   Looks like I would need to solder on the header pins something like this  ?

https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/assembly-and-wiring

I *think* I can handle that.  At any rate, it certainly looks fun :)

-Chad


Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #23 on: August 13, 2014, 06:54:15 PM »
Yep, soldering like that allows you to plug into a breadboard which makes it easy for testing. Then you can solder to your final board when you are done. Or better yet you could use this device http://www.adafruit.com/products/801

This is fun. Are you going to add any other sensors to the RPi?

Nickolas
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #24 on: August 22, 2014, 11:27:40 AM »
More updates:

I have done some massive code clean on my scripts so it actually looks like real code instead of a clobbered mess that it was. I will most likely post the code to my amazon s3 storage or something like that once I get further along in this project. Speaking of amazon s3 I know have my RPi syncing its data so I can recovered the system if there is a failure. I still have to backup the database but that shouldn't take too long.

Precip sensor will be the death of me... I have some sort of malfuntion where I am getting 10x more tips that I should. I thought it was a short but the problem came back. I have since replaced the wire and am now waiting for some more rain. It did seem to work when I showered it with my garden hose...

Lightning sensor. I am not sure if this works or not... I see this being a work in progress for a long time.

Webcam. Not in the original plan for the weather station but I had a spare webcam laying around so I figured I would give that a shot... Well that spiraled out of control and now i have a powered usb hub installed in my case to provide more power to my usb devices. The webcam was crashing my system but I think it might have something to do with the wifi.

Wifi. Well my concern about running the wifi chip above recommend temperatures came true. A few days ago the wifi chip died. I have a replacement on order and I will mount the wifi chip outside the case to help with temperatures. I also extended my wifi network so it was closer to the station. That seems to help with connection problems I was having (although that may have just been related to the dying chip.)


Some interesting information about the Raspberry Pi I have found out while doing this.
1.) Be careful of the SD memory chip you buy. Some chips have very low random 4k writes.  Sandisk Ultra memory seems good but you might want to search to see what other people have found. Ultimately you would like to get a chip that has around 1Mbps for random 4k writes.
2.) The Raspberry Pi has a watchdog circuit that could be helpful to reboot your system if it hangs. This could improve the reliability of the station greatly.
3.) Overclock you must!!! The Pi loves overclocking and it is even approved by the RPi foundation. Just run raspi-config and select 900mhz (medium) overclocking. This will give you upwards of 50% boost in some calculations.
4.) Weewx is great but it does eat up some processing power if you have 1 minute storage intervals and product reports. I find that weewx will eat up about 25% of my cpu if I want it to generate web reports. My datalogger script only takes about 5% to collection all the information from the sensors.
PWS: Custom built with Raspberry Pi collecting the data from the sensors.
CWOP: EW5462
Wunderground: KAZYUMA27
Personal WX page: http://mccolls.weewx.s3-website-us-east-1.amazonaws.com/