Skip to content

Temperature Alarm with SMS

In this example, a program is described that reads the temperature measured by OB-215, and when the temperature exceeds -15 degrees for more than 10 minutes, sends an SMS and starts logging the temperature values. In text 11 - MODBUS ID of the OB-215 device; 6 - address of the register from which the temperature is read.

!META
* PROTOCOLVERSION 9
# the program will run every 15 seconds
* UPDATE 15
!DEVICES
* * WRHANY 120 120
* 11 WRHSINGLE 4
!PARAMS
0 11 UINT16 H 6
# alarm flag - temperature rise for more than 10 minutes
1 * UINT16 H 5000
# counter for a delay of 10 minutes
2 * UINT16 H 5001
!VARS
0 PARAMVAL P0
1 PARAMVAL P1
2 PARAMVAL P2
# next counter value (15 seconds elapsed)
3 VARADDVAL P2 15
# temperature limit
4 VAL -15
# delay counter limit (10 * 60 = 600 seconds)
5 VAL 600
!CONDS
# temperature above the limit at -15?
0 VARGRVAR V0 V4
# temperature below the limit?
1 NOT C0
# the counter has reached the limit of 10 minutes?
2 VARGEVAR V1 V5
3 NOT C2
# increase the counter if it is not overfilled and the temperature is outside the limit?
4 AND C0 C3
# crash flag set?
5 VARNEVAL V2 0
!STRS
# SMS text into which the current and limit temperatures will be inserted
0 OB-215 (11) – avaria, tmp *V0* > *V4*
!PHONES
# below can be specified phone number for receiving SMS
0 01234567
!ACTS
0 PARAMWRVAL P1 0
1 PARAMWRVAL P2 0
2 PARAMWRVAL P1 1
3 PARAMWRVAR P2 V3
4 SENDSMS H0 S0
5 PARAMCOMMENT P0 S0
!REACTS
* C1 REPEAT A0
* C1 REPEAT A1
* C2 REPEAT A2
* C4 REPEAT A3
* C5 ACT A4
* C5 REPEAT A5
#END