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

0 Members and 1 Guest are viewing this topic.

Offline TejasBob

  • Member
  • *
  • Posts: 6
Re: Homemade Weather Station using a Raspberry Pi
« Reply #150 on: June 06, 2017, 02:51:24 PM »

Second you will need to create a weewx driver that takes the ascii file and transfers it to weewx. At this point weewx takes over and creates the webpage and transfers your data to wunderground and CWOP. I have included my driver, feel free to use it but it is very simple at this point.

Code: [Select]
#
#    $Revision: 1 $
#    $Author: Nickolas McColl $
#    $Date: 2014-08-16 $
#
"""Raspberry Pi driver for the weewx weather system"""

from __future__ import with_statement
# import math
import time
#import weedb
#import weeutil.weeutil
import weewx.abstractstation
import weewx.wxformulas


def loader(config_dict, engine):
    import weewx.units
    altitude_m = weewx.units.getAltitudeM(config_dict)

    station = Raspberry_pi(altitude = altitude_m, **config_dict['Raspberry_pi'])
   
    return station
       
class Raspberry_pi(weewx.abstractstation.AbstractStation):
    """Station using Raspberry Pi"""

    def __init__(self, **stn_dict):
        self.altitude = stn_dict['altitude']
        self.loop_interval = float(stn_dict.get('loop_interval'))

    def genLoopPackets(self):
        import weewx.units

        while True:
            start_time = time.time()

            # Create Loop packet
            f = open('/home/weewx/bin/wxdata.csv')
            input = f.readline()
            f.close()   
            data = input.split(',')
            if len(data) == 13: # data line is complete, process
                for i in range(1, (len(data))):
                    try:
                        data[i] = float(data[i])
                    except ValueError:
                        data[i] = None     
           
                raw_time =time.strptime(data[0], "%Y-%m-%d %H:%M:%S")
           
                _packet = {'dateTime': int(time.mktime(raw_time)),
                           'usUnits' : weewx.METRIC,
                           'pressure' : data[1],
                           'windSpeed' : data[12], #use 3 second average
                           'windGust' : data[12], #use 3 second average
                           'windDir' : data[3],
                           'windGustDir' : data[3],
                           'outTemp' : data[4],
                           'outHumidity' : data[5],
                           'rain': data[6],
                           'radiation' :data[9],
                           'inTemp' : data[11]}
           
                _packet['dewpoint']  = weewx.wxformulas.dewpointC(_packet['outTemp'], _packet['outHumidity'])
                _packet['barometer'] = weewx.wxformulas.sealevel_pressure_Metric(_packet['pressure'], self.altitude, _packet['outTemp'])
                _packet['altimeter'] = weewx.wxformulas.altimeter_pressure_Metric(_packet['pressure'], self.altitude)
                _packet['heatdeg'] = weewx.wxformulas.heating_degrees(_packet['outTemp'], 18.333)
                _packet['cooldeg'] = weewx.wxformulas.cooling_degrees(_packet['outTemp'], 18.333)
                _packet['heatindex'] = weewx.wxformulas.heatindexC(_packet['outTemp'], _packet['outHumidity'])
                 
                yield _packet
     
            sleep_time = (start_time - time.time()) + self.loop_interval
            if sleep_time > 0:
                  time.sleep(sleep_time)
   
    def hardware_name(self):
        return "raspberry_pi"
           
   

Enjoy,

The missing part of the puzzle! One step closer. :)  Thanks!!!

I see you abandoned the lightning detector.  Any particular reason?  Been thinking about how to feel that to weewx.

Offline weathernick

  • Senior Member
  • **
  • Posts: 90
Re: Homemade Weather Station using a Raspberry Pi
« Reply #151 on: June 06, 2017, 04:51:03 PM »
I could never get the lightning sensor to work to my liking...Ended up spending too much time with it so I focused on the core sensors and my wxcams. I did noticed that future versions of WEEWX does have native support for that sensor. So ultimately we don't need code for that.

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 TejasBob

  • Member
  • *
  • Posts: 6
Re: Homemade Weather Station using a Raspberry Pi
« Reply #152 on: June 06, 2017, 07:17:35 PM »
I could never get the lightning sensor to work to my liking...Ended up spending too much time with it so I focused on the core sensors and my wxcams. I did noticed that future versions of WEEWX does have native support for that sensor. So ultimately we don't need code for that.

Nickolas

Did you ever try this? https://github.com/weewx/weewx/wiki/as3935

Offline TejasBob

  • Member
  • *
  • Posts: 6
Re: Homemade Weather Station using a Raspberry Pi
« Reply #153 on: June 21, 2017, 09:22:32 AM »
Nickolas.  Do you have a more recent copy of your raspberry_pi.py driver code?  The one I copied from you looks like it is for weewx v2.x and won't run on 3.  I'm chasing down module import errors.

Offline Crannog

  • Member
  • *
  • Posts: 20
Re: Homemade Weather Station using a Raspberry Pi
« Reply #154 on: June 28, 2017, 05:49:08 AM »
Hi Guys,

Great to see this thread still active. My remote station has been running now for 12 weeks. It originally crashed due to a power failure in Oct after a week of wet and dull weather, the solar controller failing to turn of load when battery ran down. I got a better controller and re-installed the station, with a few features disabled on PI ZERO to reduce power requirements. I fear it will die again next winter with 20W panel.

