Author Topic: DIY Weather Station based on a Raspberry Pi2  (Read 4710 times)

0 Members and 1 Guest are viewing this topic.

Offline JohnG

  • Member
  • *
  • Posts: 31
DIY Weather Station based on a Raspberry Pi2
« on: August 07, 2017, 10:42:27 PM »
About two years ago I started thinking about weather stations.  Just over a year ago I received a Raspberry Pi 2 and began collecting the bits needed.  While it is easy enough to purchase off-the-shelf stations for reasonable (to me) money, but the time you collect, log and publish the data there can be serious money involved.  Knowing that I could get mechanical sensors to measure Pressure, Temperature, Rain fall, Wind speed and Wind Direction; then take periodic photos to be published for cheap money, I decided to get serious about the electronics.

Understanding the I/O of a RPi was a *real* challenge.  I began last fall trying to get my RPi to read the sensors I bought with mixed success.  After spending two days reading and re-reading, I discovered that jumping from system purchase to installing a 3rd party software like WeeWx was fool-hearty at best - KISS is the rule!

Last weekend I made huge headway after stumbling on a WXF member's post about his WeeWx system, that pointed me not only to the code for the tipping bucket, but more importantly to a "How To" of GPIOs on the RPi.  There have been a number of changes in the two odd years since I got my RPi, and jumping to the latest version of Python was a BIG MISTAKE.  Now that I have an editor that I like (Geany) and understand that Python 2.x.x will work with my hardware and 3.anything will NOT, I have data!

My set-up looks something like:
RPi2 (Jessie, GPIO ZERO v1.4)
BME280 by Adafruit for Temperature (T), Barometric Pressure (P), Humidity (Rh) connected via I2C
HMC5883L by Adafruit for Wind Direction (WD), also connected via I2C
WS-1080-WC as the Anemometer (WS), connected to GPIO #12
WS-2080-RC for the tipping bucket Rain Gauge (RG) to GPIO #21

So far, I have the i2C stuff working using Python scripts that I found, some linked from WXF!.  I do not have the final adjustments completed as the system is still in the early validation stages, but I can read both I2C sensors and see each bucket tip of the rain gauge.

I will try and attached a couple photos for reference.
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
« Last Edit: August 07, 2017, 10:50:24 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #1 on: August 08, 2017, 02:11:40 PM »
The project for today was to figure out why the BME280 suddenly stopped working.  Keen-eyed folks might notice in the photo above that I had connected the HMC5883L correctly to the I2C bus, but had the BME280 backwards.  :oops:

I conclude this happened when I re-oriented the sensors to match the 40-pin GPIO on my board.  #-o

Since I found that problem quickly, I decided to read thru the code for the temperature part of this sensor, because as others have pointed out, Temp reads high!

My discovery is that parameter (parm) for Temp is in SI units and a function of the converted raw digital output of adc_t then another function of an offset calculation.  At the end of the day, since Pressure and Humidity *seem* to be very close to actual, I am assuming that only the final output for Temperature has the error (Atm and RH appear nominal).

The last line for the temperature calculation in *C reads "cTemp = (var1 + var2) / 5120", therefore if I manipulate the denominator "5120" to get Temp in *C to more closely match observed, I will correct the *F reading as well without affecting the RH or Atm calculations as they DO NOT use "cTemp" as a variable.

Overall, I am happy!  \:D/

Now if I could just get than damned Anemometer to read and figure out how to count bucket tips.  ](*,) ](*,) ](*,) ](*,) ](*,)
« Last Edit: August 08, 2017, 02:13:40 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #2 on: August 08, 2017, 03:49:00 PM »
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #3 on: August 08, 2017, 05:25:02 PM »
=D>

When I saw the graphs, I knew I had seen them before!  Thanks!
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #4 on: August 09, 2017, 08:34:50 PM »
Photo of reading prior to the temperature function adjustments.  Being off by ~4*F is a fairly large error, but unable to correlate except for normal indoor temps.

 [ You are not allowed to view attachments ]
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #5 on: August 09, 2017, 09:12:10 PM »
Did you feel like shouting, "Eureka! It's alive, it's alive!"
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #6 on: August 09, 2017, 09:59:24 PM »
Did you feel like shouting, "Eureka! It's alive, it's alive!"

YES!!!!

It has been a good week for sure!  Still running into seemingly innumerable roadblocks with the bucket tip counter and anemometer.  I can see the tip, but counting them is a completely different matter  ](*,)
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #7 on: August 09, 2017, 11:50:39 PM »
 \:D/
