-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCalibrateWaterTank.py
76 lines (54 loc) · 1.6 KB
/
CalibrateWaterTank.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
# This is used to calibrate your Water Tank and Ultrasonic Sensor for SPP2
#
# SwitchDoc Labs 2018
VERSION = "001"
try:
import conflocal as config
except ImportError:
import config
import ultrasonicRanger
print "############################"
print "Ultrasonic Tank Calibration"
print "SwitchDoc Labs"
print "Software Version:", VERSION
print "############################"
print ""
print "Step 1) Empty Water Tank"
print "Step 2) Put Ultrasonic Sensor in place on top of tank"
print ""
raw_input('hit return to continue:')
print "Measuring Empty Level"
total = 0.0
# test 10 times
for i in range(10):
measurement = ultrasonicRanger.measurementInCM()
print "{:5.3f}{}".format(measurement,"cm")
total = total + measurement
emptyaverage = total/10.0
print "{} {:6.1f} ".format( "calibrated EMPTY Level=", emptyaverage)
print ""
print "Step 3) Fill Water Tank"
print "Step 4) Put Ultrasonic Sensor in place on top of tank"
print ""
raw_input('hit return to continue:')
print "Measuring Full Level"
total = 0.0
# test 10 times
for i in range(10):
measurement = ultrasonicRanger.measurementInCM()
print "{:5.3f}{}".format(measurement,"cm")
total = total + measurement
fullaverage = total/10.0
print "{} {:6.1f} ".format( "calibrated FULL Level=", fullaverage)
print ""
f = open("TankCalibration","w+")
f.write("{:6.1f}".format(emptyaverage))
f.write(",")
f.write("{:6.1f}".format(fullaverage))
f.close()
print "############################"
print "Values written to TankCalibration File"
print "############################"
print "Calibration Complete"
print "############################"