I have been working on a Arduino mini pro version which requires much less power and has good low power sleep modes. Have ye tried this? I have the sensors working (except wind as I don't have a second anemometer) and a SIM800L breakout uploading to WU. I plan to try and get a cheap VGA camera to upload images via the SIM800L. I think I will need a SD drive added to the assembly to store image prior to upload as memory is limited on Arduino's.


Offline TejasBob

  • Member
  • *
  • Posts: 6
Re: Homemade Weather Station using a Raspberry Pi
« Reply #155 on: June 28, 2017, 08:31:59 AM »
I have been working on a Arduino mini pro version which requires much less power and has good low power sleep modes.

I have thought about this but was considering using it only as a remote sensor package.  I was thinking of transmitting data back via a zigbee interface to a rPi running WeeWx.  I haven't looked at what the power requirements would be however.

Offline henryhunt

  • Member
  • *
  • Posts: 1
Re: Homemade Weather Station using a Raspberry Pi
« Reply #156 on: September 16, 2017, 09:37:27 AM »
Hi guys! I’ve been building a weather station from scratch too (using a raspberry pi and python), and have found this thread great to read when I found it a few months ago. I can do a post about my station at some point if you’d like? I just have a few questions about final things that need to be done before the station can be considered finished.

Nick, I’m using the same wind speed (inspeed - though it's the 1 pulse per rotation one instead of the 8 pulse) and rainfall (rainwise) sensors as you, and you’ve said you’re using an RC filter on both of them, based on the diagram at this link http://www.wetter-garching.de/howto.html, to remove noise. What I wanted to know is if you used all of the exact components in the diagram (470 ohm resistor, 1N4148 diode, 10 kohm resistor and 100nf capacitor) in the same setup, because in previous posts you have said that you just need to add a resistor and capacitor to remove the noise.

Also, did you use the same RC filter with the same component values for both rainfall and wind speed or does one have slightly different values?

One other thing: the diagram uses 5 volt power supply, but I’m using the 3.3 volt one on the pi, and was wondering if this would require any changes to the RC filter components?

Please forgive my detailed question. I don’t do very much electronics, so I always like to properly check that things are correct and will work before implementing them, as I know how easy it is to completely fry things.

Henry  :grin:
« Last Edit: September 18, 2017, 05:37:58 AM by henryhunt »

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: Homemade Weather Station using a Raspberry Pi
« Reply #157 on: September 22, 2017, 08:54:48 AM »
Not to hijack or create cross-posting.....

I have a similar set-up documented in a thread in this sub-forum that may provide the detail you are seeking.

https://www.wxforum.net/index.php?topic=32635.0

All the filtering I did was with software, although I did need pull-up resistors for the I2C circuit due to the number of devices connected and capacitance of the circuit (long runs).
"Talent is equally distributed but opportunity is not." - Leila Janah

Offline chadn

  • Member
  • *
  • Posts: 1
Re: Homemade Weather Station using a Raspberry Pi
« Reply #158 on: December 15, 2017, 03:18:51 PM »
Hello, I had a question regarding your Rainew 111 Rain gauge/tipping bucket. How is the cable connected to the pi? Is it a rj11 cable that just passes two wires to the pi that could be wired directly to the GPIO pins?

Also has anyone added a surface water/ground water logger at all to their applications?

Offline JohnG

  • Member
  • *
  • Posts: 31
Re: Homemade Weather Station using a Raspberry Pi
« Reply #159 on: December 17, 2017, 11:05:54 AM »
Here is my set-up for the tipping bucket.

The sensor is connected to Pin 21 of the RPi and Vref thru a resistor.

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

Offline thorn

  • Senior Member
  • **
  • Posts: 51
Re: Homemade Weather Station using a Raspberry Pi
« Reply #160 on: January 15, 2018, 09:57:04 AM »
I have not been getting email notices for the thread. My station has been running fine.

I see that weewx has a I2C interface.

https://github.com/weewx/weewx/wiki/Raspberry-Pi-weather-station-with-i2C-sensors

I still need to get my rain gauge working. I was getting false positives. Just had not had the time to work on it. I did hook it up to a PiFace interface and it worked. But it would require a separate Pi.

Offline Crannog

  • Member
  • *
  • Posts: 20
Re: Homemade Weather Station using a Raspberry Pi
« Reply #161 on: December 12, 2018, 06:19:27 PM »
Quick update for those interested. The arduino station has been running for 7 months without failure. Power usage about 0.2w compared to 1w for Pi. Below is a picture of the final design bench testing with 9v battery. The original Davis sensor failed so replaced with a Closed Cube SHT31 breakout. Working good so far.

Sent from my G3121 using Tapatalk


Offline thorn

  • Senior Member
  • **
  • Posts: 51
Re: Homemade Weather Station using a Raspberry Pi
« Reply #162 on: January 02, 2019, 01:00:12 PM »

Crannog, that's look great.

My system stopped working the other day. The card was corrupted but I was able to get the data off OK. I re-imaged another card with a image from last year and it won't boot up on the Pi that's in the station. It works OK on another pi I have inside. I'll have to swap out the Pi from the station.  I might try using the zero, they are cheaper that a regular pi.
 
I have been transmitting on HF (ham radio), I wonder if RF could into the the Pi? The antenna is about 100ft away.