Es geht um das auslesen eines Anemometers (Windmesser) an meinem pi 4.

es kommt ständig der fehler

pi@raspberrypi:~ $ /home/pi/Desktop/Wetterstation/Wind/Wind.py

 File "/home/pi/Desktop/Wetterstation/Wind/Wind.py", line 19

  def calculate_speed(time_sec):

                 ^

IndentationError: unindent does not match any outer indentation level

Später soll das ganze in eine rrd Datenbank wer also dazu ne Idee hat wie das geht bin ich auch offen.

Danke im voraus

Hier ist mein code

#!/usr/bin/python3

# -- coding: utf-8 --

from gpiozero import Button

import math

import time

radius_cm = 9.0

wind_interval = 2

wind_count = 0

def spin():

  global wind_count

  wind_count = wind_count + 1

 def calculate_speed(time_sec):

   

    global wind_count

    circumference_cm = (2 * math.pi) * radius_cm

    rotations = wind_count / 2.0

     

    dist_cm = circumference_cm * rotations

     

    speed = dist_cm / time_sec

    return speed

   

wind_speed_sensor.when_pressed = spin

wind_speed_sensor = Button(5)

while True:

    wind_count = 0

    time.sleep(wind_interval)

    print( calculate_speed(wind_interval), "cm/h")