Skip to content

Weather wind speed false value #234

@JMBRillie

Description

@JMBRillie

My setup

I'm running the latest release (v0.2.0) on the weather board.
Recording every 5 minutes and sending every reading to an MQTT broker.
Using the DFRobot's Weather Station Kit with Anemometer/Wind Vane/Rain Bucket from The Pi Hut

The problem

I've had it running for about 2 weeks now and twice I've had readings of 958.8141 m/s
I'm not sure the anemometer would have survived spinning at almost 3 times the speed of sound... so I think maybe that reading was wrong... XD
I had excatly the same number both times (958.8141)

Image

The code

The relevant code is enviro/boards/weather.py lines 110-126

  # if no sensor connected then we have no readings, skip
  if len(ticks) < 2:
    return 0

  # calculate the average tick between transitions in ms
  average_tick_ms = (time.ticks_diff(ticks[-1], ticks[0])) / (len(ticks) - 1)

  if average_tick_ms == 0:
    return 0
  # work out rotation speed in hz (two ticks per rotation)
  rotation_hz = (1000 / average_tick_ms) / 2

  # calculate the wind speed in metres per second
  circumference = WIND_CM_RADIUS * 2.0 * math.pi
  wind_m_s = rotation_hz * circumference * WIND_FACTOR

  return wind_m_s

Working this backwards from an output of 958.8141 means there was a rotation_hz value of 1000 and an average_tick_ms value of 0.5

I don't know what len(ticks) would have been but it was at least 2
If it was 2 then time.ticks_diff(ticks[-1], ticks[0]) would have been 0.5, if it was higher than 2 then time.ticks_diff(ticks[-1], ticks[0]) would be higher too
I'm not sure if time.ticks_diff(ticks[-1], ticks[0]) should be an integer or not but the first integer value would be 4 with a len(ticks) value of 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions