Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://www.facebook.com/groups/PythonUserDeutschland/?multi_permalinks=2309771629168801¬if_id=1603924541443079¬if_t=group_highlights&ref=notif
- # https://www.dg1sfj.de/index.php/elektronik/selbstbau/51-usb-protokoll-oregon-scientific-wmr-100-wetterstation
- import datetime
- import struct
- def parse_datetime(data):
- result = struct.unpack("<c3x5bxb", data)
- frame, minute, hour, day, month, year, check_sum = result
- return datetime.datetime(2000 + year, month, day, hour, minute)
- hex_str = "30 60 00 00 1A 12 02 05 07 00 CA".replace(" ","")
- data = binascii.unhexlify(hex_str)
- time_stamp = parse_datetime(data)
- print(time_stamp)
Add Comment
Please, Sign In to add comment