DeaD_EyE

wmr-100-wetterstation time_stamp

Oct 29th, 2020
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # https://www.facebook.com/groups/PythonUserDeutschland/?multi_permalinks=2309771629168801&notif_id=1603924541443079&notif_t=group_highlights&ref=notif
  2.  
  3. # https://www.dg1sfj.de/index.php/elektronik/selbstbau/51-usb-protokoll-oregon-scientific-wmr-100-wetterstation
  4.  
  5. import datetime
  6. import struct
  7.  
  8.  
  9. def parse_datetime(data):
  10.     result = struct.unpack("<c3x5bxb", data)
  11.     frame, minute, hour, day, month, year, check_sum = result
  12.     return datetime.datetime(2000 + year, month, day, hour, minute)
  13.  
  14. hex_str = "30 60 00 00 1A 12 02 05 07 00 CA".replace(" ","")
  15. data = binascii.unhexlify(hex_str)
  16. time_stamp = parse_datetime(data)
  17. print(time_stamp)
  18.  
RAW Paste Data