I have a CR800 hooked up to an OBS500 turbidity meter and a Raven XT modem (Sierra Wireless). I'm trying to make it so that it sends me an email any time that the turbidity exceeds a certain value. I have very limited coding knowledge. Is this something that is done in RTMC or in Basic Editor? Can anyone point me in the right direction?
Here is an email alarm example I did for another customer. I used water level in this case, but turbidity wouldn't be any different.
Public WaterLevel Const HighWater = 10.5 Public HighWaterAlarm As Boolean Public SendAlarmMessage As Boolean Public MessageBody As String * 64 Dim ElapsedTime As Long Const Holdoff = 600 ' Seconds between alarm messages Public ServerResp As String 'Main Program BeginProg Timer (1,Sec,0 ) 'Start alarm timer Scan (1,Sec,0,0) 'Enter measurements etc. here. If WaterLevel >= HighWater Then HighWaterAlarm = True Else HighWaterAlarm = False EndIf If HighWaterAlarm = False Then SendAlarmMessage = False EndIf ElapsedTime = Timer (1,Sec,4) 'Always read your timers MessageBody = "Water level is: " & WaterLevel If HighWaterAlarm AND ElapsedTime > Holdoff Then SendAlarmMessage = True Timer (1,Sec,2) 'Reset holdoff timer EndIf NextScan SlowSequence Scan (10,Sec,1,0) 'EmailSend should be done in slow sequence, because it can take a while If SendAlarmMessage Then SendAlarmMessage = False EmailSend ("0.0.0.0","name@server.com","name@server.com","Subject","MessageBody","","UserName","Password",ServerResp) EndIf NextScan EndProg
To get more elaborate, you can add the ability to silence the alarm like this:
Public AirTemp_C Public AlarmHighHigh As Boolean, AlarmHigh As Boolean Public AcknowledgeAlarms As Boolean 'Manually set to true to reset alarms and silence for a while Public PTemp, batt_volt Public ElapsedHigh As Long, ElapsedHighHigh As Long, ElapsedAcknowledge As Long Const HighThreshold = 26 'Same units as monitored parameter Const HighHighThreshold = 28 Const AlarmHighTimer = 1 'Start numbering your timers from 1 Const AlarmHighHoldoff = 300 'seconds Const AlarmHighHighTimer = 2 Const AlarmHighHighHoldoff = 60 'seconds Const AcknowledgeTimer = 3 Const AcknowledgeHoldoff = 3600 'seconds to silence alarms 'Define Data Tables 'Main Program BeginProg ElapsedAcknowledge = AcknowledgeHoldoff + 1 'Initialize past alarm silence interval Scan (1,Sec,0,0) PanelTemp (PTemp,60) Battery (batt_volt) 'Temperature measurement of type T thermocouple on U1/U2 TCDiff (AirTemp_C,1,mV200c,U1,TypeT,PTemp,True ,0,60,1.0,0) 'Set alarms when over thresholds If AirTemp_C >= HighHighThreshold Then AlarmHighHigh = True If AirTemp_C >= HighThreshold Then AlarmHigh = True 'Important Note! : This example program will leave alarms set until manually reset 'Call Data Tables NextScan SlowSequence Scan (1,Sec,3,0) '#Alarming tasks# 'Acknowledge will silence alarm notification for a time If AcknowledgeAlarms Then AcknowledgeAlarms = false AlarmHigh = false 'Reset alarms AlarmHighHigh = false Timer (AcknowledgeTimer,Sec,2) 'Reset and start alarm silence EndIf 'Always read the current elapsed times outside of any if statements, read as zero if stopped and reset ElapsedHigh = Timer (AlarmHighTimer,Sec,4) ElapsedHighHigh = Timer (AlarmHighHighTimer,Sec,4) ElapsedAcknowledge = Timer (AcknowledgeTimer,Sec,4) If ElapsedAcknowledge >= AcknowledgeHoldoff Then 'When high level alarm triggers, send alarm message and wait for holdoff time before sending again if condition persists. If AlarmHigh AND ( (ElapsedHigh = 0) OR ElapsedHigh >= (AlarmHighHoldoff) ) Then Timer(AlarmHigh,sec,2) 'Send out your high alarm messages here EndIf 'When high high alarm triggers, ignore high holdoff and use high high holdoff. If AlarmHighHigh AND ( (ElapsedHighHigh = 0) OR ElapsedHighHigh >= (AlarmHighHighHoldoff) ) Then Timer(AlarmHighHigh,sec,2) 'Send out your high high alarm messages here EndIf EndIf 'ElapsedAcknowledge > AcknowledgeHoldoff NextScan EndProg
Thank you for the response. My router is sending me data, but I did not revieve an email when my turbidity was above 10.5 units. I have it set up so that it's sending results to a file on my computer in a .dat file. I want an email when the BS turbidity is above 10.5. I put in the router's IP in the bottom along with the email address I want it sent to. Here's my script:
'CR800 Series
'Created by Short Cut (3.2)
'Declare Variables and Units
Dim MinIntoDay
Public BattV
Public PTemp_C
Public OBS500(4)
Public SW12State As Boolean
Alias OBS500(1)=Turb_BS
Alias OBS500(2)=Turb_SS
Alias OBS500(3)=Temp_C
Alias OBS500(4)=WD_OBS
Units BattV=Volts
Units PTemp_C=Deg C
Units Turb_BS=FBU
Units Turb_SS=FNU
Units Temp_C=Deg C
Units WD_OBS=unitless
'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
Average(1,Turb_BS,FP2,False)
Average(1,PTemp_C,FP2,False)
Average(1,Turb_SS,FP2,False)
Average(1,Temp_C,FP2,False)
Minimum(1,BattV,FP2,False,False)
EndTable
'Main Program
BeginProg
'Main Scan
Scan(5,Min,1,0)
'Default CR800 Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default CR800 Datalogger Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp(PTemp_C,_60Hz)
'OBS500/OBS501 Smart Turbidity Meter (SDI-12) measurements 'Turb_BS', 'Turb_SS', 'Temp_C', and 'WD_OBS'
SDI12Recorder(OBS500(),3,"0","M!",1,0,-1)
'SW12 Timed Control
'Get minutes into current day
MinIntoDay=Public.TimeStamp(4,1)/60
'Turn ON SW12 between 0000 hours and 2359 hours
'for 25 minutes every 5 minutes
If (MinIntoDay>=0 And MinIntoDay<1439) And ((MinIntoDay-0) Mod 5 < 25) 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
NextScan
EndProg
Const HighTurb_BS = 10.5
Public HighTurb_BSAlarm As Boolean
Public SendAlarmMessage As Boolean
Public MessageBody As String * 64
Dim ElapsedTime As Long
Const Holdoff = 600 ' Seconds between alarm messages
Public ServerResp As String
'Main Program
BeginProg
Timer (1,Sec,0 ) 'Start alarm timer
Scan (1,Sec,0,0)
'Enter measurements etc. here.
If Turb_BS >= HighTurb_BS Then
HighTurb_BSAlarm = True
Else
HighTurb_BSAlarm = False
EndIf
If HighTurb_BSAlarm = False Then
SendAlarmMessage = False
EndIf
ElapsedTime = Timer (1,Sec,4) 'Always read your timers
MessageBody = "Turb_BS is: " & WaterLevel
If HighTurb_BSAlarm AND ElapsedTime > Holdoff Then
SendAlarmMessage = True
Timer (1,Sec,2) 'Reset holdoff timer
EndIf
NextScan
SlowSequence
Scan (10,Sec,1,0)
'EmailSend should be done in slow sequence, because it can take a while
If SendAlarmMessage Then
SendAlarmMessage = False
EmailSend ("myip","myemail","myemail","Subject","MessageBody","","myemail","mypassword",ServerResp)
EndIf
NextScan
EndProg
The IP address you put into the EmailSend instruction should be the IP address of the server.
PS. I suggest editing your post to remove your email account information and IP address. This is a public forum.
@joedappy If you haven't yet, you should change that email account password. You can edit the post but there's no revoking subscription emails.
Thank you, I changed all of that. I changed the IP address to the yahoo server ip address and still haven't recieved an email. I checked the junk folder too. Could it be because it's recording average turbidity and sending that to the dat file as Turb_BS_Avg? How would I correct this?
The result code from EmailSend will tell you if it is successful. If there is an error, it will give you an indication of what to check.
There are several other posts in this forum about getting Yahoo working.
Out of one of them, I saw a reference to using this for the server address:
"smtp.mail.yahoo.com:465"
No errors in CRBasic Editor. I changed the server to what you have suggested, still no email...
What does your ServerResp variable show after attempting to send an email?
Not sure what you mean... I changed ServerResp to Turb_BS. It's compiling without any errors. How would I attempt to send an email?