This commit is contained in:
Your Name
2025-03-10 17:44:03 +01:00
parent 10c4348e54
commit 283a46eb0b
2 changed files with 68 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ Line by line installation.
``` ```
sudo apt update sudo apt update
sudo apt install git gh apache2 php php-sqlite3 python3 python3-pip jq autossh i2c-tools python3-smbus -y sudo apt install git gh apache2 php php-sqlite3 python3 python3-pip jq autossh i2c-tools python3-smbus -y
sudo pip3 install pyserial requests RPi.GPIO adafruit-circuitpython-bme280 crcmod psutil ntplib pytz --break-system-packages sudo pip3 install pyserial requests RPi.GPIO adafruit-circuitpython-bme280 crcmod psutil ntplib pytz gpiozero --break-system-packages
sudo mkdir -p /var/www/.ssh sudo mkdir -p /var/www/.ssh
sudo ssh-keygen -t rsa -b 4096 -f /var/www/.ssh/id_rsa -N "" sudo ssh-keygen -t rsa -b 4096 -f /var/www/.ssh/id_rsa -N ""
sudo ssh-copy-id -i /var/www/.ssh/id_rsa.pub -p 50221 airlab_server1@aircarto.fr sudo ssh-copy-id -i /var/www/.ssh/id_rsa.pub -p 50221 airlab_server1@aircarto.fr

View File

@@ -0,0 +1,67 @@
'''
__ _____ _ _ ____
\ \ / /_ _| \ | | _ \
\ \ /\ / / | || \| | | | |
\ V V / | || |\ | |_| |
\_/\_/ |___|_| \_|____/
Script to read wind speed from a Davis Anémomètre-girouette Vantage Pro (6410)
https://www.shapemaker.io/blog/wind-speed-measurements-with-anemometer-and-a-raspberry-pi
Connexion:
black (wind speed ) -> gpio21
green (wind direction) -> gpio20
Yellow -> 5v
RED -> GND
Attention: The Raspberry Pi doesn't have analog inputs, so we need an analog-to-digital converter (ADC) to read the wind direction.
/usr/bin/python3 /var/www/nebuleair_pro_4g/windMeter/read_wind_speed.py
'''
import time
from gpiozero import Button
from signal import pause
# Setup wind speed sensor on GPIO pin 21 (instead of 5)
wind_speed_sensor = Button(21)
wind_count = 0
def spin():
global wind_count
wind_count = wind_count + 1
def calc_speed(spins, interval):
# Davis anemometer formula: V = P*(2.25/T) in MPH
# P = pulses per sample period, T = sample period in seconds
wind_speed_mph = spins * (2.25 / interval)
return wind_speed_mph
def reset_wind():
global wind_count
wind_count = 0
# Register the event handler for the sensor
wind_speed_sensor.when_pressed = spin
try:
print("Wind speed measurement started. Press Ctrl+C to exit.")
while True:
# Reset the counter
reset_wind()
# Wait for 3 seconds and count rotations
print("Measuring for 3 seconds...")
time.sleep(3)
# Calculate and display wind speed
wind_speed = calc_speed(wind_count, 3)
print(f"Wind count: {wind_count} spins")
print(f"Wind speed: {wind_speed:.2f} mph ({wind_speed * 1.60934:.2f} km/h)")
except KeyboardInterrupt:
print("\nMeasurement stopped by user")