Freezer/Refrigerator Example

In many applications, it is useful to be emailed if a certain condition occurs - for example if the temperature of a refrigerator or freezer is getting too high. This example shows how to configure the device to send an alert e-mail when a specific analog pin driven by an analog temperature sensor reaches a certain value. This example also shows you how to edit the contents of the e-mail that is sent by the EZ Web Lynx.

For this example, we will trigger an alarm if Input 1 goes above 3 Volts. When the alarm triggers we will send an e-mail.

Initial setup:

Create a new .htm file in your project called config.htm. This will include all the initial setup required for our application. Once uploaded to the EZ Web Lynx, simply view config.htm once with a web browser and it will be configured. Since the configuration is stored to non-volatile memory, config.htm only needs to be run once. Alternately, you could also configure these settings using the serial port or the UDP command port.

Add the following contents to your config.htm:

    <title>ezWeblynx e-mail alarm setup</title>
    <!--(EXEC ID=My Device Name)-->
    <!--(EXEC NVSTRING0=Refrigerator)-->
    <!--(EXEC EMAIL_PORT=25)-->
    <!--(EXEC EMAIL_USER=username)-->
    <!--(EXEC EMAIL_PASS=password)-->
    <!--(EXEC EMAIL_SUBJECT=ezWeblynx E-mail alert!)-->
    <!--(EXEC TRIGGER_SAFETY=1)-->
    <!--(EXEC TRIGGER_DELAY=300)-->
    <!--(EXEC TRIGGER_INSPECT1=ANALOG,1,1,3.0)-->

    <h1>ezWeblynx configured for e-mail alerts!</h1>

Here is an explanation of the commands used:

  • EXEC sets the config register to the desired value.
  • ID allows you to configure a name for your device. It may be useful to program a unique identifier for each of your EZ Web Lynxes.
  • NVSTRING0 allows us to store a string to non-volatile memory. We are starting our string at position 0. There are 256 non-volatile memory positions. We will use NVSTRING0 for a description of what Input 1 is.
  • EMAIL_HOST and EMAIL_PORT configure the SMTP server to use for sending e-mails. You should change these values for your ISP.
  • EMAIL_USER and EMAIL_PASS configure the username/password required by your SMTP server for sending e-mails. If your SMTP server does not require this, you should remove these two lines.
  • EMAIL_TO configures to To or destination of the e-mails. EMAIL_FROM configures the From address of the sent e-mails.
  • EMAIL_SUBJECT configures the subject of the send e-mails.
  • You can configure the body of the e-mail by having an email.txt in your project. This will be covered in the next section.
  • TRIGGER_SAFETY acts as a debounce of the alarm condition. TRIGGER_SAFETY=1 configures the device to not send another alarm event until the voltage has gone below 3.0V and then back over 3.0V. If TRIGGER_SAFETY is set to 0, it will send an e-mail every 300 seconds as long as the voltage is above 3.0V.
  • TRIGGER_DELAY is the delay between alarm events. To prevent the EZ Web Lynx from spamming an SMTP server, it has a minimum value of 300 seconds for e-mails.
  • TRIGGER_INSPECT1 configures what the first alarm is looking for. For our instance, we are waiting for the analog voltage on Input 1 to go above 3.0V.
  • TRIGGER_ACTION1 configures what to do if the first alarm is triggerd. For our instance, we are going to send an e-mail.

Now create a new text file called email.txt and add it to your project. When an e-mail is sent by the EZ Web Lynx, it uses the contents of email.txt for the body of the e-mail. Add the following contents to your email.txt:

Alarm Condition!

Device ID: <!--(READ ID)-->

<!--(READ NVSTRING0)--> is greater than 3.0V 
(current reading is <!--(READ PIN_ANALOG1)-->)

Here is an explanation of the commands used:

  • READ read the config register and replaces the tag with the contents of the register.
  • ID reads our device ID. We had initially set this value with config.htm shown above.
  • NVSTRING0 reads our description of the input pin. We had initialy set this value with config.htm shown above.
  • PIN_ANALOG1 reads the analog voltage on input pin 1.

With this project uploaded the EZ Web Lynx, it will send the alert e-mail whenever the input voltage in Input 1 goes above 3.0V.