THIS GUY IS STOKED!
 \:D/

I got ALL the I^2C sensors reading at the same time and then found a way to add CPU temperature to boot!  Even managed to get the sensor outputs aligned for easier reading :)

Now to get that damned bucket tip counter working... ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)

 [ You are not allowed to view attachments ]
« Last Edit: August 09, 2017, 11:53:28 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline vreihen

  • El Niño chaser
  • Forecaster
  • *****
  • Posts: 1216
  • K2BIG
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #8 on: August 10, 2017, 06:18:23 AM »
Now to get that damned bucket tip counter working... ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)

Are you doing hardware or software debouncing on the input from the bucket?????
WU Gold Stars for everyone! :lol:

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1132
    • Wilmslow Astro
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #9 on: August 10, 2017, 07:36:47 AM »
The BME280 datasheet says the temperature reading is likely to be above ambient?

Quote
...temperature value depends on the PCB temperature, sensor element self-heating and ambient temperature and is typically above ambient temperature.
Mark

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #10 on: August 10, 2017, 09:06:33 AM »
Are you doing hardware or software debouncing on the input from the bucket?????

I have tried no debounce, software (0.01s - 1.0s) and even though I can see each individual tip, I cannot figure out how to count (accumulate) them.  I have tried about 20 scripts for counting button presses, GPIO inputs, coin counters and either I get one tip counted for each debounce, or one tip with no accumulators.

This morning, the BME280 decided not to read again :(  Syntax error line 33 for the I2C, but nothing changed since last night except a reboot.

Will hit it again after work.
« Last Edit: August 10, 2017, 09:14:40 AM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #11 on: August 23, 2017, 06:20:33 PM »
Cannot believe it has been almost two weeks!

Update: I have done the ice-to-boiling water calibration test on my thermometers.  Presuming I waited long enough, I get high readings at low temperature and low readings at high temperature.  Typical ambient in this area ranges from 20*F to 110*F and within that range the differential is reasonably constant.

I also discovered that I^2C devices do not like long wire runs and that is why I was dropping signal on the BME280 at times.  A couple pull-up resistors of the 470 ohm variety fixed that right quick.  There is not a ton of mention about this foible, I just stumbled on it, seems to be treated as "common knowledge" within the Electrical Engineering ranks.

The rain counter is *sort-of* working.  It will count bucket tips fine, but reporting them the way I want (every 5 minutes for example) is not working AT ALL.  I can run the program and see when another 1/10" has fallen, so at least the hardware and software are ok.

I calibrated the bucket tipping to inches of rainfall using the following:
- running water *just* slow enough to be steady (we have constant "city" pressure)
- placed sensor in water stream and counted 100 bucket tips (100 in 32s)
- placed a cylinder in the water stream w/o making ANY adjustments
- ran for 30 seconds and measured depth of water
- determined the AREA of the cylinder, compared to the area of the rain sensor (Cyl = 5.94, Rain = 8.22)
- determined the "equivalent" rainfall had the areas been equal
>> Divided the water depth by number of bucket tips = 17 tips to the 0.203" ==> 83.7438 per inch

The highest rainfall rate ever recorded in this area is less than 6"/hr, or 502 tips per hour ~ 0.14 tips/second == 7.16s per tip.  This is WELL within my ability to accurately measure w/o incurring hardware, software or other IO problems.

"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #12 on: August 23, 2017, 10:09:12 PM »
I whipped up a couple hand-drawn diagrams of the intended system.

 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
« Last Edit: August 23, 2017, 10:12:11 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #13 on: August 23, 2017, 10:23:32 PM »
I also performed some tipping bucket rain sensor tests.  Three 8oz volumes were poured thru the sensor at various installation angles, all deviating from two-plane level by under 5*.

Suffice it to say, there is a large measurement error along the bucket axis and a much smaller one transversely.  Some effort should be made to ensure the sensor is level, mine has a built-in bubble level and if the center of the sight glass is entirely within the bubble, your errors will be small, if not undetectable.

As the edge of the bubble gets closer to the red ring, the measurement error goes up quickly!

 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
« Last Edit: August 23, 2017, 10:25:52 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #14 on: August 26, 2017, 09:41:56 AM »
Late last night I finally found a way to get the anemometer to read!!!!  The program I have should also help solve the counting problem I have with the rain gauge.

Once I have all the software reading correctly, I will start final design and construction of the station.  I am still wondering if I should mount the RPi remotely, or as part of the station, suggestions and experience of member is welcome here!

Remote mounting
Advantages:
 a) can use a battery back-up system
 b) easier access (no ladders needed)
 c) weatherproof enclosure not needed
 
