Skip to content

Instantly share code, notes, and snippets.

@mc3k
Last active December 31, 2024 17:33
Show Gist options
  • Save mc3k/5b889804f63c73fe0d8fd2631c05bed4 to your computer and use it in GitHub Desktop.
Save mc3k/5b889804f63c73fe0d8fd2631c05bed4 to your computer and use it in GitHub Desktop.
Log ThermoPro TP350S temperature and humidity in Linux
import sys, os, logging, datetime
from tp357tool import *
temp, humid = None, None
mac = 'MY:MA:CA:DD:RE:SS'
# Read data from ThermoPro
device, read, write = bt_setup(mac)
temp, humid = wait_for_temp(read, write)
if temp is not None:
format = "%Y-%m-%d,%H:%M:%S"
today = datetime.datetime.today()
s = today.strftime(format)
output = s+' '+str(temp[0])+' '+str(humid[0])+'\n'
with open('tp350.log', 'a') as f:
f.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment