matthewwall / weewx-sdr

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

WS68 Support #167

Open fankyy opened 1 year ago

fankyy commented 1 year ago

Please add WS68 Support (Wind/Solar Sensor)

{"time" : "2022-09-26 00:47:08", "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 90, "battery_ok" : 1, "lux_raw" : 0, "wind_avg_raw" : 0, "wind_max_raw" : 0, "wind_dir_deg" : 157, "data" : "00 210", "mic" : "CRC"}
{"time" : "2022-09-26 00:47:24", "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 90, "battery_ok" : 1, "lux_raw" : 0, "wind_avg_raw" : 0, "wind_max_raw" : 0, "wind_dir_deg" : 157, "data" : "00 210", "mic" : "CRC"}
{"time" : "2022-09-26 00:47:41", "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 90, "battery_ok" : 1, "lux_raw" : 0, "wind_avg_raw" : 0, "wind_max_raw" : 0, "wind_dir_deg" : 157, "data" : "00 210", "mic" : "CRC"}
{"time" : "2022-09-26 00:47:57", "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 90, "battery_ok" : 1, "lux_raw" : 0, "wind_avg_raw" : 0, "wind_max_raw" : 0, "wind_dir_deg" : 157, "data" : "00 210", "mic" : "CRC"}

It uses the same device protocol like e.g. the WH40 rain gauge (113)

Thanks a lot!

fankyy

andylittle commented 1 year ago

What units are battery_raw, wind_avg_raw, wind_max_raw? Do you have the latest version of RTL_433? Is rtl_433 not parsing correctly and outputting the raw values?

Try this in your sdr.py:

class EcoWittWS68Packet(Packet):
    # This is for a WS68 sensor

    #  {"time" : "2022-09-26 00:47:08", "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 90, "battery_ok" : 1, "lux_raw" : 0, "wind_avg_raw" : 0, "wind_max_raw" : 0, "wind_dir_deg" : 157, "data" : "00 210", "mic" : "CRC"}

    IDENTIFIER = "EcoWitt-WS68"

    @staticmethod
    def parse_json(obj):
        pkt = dict()
        pkt['dateTime'] = Packet.parse_time(obj.get('time'))
        pkt['usUnits'] = weewx.METRICWX
        pkt['station_id'] = obj.get('id')
        pkt['battery'] = 0 if obj.get('battery_ok') == 1 else 1
        pkt['luminosity'] = Packet.get_float(obj, 'lux_raw')
        pkt['wind_speed'] = Packet.get_float(obj, 'wind_avg_raw')
        pkt['wind_gust'] = Packet.get_float(obj, 'wind_max_raw')
        pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')
        return EcoWittWS68Packet.insert_ids(pkt)

    @staticmethod
    def insert_ids(pkt):
        station_id = pkt.pop('station_id', 0)
        return Packet.add_identifiers(pkt, station_id, EcoWittWS68Packet.__name__)
fankyy commented 1 year ago

My rtl_433 version is _21.12-113-g631f9f85 branch master at 202207052057

rtl_433 version 21.12-113-g631f9f85 branch master at 202207052057 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "(null)/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...

New defaults active, use "-Y classic -s 250k" for the old defaults!

Registered 187 out of 219 device decoding protocols [ 1-4 8 11-12 15-17 19-23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151-161 163-168 170-175 177-197 199 201-215 217-219 ]

It seems there is one newer Version from 20220718 (21.12+git20220718 release) but it's only a few days apart so not sure if there are changes for the ws68?

The raw wind numbers are probably the same as in a WH65 or WH69, they seem to be whole numbers always EDIT: they seem to be quite a bit higher, wait..

{"time" : "2022-09-26 15:27:08", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 971, "wind_avg_raw" : 14, "wind_max_raw" : 15, "wind_dir_deg" : 251, "data" : "00 204", "mic" : "CRC"}
{"time" : "2022-09-26 15:27:25", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 1017, "wind_avg_raw" : 17, "wind_max_raw" : 20, "wind_dir_deg" : 251, "data" : "00 a04", "mic" : "CRC"}
{"time" : "2022-09-26 15:27:41", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 1077, "wind_avg_raw" : 18, "wind_max_raw" : 26, "wind_dir_deg" : 251, "data" : "00 204", "mic" : "CRC"}
{"time" : "2022-09-26 15:27:58", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 1138, "wind_avg_raw" : 21, "wind_max_raw" : 26, "wind_dir_deg" : 251, "data" : "00 204", "mic" : "CRC"}
{"time" : "2022-09-26 15:28:14", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 1156, "wind_avg_raw" : 18, "wind_max_raw" : 26, "wind_dir_deg" : 251, "data" : "00 a04", "mic" : "CRC"}
{"time" : "2022-09-26 15:28:31", "protocol" : 113, "model" : "EcoWitt-WS68", "id" : 388, "battery_raw" : 91, "battery_ok" : 1, "lux_raw" : 1241, "wind_avg_raw" : 17, "wind_max_raw" : 20, "wind_dir_deg" : 251, "data" : "00 204", "mic" : "CRC"}

The battery voltage in ecowitt currently says 1.82 V, so battery_raw seems to be exactly half of the actual voltage

fankyy commented 1 year ago

Ok, seems to be a factor of 10:

2022-09-26_175631 2022-09-26_175643 2022-09-26_175518

Wind direction looks odd, until 270 deg it works

2022-09-26_180951

270° to 360° gets somehow switched to 0-90°:

2022-09-27_062701

fankyy commented 1 year ago
2022-09-28_012909 2022-09-28_183043

is there a way to correct this?

For better overview: Wind speed: 1/10 Battery: *2 Winddir: minus 90° above 270° (but not sure how the switch from e.g. 315 to 45 can be differentiated from a "true" 45° reading). I'll try to look if rtl_433 outputs something different when the wind direction turns NW)