def wtgr800_anemometer(part, message, p): dirno = hi_nibble(p[4]) speed = lo_nibble(p[7]) * 10 + hi_nibble(p[6]) + lo_nibble(p[6]) / 10.0 avgspeed = hi_nibble(p[8]) * 10 + lo_nibble(p[8]) + hi_nibble(p[7]) / 10.0 message['source'] = message['sensor'] = part message['dir'] = dirno message['speed'] = speed message['avgspeed'] = avgspeed
def wtgr800_anemometer(part, message, p): dirno = hi_nibble(p[4]) * 22.5 speed = lo_nibble(p[7]) * 10 + hi_nibble(p[6]) + lo_nibble(p[6]) / 10.0 avgspeed = hi_nibble(p[8]) * 10 + lo_nibble(p[8]) + hi_nibble(p[7]) / 10.0 message['source'] = message['sensor'] = '%s.%02x' % (part, p[3]) message['dir'] = dirno message['speed'] = speed message['avgspeed'] = avgspeed percentage_battery(p, message)
def pcr800_rain(part, message, p): message['source'] = message['sensor'] = '%s.%02x' % (part, p[3]) rain = (lo_nibble(p[6]) * 10 + hi_nibble(p[5]) + lo_nibble(p[5]) / 10.0 + hi_nibble(p[4]) / 100.0) rain *= 25.4 # convert from inch/hr to mm/hr train = (lo_nibble(p[9]) * 100 + dec_byte(p, 8) + dec_byte(p, 7) / 100.0 + hi_nibble(p[6]) / 1000.0) train *= 25.4 # convert from inch/hr to mm/hr message['speed'] = rain message['total'] = train simple_battery(p, message)
def humidity(p, message): hum = lo_nibble(p[7]) * 10 + hi_nibble(p[6]) message['humidity'] = hum
def temperature(p, message): temp = ( ((p[6] & 0x8) and -1 or 1) * (hi_nibble(p[5]) * 10.0 + lo_nibble(p[5]) + hi_nibble(p[4]) / 10.0)) message['temp'] = temp
def checksum1(p): c = hi_nibble(p[6]) + (lo_nibble(p[7]) << 4) s = ((nibble_sum(6, p) + lo_nibble(p[6]) - 0xa) & 0xff) return s == c
def checksum8(p): c = hi_nibble(p[9]) + (lo_nibble(p[10]) << 4) s = ((nibble_sum(9, p) - 0xa) & 0xff) return s == c
def checksum6(p): return (hi_nibble(p[8]) + (lo_nibble(p[9]) << 4) == ((nibble_sum(8, p) - 0xa) & 0xff))