hello Gary,

I give you my python script that I use without weewx to measure *the Wind 
and also Rain* .
thanks

Patrick


On Saturday, December 8, 2018 at 3:40:43 PM UTC+1, Patrick Tranchant wrote:
>
> hello I am a newbie from France ( sorry for my english )
>
> I want to use weewx on a raspberry with a weather station built by myself 
> (view on Magpi)
> I don't see my station on your website to configure :
>
> Weather Station Hardware Comparison: I don't found my weather station.
> Do you have a solution or how to configure Weewx
>
> thank you for your help
>
> Patrick
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from gpiozero import Button

rain_sensor = Button(6)
BUCKET_SIZE = 0.2794
count = 0

def bucket_tipped():
    global count
    count = count + 1
    print(count * BUCKET_SIZE)

def reset_rainfall():
    global count
    count = 0


rain_sensor.when_pressed = bucket_tipped
from gpiozero import Button
import time
import math
import statistics

wind_count = 0
radius_cm = 9.0
wind_interval = 5
store_speeds = []

def spin():
    global wind_count
    wind_count = wind_count + 1
    #print("spin" + str(wind_count))

CM_IN_A_KM = 100000.0
SECS_IN_AN_HOUR = 3600
ADJUSTMENT = 1.18

def reset_wind():
    global wind_count
    wind_count = 0

# Calculate the wind speed
def calculate_speed(time_sec):
    global wind_count
    circumference_cm = (2 * math.pi) * radius_cm
    rotations = wind_count / 2.0

    dist_km = (circumference_cm * rotations) / CM_IN_A_KM

    km_per_sec = dist_km / time_sec
    km_per_hour = km_per_sec * SECS_IN_AN_HOUR

    return km_per_hour * ADJUSTMENT

wind_speed_sensor = Button(5)
wind_speed_sensor.when_pressed = spin

# Loop to measure wind speed and report at 5-second intervals
while True:
    start_time = time.time()
    while time.time() - start_time <= wind_interval:
        reset_wind()
        time.sleep(wind_interval)
        final_speed = calculate_speed(wind_interval)
        store_speeds.append(final_speed)

        wind_gust = max(store_speeds)
        wind_speed = statistics.mean(store_speeds)
        print( (wind_speed, wind_gust), "km/h")

Reply via email to