matthewwall / weewx-sdr

weewx driver for software-defined radio
GNU General Public License v3.0
114 stars 74 forks source link

Divide By Zero errors in WeeWx - Sensor map issue? #44

Closed phinnay closed 5 years ago

phinnay commented 5 years ago

I have weewx-sdr working with my Fine Offset WH65B. Everything looks good except for random crashes in weewx with "ZeroDivisionError" errors. example:

  File "./bin/weewxd", line 64, in <module>
    weewx.engine.main(options, args)
  File "/home/weewx/bin/weewx/engine.py", line 890, in main
    engine.run()
  File "/home/weewx/bin/weewx/engine.py", line 191, in run
    self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
  File "/home/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
    callback(event)
  File "/home/weewx/bin/weewx/engine.py", line 540, in new_loop_packet
    self.accumulator = self._new_accumulator(event.packet['dateTime'])
  File "/home/weewx/bin/weewx/engine.py", line 650, in _new_accumulator
    self.archive_interval)
  File "/home/weewx/bin/weeutil/weeutil.py", line 220, in startOfInterval
    m = int(time_tt.tm_min // interval_m * interval_m)
ZeroDivisionError: integer division or modulo by zero

what stands out is the "self._new_accumulator(event.packet['dateTime'])" line.

When I run the weewx-sdr driver directly, I see output from my sensor array as follows:

out: ['{"time" : "2019-02-14 01:10:14.653076", "protocol" : 78, "model" : "Fine Offset WH65B", "id" : 10, "temperature_C" : 1.500, "humidity" : 51, "wind_dir_deg" : 283, "wind_speed_ms" : 1.721, "gust_speed_ms" : 2.040, "rainfall_mm" : 407.416, "uv" : 2, "uvi" : 0, "light_lux" : 0.000, "battery" : "OK", "mic" : "CRC", "mod" : "FSK", "freq1" : 914.983, "freq2" : 914.911, "rssi" : -12.775, "snr" : 14.586, "noise" : -27.362}]
parsed: {'rain_total.10.FOWH65BPacket': 407.416, 'uv.10.FOWH65BPacket': 2.0, 'wind_dir.10.FOWH65BPacket': 283.0, 'uv_index.10.FOWH65BPacket': 0.0, 'light.10.FOWH65BPacket': 0.0, 'battery.10.FOWH65BPacket': 0, 'wind_gust.10.FOWH65BPacket': 2.04, 'temperature.10.FOWH65BPacket': 1.5, 'dateTime': 1550106614, 'humidity.10.FOWH65BPacket': 51.0, 'usUnits': 17, 'wind_speed.10.FOWH65BPacket': 1.721}

my sensor map is:

 [[sensor_map]]
        light = light.10.FOWH65BPacket
        uv = uv.10.FOWH65BPacket
        rain = rain_total.10.FOWH65BPacket
        windDir = wind_dir.10.FOWH65BPacket
        windSpeed = wind_speed.10.FOWH65BPacket
        windGust = wind_gust.10.FOWH65BPacket
        outHumidity = humidity.10.FOWH65BPacket
        outTemp = temperature.10.FOWH65BPacket
        txBatteryStatus = battery.10.FOWH65BPacket

There are a few items in the "parsed" stanza without sensor identifiers (usUnits, dateTime) I assume that since they do not have identifiers, I do not need to manually map them in the sensor_map? Did not see anything in the documentation to confirm or deny this, however the mention of dateTime in the error has me second guessing...

Any ideas?

matthewwall commented 5 years ago

There are a few items in the "parsed" stanza without sensor identifiers (usUnits, dateTime) I assume that since they do not have identifiers, I do not need to manually map them in the sensor_map?

that is correct.

what archive interval did you specify in your weewx configuration?

phinnay commented 5 years ago

my archive interval is set to "30"

matthewwall commented 5 years ago

weewx supports archive interval of 60 or greater. also, archive interval must be a multiple of 60, otherwise you will get unexpected behavior at midnight crossings.

300 (5 minutes) is a standard archive interval. if you want to capture data at higher temporal resolution, then use weewx to feed your loop data into influx or some other timeseries database.

if you think this should be otherwise, please post to the weewx user group.

matthewwall commented 5 years ago

i fixed the lux-to-solarrad conversion by removing it. the driver should not be doing those conversions, especially lux-to-solarrad, since there is no correct way to convert from lux to solar radiation. commit cb40cea