Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

program to email with 'get variables'


ekahler Dec 8, 2015 06:37 PM

I have a CR800 and a CR206 (communiate via 206's radio and an RF401A attached to the CR800) and I am using the LS300G modem with Loggernet to get data. I am trying to program the CR800 to send an email with sensor data from both it and the CR206, once a day. I copied the code to do that from another program with different variables and constants, and I'm having a hard time figuring out how to set everything to work with my own system.

I called Campbell and they suggested using GetVariables with an array of the data I want to collect from the CR206. What I've done so far is created variables that I'm using in the send email command, but they are not attached to any actual data or variables that mean anything really. I can view my new variables when connected and they just give values of zero - they are meaningless. How do I create distinct variables and attach them to the relevant sensor readings?

One problem is that the variables in the CR800 program are the exact same as in the CR206. So if I use get variables and then assign an array with the variables from the CR206 that I want to have emailed to me, how is the program going to know that those are supposed to come from the CR206?

I created the main program in Shortcut and I don't know what I can change without wrecking the program. I can't simply set my created variable equal to Lvl_ft or CS451(1) for example, because when I try to compile is gives an error because those variables are already defined (I tried public and alias).

Here is what I have for the CR800 program:

'CR800 Series
'Created by Short Cut (3.1)
'author Libby Kahler
'12.07.2015

'Declare Variables and Units
Dim MinIntoDay
Public BattV
Public PTemp_C
Public CS450(2)
Public AirTC
Public RH
Public SW12State As Boolean
Public SC1
Public SC22

Alias CS450(1)=Lvl_ft
Alias CS450(2)=Temp_C

Units BattV=Volts
Units PTemp_C=Deg C
Units AirTC=Deg C
Units RH=%
Units Lvl_ft=feet
Units Temp_C=deg C

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,60,Min,10)
Sample(1,BattV,FP2)
Sample(1,Lvl_ft,FP2)
Sample(1,AirTC,FP2)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1440,Min,10)
Minimum(1,BattV,FP2,False,False)
EndTable

Const ServerAddr="smtp.yahoo.com:587"
Const ToAddr="ekahler@usgs.gov"
Const ToAddr2="ekahler@usgs.gov"
Const FromAddr="sancarlos122@yahoo.com"
Const Subject="FROM SC1"
Const Attach=""
Const UserName="sancarlos122@yahoo.com"
Const Password="tinpen59"
Const CRLF = CHR(13)+CHR(10)

Public Result As String * 50
Dim Message As String * 250
Dim EmailSuccess As Boolean
Dim Email_Attempts As Long
Dim EmailResult As String * 50

'Main Program
BeginProg
'Main Scan
Scan(1,Min,1,0)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default Wiring Panel Temperature measurement 'PTemp_C'

PanelTemp(PTemp_C,_60Hz)
'CS450/CS451/CS455/CS456 Pressure Transducer measurements 'Lvl_ft' and 'Temp_C'


'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SDI12Recorder(CS450,3,"0","M1!",2.30666,0)
'HC2S3 (constant power) Temperature & Relative Humidity Sensor measurements 'AirTC' and 'RH'
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


VoltSe(AirTC,1,mV2500,1,0,0,_60Hz,0.1,-40)

VoltSe(RH,1,mV2500,2,0,0,_60Hz,0.1,0)

If RH>100 AND RH<103 Then RH=100
'SW12 Timed Control
'Get minutes into current day

MinIntoDay=Public.TimeStamp(4,1)/60
'Turn ON SW12 between 0900 hours and 1700 hours
'for 15 minutes every 60 minutes
If (MinIntoDay>=540 AND MinIntoDay<1020) AND ((MinIntoDay-540) MOD 60 < 15) Then
SW12State=True

'Turn OFF SW12 only if time runs out and RS232 is not active
ElseIf (ComPortIsActive(ComRS232)=False) Then
SW12State=False

EndIf
'Always turn OFF SW12 if battery drops below 11.5 volts

If BattV<11.5 Then SW12State=False
'Set SW12 to the state of 'SW12State' variable

SW12(SW12State)

'Call Data Tables and Store Data
CallTable Table1
CallTable Table2

If TimeIntoInterval (720,1440,min)

And the CR206

'CR200/CR200X Series
'Created by Short Cut (3.1)

'Declare Variables and Units
Public BattV
Public CS450(2)

Alias CS450(1)=Lvl_ft
Alias CS450(2)=Temp_C

Units BattV=Volts
Units Lvl_ft=feet
Units Temp_C=deg C

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,60,Min)
Sample(1,BattV)
Sample(1,Lvl_ft)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1440,Min)
Minimum(1,BattV,False,False)
EndTable

'Main Program
BeginProg
'Main Scan
Scan(1,Min)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'CS450/CS451/CS455/CS456 Pressure Transducer measurements 'Lvl_ft' and 'Temp_C'
SDI12Recorder(Lvl_ft,"0M1!",1,0)
Lvl_ft=Lvl_ft*2.30666
'Call Data Tables and Store Data
CallTable Table1
CallTable Table2
NextScan
EndProg


JDavis Dec 8, 2015 09:21 PM

You may rename the variable from the CR206 when you bring it into the CR800. The TableName and FieldName parameters(source) of GetVariable must match the name of the variable on the CR206. The variable you use for the Variable parameter(destination) may have a different name.

GetVariables (Result,ComSDC7,206,206,0000,0,"Public","Lvl_ft",CR206Lvl_ft,1)


ekahler Dec 10, 2015 05:10 PM

That makes sense - but when I try to put in CR206Lvl_ft (like your example) instead of just Lvl_ft it says the variable is undefined. So I'm still not sure how to define it in such a way that it's attached to level data from the CR206. Or maybe it doesn't matter that it's undefined, it will still assign that name to the data?

Also, I get why I should use ComSDC7 but I'm not sure if that's what's supposed to be there, and if I'm supposed to create a public variable called Result first. The example program I'm working from defines Result1 2, 3, and 4 to correspond to different dataloggers, then uses that Result# for this command. Since I only have one other datalogger I'm not sure if that's necessary for me.

thank you,

Libby


ekahler Dec 10, 2015 08:55 PM

So I'm still trying to figure out how to make the getvariables command to work.

Currently I have:

'get variables from 206
GetVariables(Result22,ComSDC7,0,22,0000,0,"Table1","Lvl_ft",Lvl_ft22,1)

where Result22 is a public variable I created - I have no idea what this is supposed to be or what it means, so I suspect it's the most likely/first problem. Table1 in the CR206 looks like this:

DataTable(Table1,True,-1)
DataInterval(0,60,Min)
Sample(1,BattV)
Sample(1,Lvl_ft)
EndTable

So I think I'm telling it to go to Table1, take the Lvl_ft value, and save/report it as Lvl_ft22.

When connected to the CR800, looking at the public table (in connect) I see this:

Lvl_ft22 0
Result22 -16
Result

So it's still not working, because Lvl_ft22 should read NAN (since it's not connected to the Cr206 at the moment), and Result22 should be equal to zero (?), and Result also should be equal to 0 to indicate that....something good happened. I'm fuzzy on the result stuff. I used Result one time in the program for the CR800, in the last segment telling it when/what to email. I have no idea what it means - I copied that part of the program from a cooperator who uses a similar system.

At any rate, still not working - any suggestions?

Log in or register to post/reply in the forum.