Disadvantages:
 a) less portable
 b) longer wire runs to sensor array
 c) cannot use on-device sensors
 d) no "line-of-sight" for Wi-Fi

Station mounting
Advantages:
 a) can use solar power, no need for line voltage
 b) have line-of-sight for Wi-Fi connection
 c) more portable
 d) may be able to use on-device sensors
 
Disadvantages:
 a) weather exposure, specifically moisture and temperature are big concern
 b) more cost if solar powered
 c) access would be by ladder only
 d) all wiring would need to be made with UV tolerant and moisture tight connections

Time to get to work!
 
« Last Edit: August 26, 2017, 09:47:11 AM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #15 on: August 26, 2017, 11:21:52 AM »
You can "plumb" all the wiring inside weather-proof PVC which can be cut, bent, and glued to just about any shape...just remember to install the "pull" string/wire before you glue everything up.
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #16 on: August 26, 2017, 11:32:29 AM »
I never bother with a pull string pre-install.  I just use a vacuum cleaner later to suck the string through.
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #17 on: August 26, 2017, 01:00:01 PM »
I never bother with a pull string pre-install.  I just use a vacuum cleaner later to suck the string through.
Didn't work for me on my 90-degree corners...I had to cut, thread an old guitar-string with string (twine) attached thru, then re-glue.
« Last Edit: August 26, 2017, 01:47:26 PM by Old Tele man »
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #18 on: August 26, 2017, 01:23:11 PM »
The trick is to start with light fishing line or heavy thread. 
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #19 on: August 26, 2017, 01:52:01 PM »
I never bother with a pull string pre-install.  I just use a vacuum cleaner later to suck the string through.

One caveat... Any buried horizontal run of conduit, over time, may fill with water from condensation. I ruined a household vacuum cleaner that way. Best to use a wet/dry shop vac.

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #20 on: August 26, 2017, 01:54:00 PM »
The trick is to start with light fishing line or heavy thread.

I've had good luck with mason's twine and a bit of rag or paper towel tied to the end to create something to get carried long by the air.

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #21 on: August 26, 2017, 02:09:26 PM »
You can "plumb" all the wiring inside weather-proof PVC which can be cut, bent, and glued to just about any shape...just remember to install the "pull" string/wire before you glue everything up.

Well you promoted me to consider something I had not....

I have tele wire run from the house to the shop, where the actual station will be placed, it's 8 conductor twisted.  Obviously there is no reason for that with the advent of cell phones ;)  I am currently using a spool of same for testing on a rack in the yard, so I KNOW the I^2C stuff will work on it and I am getting wind speed just fine.

Since I have 8 wires to use, I could potentially wire as:
1) 3v3
2) Gnd
3&4) I^2C: Wind direction, Temp, RH, Pressure
   SCL
   SDA

With sensors connected to:
5) GPIO #21 = Rain
6) GPIO #18 = Wind

That would leave two left over and the RPi indoors!

Hmmmmm...........
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #22 on: August 26, 2017, 03:40:53 PM »
A man with a plan!
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside

Offline Phil23

  • Senior Contributor
  • ****
  • Posts: 289
    • Phil's Backyard
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #23 on: August 26, 2017, 09:05:47 PM »
The trick is to start with light fishing line or heavy thread.

I've had good luck with mason's twine and a bit of rag or paper towel tied to the end to create something to get carried long by the air.

Back in my BHP days we used a "Mouse".
Nothing more than little bit of rag tied to a bit of fishing line.
Then blew it thru the pipe with an air hose.

20m runs thru inch water pipe were common.
Only thing was that they did have a huge air supply;
100psi 1" air hoses in most places.


Offline JohnG

  • Member
  • *
  • Posts: 31
Re: DIY Weather Station based on a Raspberry Pi2
« Reply #24 on: August 26, 2017, 11:53:01 PM »
Today I got the WS sensor reading finally!!!!  Also have the rain gauge actually measuring rainfall (no photos of that).

A few photos of the WS sensor installed on the weather vane, compass will be inside the vane as well, for direction.

 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]

« Last Edit: August 26, 2017, 11:54:38 PM by JohnG »
"Talent is equally distributed but opportunity is not." - Leila Janah

 

anything