T1 Hall Probe System
10.2 Example Python script to display the field in large text
import
sys
import
requests
import
time
import
tkinter
from
tkinter
import
*
# Initial prompts in console
print
("\nT1 BIG FIELD DISPLAY"),
# Get IP address for device here
defipaddr =
"192.168.1.135"
print
("Set T1 IP address (default is",defipaddr,")
ipaddr =
input()
if
ipaddr ==
"":
ipaddr = defipaddr
print
("Using",ipaddr,"\n")
t1B_url =
"http://"+ipaddr+"/io/t1/probe/field/value.json"
# Choose field units here
Units =
"Gauss"
UnitMult = 1.0
UnitFmt =
"{:+10.2f}"
print
("Select units ((G or T), default is Gauss)
selUnits =
input
()
if
selUnits ==
"T"
or
selUnits == "t":
Units =
"Tesla"
UnitMult = .0001
UnitFmt =
"{:+10.6f}"
# Heartbeat ticker
global
pls, plsctr
pls =
["'"," ","
"]
plsCtr = 1
t1B_url =
"http://"
+ ipaddr +
# Get T1 ID
t1_Name =
requests.get("http://"
# Set up field display window
B_window = Tk()
B_window_Title =
"PTC "
B_window.wm_title(B_window_Title)
B_window.minsize(900,168)
# Get first field reading
ra = requests.get(t1B_url)
vala = ra.json()
vala = vala * UnitMult
vala = str(UnitFmt.format(vala))
T1 User Guide
# Call to html server
# Timestamps
print
"/io/t1/adc/1/value.json"
+ ipaddr + "/io/ip/hostname/value.json")
+ Units +
"meter
"
+ t1_Name +
T1_UG_210314
",end="")
",end="")
"
"
+ ipaddr
Page 24 of 42