Appendix B. Example Program
B-6
'*****************************************************************************
'* ------------------------- ConvertSDI12addr() -------------------------- *
'* Convert SDI-12 character address (0->9, A->Z, and a->z) to number value *
'* (0->61). *
'*****************************************************************************
Function
ConvertSDI12addr(address
As
Long
)
As
String
* 1
Select
Case
address
Case
0
To
9
'ASCII Code 48->57 = 0->9
Return
(
CHR
(a 48))
Case
10
To
35
'ASCII Code 65->90 = A->Z = 10->35
Return
(
CHR
(a 55))
Case
36
To
61
'ASCII Code 97->122 = a->z = 36->61
Return
(
CHR
(a 61))
EndSelect
Return
("")
EndFunction
'ConvertSDI12addr()
'EndSub
'Main Program
BeginProg
Scan
(60,Sec,0,0)
PanelTemp
(PTemp,250)
Battery
(batt_volt)
'Read the Metadata from the sensor daily
'Also read if a non-valid serial number is present (Startup values should be zero).
'A valid serial number will be greater than 1
If
(Meta(1,1) < 1)
OR
(
IfTime
(0,1440,Min))
Then
For
i=1
To
NumTempSensors
SDI12Recorder
(Meta(i,1),SDI12_Port,ConvertSDI12addr(i),"R1!",1.0,0)
Next
EndIf
'Read the current Temperature Min and Max Values Every 5 minutes and Reset the Value
If
TimeIntoInterval
(0,5,Min)
Then
For
i=1
To
NumTempSensors
'Read the current Temperature Value
SDI12Recorder
(TempC(i),SDI12_Port,ConvertSDI12address(i),"R0!",1.0,0)
'To Read and Reset the User Min Values use SDI-12 R6! or M6! Command. This command
'is preferred over the minimum instruction as it constitutes the minimum of all
'1 s measurements taken since the previous aR6! Command.
SDI12Recorder
(TempCMin(i),SDI12_Port,ConvertSDI12addr(i),"R6!",1.0,0)
'To Read and Reset the User Max Values use SDI-12 R7! or M7! Command. This
'command is preferred over the maximum instruction as it constitutes the
'maximum of all 1 s measurements taken since the previous aR6! Command.
SDI12Recorder
(TempCMax(i),SDI12_Port,ConvertSDI12addr(i),"R7!",1.0,0)
Next
EndIf
CallTable
Daily
CallTable
MetaData
CallTable
TempSample
NextScan
EndProg