From 432334bd2371395b6056e64c553b985424a5620d Mon Sep 17 00:00:00 2001 From: deennoo Date: Tue, 6 Jan 2015 21:30:14 +0100 Subject: [PATCH 1/2] Addition of BTHGN129 Sensor Addition of BTGHN129 Sensor (Outdoor Temp, Hum & Pressure) and set as first sensor on dictionnary --- parser.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/parser.py b/parser.py index c0ce0e4..c67afba 100644 --- a/parser.py +++ b/parser.py @@ -100,6 +100,63 @@ def _parseBHTR968(data): output['forecast'] = 'unknown' return output + + def _parseBTHGN129(data): + """ + Parse the data section of a BTHGN129 outdoor temperature/humidity/pressure + sensor packet and return a dictionary of the values recovered. + """ + + output = {'temperature': -99, 'humidity': -99, 'pressure': -99, + 'comfortLevel': 'unknown', 'forecast': 'unknown'} + + # Indoor temperature in C + temp = nibbles2value(data[0:12]) + temp = 10*temp[2] + temp[1] + 0.1*temp[0] + if sum(data[12:16]) > 0: + temp *= -1 + output['temperature'] = temp + + # Indoor relative humidity as a percentage + humi = nibbles2value(data[16:24]) + output['humidity'] = 10*humi[1]+humi[0] + + # Indoor "comfort level" + comf = nibbles2value(data[24:28])[0] + if comf == 0: + output['comfortLevel'] = 'normal' + elif comf == 4: + output['comfortLevel'] = 'comfortable' + elif comf == 8: + output['comfortLevel'] = 'dry' + elif comf == 0xC: + output['comfortLevel'] = 'wet' + else: + output['comfortLevel'] = 'unknown' + + # Barometric pressure in mbar + baro = nibbles2value(data[28:36]) + baro = (baro[1] << 4) | (baro[0]) + if baro >= 128: + baro -= 256 + #output['pressure'] = baro + 856 + output['pressure'] = baro + 1071 + + # Pressure-based weather forecast + fore = nibbles2value(data[40:44])[0] + if fore == 2: + output['forecast'] = 'cloudy' + elif fore == 3: + output['forecast'] = 'rainy' + elif fore == 6: + output['forecast'] = 'partly cloudy' + elif fore == 0xC: + output['forecast'] = 'sunny' + else: + output['forecast'] = 'unknown' + + return output + def _parseRGR968(data): """ @@ -212,6 +269,7 @@ def parsePacketv21(packet, wxData=None, verbose=False): * 1D20 - THGR268 - Outdoor temperature/humidity * 1D30 - THGR968 - Outdoor temperature/humidity * EC70 - UVR128 - UV sensor + * 5D53 - BTHGN129 - Outdoor temperature/humidity/pressure """ # Check for a valid preamble @@ -225,9 +283,12 @@ def parsePacketv21(packet, wxData=None, verbose=False): # Try to figure out which sensor is present so that we can get # the packet length sensor = ''.join(["%x" % i for i in nibbles2value(packet[20:36])]) - if sensor == '5d60': - nm = 'BHTR968' + if sensor == '5d53': + nm = 'BTHGN129' ds = 96 + elif sensor == '5d60': + nm = 'BTHGN129' + ds = 96 elif sensor == '2d10': nm = 'RGR968' ds = 84 @@ -275,7 +336,9 @@ def parsePacketv21(packet, wxData=None, verbose=False): # Parse data = packet[52:ds] channel = nibbles2value(packet[36:40])[0] - if nm == 'BHTR968': + ifnm == 'BTHGN129': + output = _parseBTHGN129(data) + elif nm == 'BHTR968': output = _parseBHTR968(data) elif nm == 'RGR968': output = _parseRGR968(data) @@ -343,13 +406,13 @@ def parseBitStream(bits, elevation=0.0, inputDataDict=None, verbose=False): ### Data reorganization and computed quantities if valid: #### Dew point - indoor and output - if sensorName in ('BHTR968', 'THGR268', 'THGR968'): + if sensorName in ('BHTR968', 'THGR268', 'THGR968','BTHGN129'): sensorData['dewpoint'] = computeDewPoint(sensorData['temperature'], sensorData['humidity']) #### Sea level corrected barometric pressure - if sensorName in ('BHTR968',) and elevation != 0.0: + if sensorName in ('BHTR968','BTHGN129') and elevation != 0.0: sensorData['pressure'] = computeSeaLevelPressure(sensorData['pressure'], elevation) #### Disentangle the indoor temperatures from the outdoor temperatures - if sensorName == 'BHTR968': + if sensorName == 'BHTR968','BTHGN129': for key in ('temperature', 'humidity', 'dewpoint'): newKey = 'indoor%s' % key.capitalize() sensorData[newKey] = sensorData[key] From 8d7d74b32976608a8349a01d21abdf62246fbdf8 Mon Sep 17 00:00:00 2001 From: deennoo Date: Thu, 8 Jan 2015 11:08:08 +0100 Subject: [PATCH 2/2] Remplacement of BTHR968 by BTHGN129 Remplacement of BTHR968 by BTHGN129. BTHGN129 act as outdoor sensor for temp, hum and Pressur This sensor got 5 channel, to get information recorder on main stream, you must have to put it on channel 1 On this parser i start to includ Rain Meter : PCR 800 def_parse Wind Gauge : WGR800 def_parse Temp/hum sensor : THGN800 def_parse As those sensor are Oregon Scientific Protocol V3 there are not support for the moment --- parser.py | 154 +++++++++++------------------------------------------- 1 file changed, 31 insertions(+), 123 deletions(-) diff --git a/parser.py b/parser.py index c67afba..6944fa3 100644 --- a/parser.py +++ b/parser.py @@ -46,62 +46,7 @@ def computeChecksum(bits): return value -def _parseBHTR968(data): - """ - Parse the data section of a BHTR968 indoor temperature/humidity/pressure - sensor packet and return a dictionary of the values recovered. - """ - - output = {'temperature': -99, 'humidity': -99, 'pressure': -99, - 'comfortLevel': 'unknown', 'forecast': 'unknown'} - - # Indoor temperature in C - temp = nibbles2value(data[0:12]) - temp = 10*temp[2] + temp[1] + 0.1*temp[0] - if sum(data[12:16]) > 0: - temp *= -1 - output['temperature'] = temp - - # Indoor relative humidity as a percentage - humi = nibbles2value(data[16:24]) - output['humidity'] = 10*humi[1]+humi[0] - - # Indoor "comfort level" - comf = nibbles2value(data[24:28])[0] - if comf == 0: - output['comfortLevel'] = 'normal' - elif comf == 4: - output['comfortLevel'] = 'comfortable' - elif comf == 8: - output['comfortLevel'] = 'dry' - elif comf == 0xC: - output['comfortLevel'] = 'wet' - else: - output['comfortLevel'] = 'unknown' - - # Barometric pressure in mbar - baro = nibbles2value(data[28:36]) - baro = (baro[1] << 4) | (baro[0]) - if baro >= 128: - baro -= 256 - output['pressure'] = baro + 856 - - # Pressure-based weather forecast - fore = nibbles2value(data[40:44])[0] - if fore == 2: - output['forecast'] = 'cloudy' - elif fore == 3: - output['forecast'] = 'rainy' - elif fore == 6: - output['forecast'] = 'partly cloudy' - elif fore == 0xC: - output['forecast'] = 'sunny' - else: - output['forecast'] = 'unknown' - - return output - - def _parseBTHGN129(data): +def _parseBTHGN129(data): """ Parse the data section of a BTHGN129 outdoor temperature/humidity/pressure sensor packet and return a dictionary of the values recovered. @@ -157,10 +102,9 @@ def _parseBTHGN129(data): return output - -def _parseRGR968(data): +def _parsePCR800(data): """ - Parse the data section of a RGR968 rain gauge packet and return a dictionary + Parse the data section of a PCR800 rain gauge packet and return a dictionary of the values recovered. """ @@ -176,7 +120,7 @@ def _parseRGR968(data): return output -def _parseWGR968(data): +def _parseWGR800(data): """ Parse the data section of a WGR968 anemometer packet and return a dictionary of the values recovered. @@ -198,30 +142,9 @@ def _parseWGR968(data): return output -def _parseTHGR268(data): - """ - Parse the data section of a THGR268 temperature/humidity sensor packet and return a dictionary - of the values recovered. - """ - - output = {'temperature': -99, 'humidity': -99} - - # Temperature in C - temp = nibbles2value(data[0:12]) - temp = 10*temp[2] + temp[1] + 0.1*temp[0] - if sum(data[64:68]) > 0: - temp *= -1 - output['temperature'] = temp - - # Relative humidity as a percentage - humi = nibbles2value(data[16:24]) - output['humidity'] = 10*humi[1]+humi[0] - - return output - -def _parseTHGR968(data): +def _parseTHGN800(data): """ - Parse the data section of a THGR268 temperature/humidity sensor packet and return a dictionary + Parse the data section of a THGN800 temperature/humidity sensor packet and return a dictionary of the values recovered. """ @@ -263,13 +186,12 @@ def parsePacketv21(packet, wxData=None, verbose=False): values recovered. Supported Sensors: - * 5D60 - BHTR968 - Indoor temperature/humidity/pressure - * 2D10 - RGR968 - Rain gauge - * 3D00 - WGR968 - Anemometer - * 1D20 - THGR268 - Outdoor temperature/humidity - * 1D30 - THGR968 - Outdoor temperature/humidity + * 5D53 - BTHGN129 - Outdoor temperature/humidity/pressure + * 1924 - PCR800 - Rain gauge + * 1984 - WGR800 - Anemometer + * FA28 - THGN800 - Outdoor temperature/humidity + * EC70 - UVR128 - UV sensor - * 5D53 - BTHGN129 - Outdoor temperature/humidity/pressure """ # Check for a valid preamble @@ -286,20 +208,14 @@ def parsePacketv21(packet, wxData=None, verbose=False): if sensor == '5d53': nm = 'BTHGN129' ds = 96 - elif sensor == '5d60': - nm = 'BTHGN129' - ds = 96 - elif sensor == '2d10': - nm = 'RGR968' + elif sensor == '2A19': + nm = 'PCR800' ds = 84 - elif sensor == '3d00': - nm = 'WGR968' + elif sensor == '1A89': + nm = 'WGR800' ds = 88 - elif sensor == '1d20': - nm = 'THGR268' - ds = 80 - elif sensor == '1d30': - nm = 'THGR968' + elif sensor == 'FA28': + nm = 'THGN800' ds = 80 elif sensor == 'ec70': nm = 'UVR128' @@ -336,18 +252,14 @@ def parsePacketv21(packet, wxData=None, verbose=False): # Parse data = packet[52:ds] channel = nibbles2value(packet[36:40])[0] - ifnm == 'BTHGN129': + if nm == 'BTHGN129': output = _parseBTHGN129(data) - elif nm == 'BHTR968': - output = _parseBHTR968(data) - elif nm == 'RGR968': - output = _parseRGR968(data) - elif nm == 'WGR968': - output = _parseWGR968(data) - elif nm == 'THGR268': - output = _parseTHGR268(data) - elif nm == 'THGR968': - output = _parseTHGR968(data) + elif nm == 'PCR800': + output = _parsePCR800(data) + elif nm == 'WGR800': + output = _parseWGR800(data) + elif nm == 'THGN800': + output = _parseTHGN800(data) elif nm == 'UVR128': output = _parseUVR128(data) else: @@ -406,21 +318,17 @@ def parseBitStream(bits, elevation=0.0, inputDataDict=None, verbose=False): ### Data reorganization and computed quantities if valid: #### Dew point - indoor and output - if sensorName in ('BHTR968', 'THGR268', 'THGR968','BTHGN129'): + if sensorName in ('BTHGN129', 'THGN800', 'THGN800'): sensorData['dewpoint'] = computeDewPoint(sensorData['temperature'], sensorData['humidity']) - #### Sea level corrected barometric pressure - if sensorName in ('BHTR968','BTHGN129') and elevation != 0.0: - sensorData['pressure'] = computeSeaLevelPressure(sensorData['pressure'], elevation) + #### Disentangle the indoor temperatures from the outdoor temperatures - if sensorName == 'BHTR968','BTHGN129': - for key in ('temperature', 'humidity', 'dewpoint'): - newKey = 'indoor%s' % key.capitalize() - sensorData[newKey] = sensorData[key] - del sensorData[key] - #### Multiplex the THGR268 values + if sensorName == 'BTHGN129': + for key in ('temperature', 'humidity', 'dewpoint','pressure'): + output[key] = sensorData[key] + #### Multiplex the THGN800 values for key in sensorData.keys(): if key in ('temperature', 'humidity', 'dewpoint'): - if sensorName == 'THGR968': + if sensorName == 'THGN800': output[key] = sensorData[key] else: try: