Wireless WiFi based Thermometers Rated for 0C (lower?) to about 299C.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

104 lines
1.7 KiB

#!/usr/bin/python3
import socket, sys
from pprint import pprint
from time import sleep
msg = bytearray(16)
# ID?
msg[0] = 0x3c
msg[1] = 0x54
msg[2] = 0x01
msg[3] = 0x69
msg[4] = 0xe0
msg[5] = 0x81
msg[6] = 0xe2
#??
msg[7] = 0x41
msg[8] = 0x31
msg[9] = 0x01
msg[10] = 0x02
msg[11] = 0x00
# DATA HERE
# EOF?
msg[15] = 0x3e
# reusable socket to send broadcast packets, and get responses
b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
b.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
b.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
b.bind(("0.0.0.0", 8900))
# DATA:
if (len(sys.argv) == 2):
# first and third bytes will increase by 10 for each degree C
# second byte holds overflow.
num = int(sys.argv[1])
bs = num * 10
msg[12] = (bs & 0x00FF)
msg[13] = (bs & 0xFF00) >> 8
for x in range(0, 256):
msg[14] = x
print("{} {} {}".format(hex(msg[12]), hex(msg[13]), hex(msg[14])))
b.sendto(msg, ("10.1.2.116", 49154))
sleep(0.1)
else:
msg[12] = int(sys.argv[1], 16)
msg[13] = int(sys.argv[2], 16)
msg[14] = int(sys.argv[3], 16)
b.sendto(msg, ("10.1.2.116", 49154))
# 00 00 b2: 0
# 0a 00 bc: 1
# 14 00 c6: 2
# 1e 00 d0: 3?
# 32 00 e4: 5
# 46 00 f8: 7
# f4 00 02: 8?
# 50 00 02: 8
# 64 00 16: 10
# 2c 01 df: 30
# 36 01 e9: 31
# 40 01 f3: 32
# 4a 01 fd: 33
# 54 01 07: 34
# f4 01 a7: 50
# fe 01 b1: 51
# 08 02 bc: 52
# 12 02 c6: 53
# 1c 02 d0: 54
# 26 02 da: 55
# 30 02 e4: 56
# 3a 02 ee: 57
# 44 02 f8: 58
# 4e 02 02: 59
# e4 02 98: 74
# 02 03 b7: 77
# 4c 04 02: 110
# 56 04 0c: 111
# 60 04 16: 112
# 6a 04 20: 113
# 74 04 2a: 114
# 7e 04 34: 115
# ba 04 70: 121
# ae 06 66: 171