Use the Simple Mail Transport Protocol (SMTP) to send an email message; send the email to an SMS (Short Message Service) gateway service to forward the email as a text message.
Use cases
Event detection – Academic RIO Device monitors an array of sensors and sends a text message when a sensor value goes out of range
Remote data logging – Device monitors environmental conditions through one or more sensors, stores the measurements, and forwards them by email to one or more recipients either on demand or periodically
Features
Easy to code, especially when using the “Send Email” Express VI
Implements TLS (Transport Layer Security) to ensure the secure (private) transmission of email, which is often required by modern SMTP servers
Send the email to an “SMS Gateway” service to text a mobile phone number when you know the carrier (service provider)
Use the low-level email VIs for advanced features such as attachments (single and multiple), CC and BCC recipients (carbon copy, blind carbon copy), and email headers such as “importance” level
Keep in mind
You must designate a 3rd-party SMTP server such as Google Gmail or one provided by your own Internet Service Provider (ISP); LabVIEW does not implement its own SMTP server
No built-in support to receive email
IMPORTANT: The Academic RIO Device system date must be reasonably close to the true date for TLS-secured email to be accepted by the SMTP server. Experiments with the Gmail SMTP server show that the Device system date must be no more than 12 days in the past and no more than 70 days into the future. The Device does not include an onboard real-time clock (RTC), therefore its system date resets to the same date on each power cycle. While it is possible to occasionally manually update the power-on system date (see below), consider the inexpensive Digilent I2C battery-backed RTC module to preserve the true calendar date across power cycles.
You can adjust the power-on system date with NI MAX or a browser.
LabVIEW block diagram elements
Locate these elements with "Quick Drop" (press Ctrl+Space and start typing the name); click on an icon to see more sample code that uses that element:
Connect your Academic RIO Device to your PC using USBLAN, Ethernet, or Wi-Fi. NOTE: Not all Academic RIO Devices have Ethernet and Wi-Fi connectivity options.
Download and unpack the
rt_email.zip (for use with NI myRIO 1900)
or the
NIELVISIII-rt_email.zip (for use with NI ELVIS III)
archive, and then double-click the ".lvproj" file to open the project. NOTE: This project was written for a NI myRIO 1900 or NI ELVIS III connected by USBLAN at IP address 172.22.11.2.
If you are using a different IP address or another Academic RIO Device (Example: NI myRIO 1950 or NI RIO Control Module) do the following:
If using the NI myRIO 1950 or NI RIO Control Module start with the NI myRIO 1900 Archive.
Different IP address: Right-click on the "NI myRIO 1900" Device, choose "Properties", and then enter the new IP address
Different device:
Right-click on the top of the project hierarchy, select "New Targets and Devices", keep the "Existing target or device" option, and then find and select your particular device
Select all of the components under the "NI myRIO 1900" device: click the first one and then shift+click the last one
Drag the selected components to the new device
Right-click the "NI myRIO 1900" device and select "Remove from project"
Open the “RT Main” block diagram
Double-click the “Send Mail” Express VI and enter the following information:
“Sender’s Email Address” = your Google Gmail account, e.g., “myaccount@gmail.com”
“Username” = Google account username, e.g., “myaccount”
“Password” = Google account password
CAUTION: This Express VI stores your Google account credentials – keep this in mind when posting or sharing your code!
Return to the front panel and enter the following:
“Recipients” = one or more destination email addresses separated by commas
“Subject” = subject line
“Message” = body of the email message
Run “RT Main” and observe the following behavior:
The “Internet OK” indicator signals that the RT can successfully access the Internet; refer to the “check internet access” subVI for details
The “Send Email” Express VI runs only when Internet access is available
When all goes well the recipient should receive the RT-generated email message within several seconds or perhaps as long as a minute or so, depending on the nature of the recipient’ email system
Follow these instructions to send an SMS (Short Message Service) text message to a mobile phone:
Limit the message body to 160 characters
Do an Internet search on “email to SMS gateway” to obtain the email domain of the mobile phone provider for the number you wish to text. For example, Verizon Wireless mobile phone numbers can be reached within the email domain “vtext.com.” Alternatively, use the Whitepages.com reverse lookup feature to find the carrier for a given mobile number.
Form the email address as 10digitnumber@vtext.com where 10digitnumber is the numbers-only (no hyphens) mobile phone number
Repeat the above techniques to send email from the PC using “PC Main”
Troubleshooting tips
“Error 7 occurred at Call Library Function Node in LabVIEWSMTPClient.lvlib:Open Handle.vi” (File not found) – This error indicates that the Academic RIO Device is missing the required software set add-on called “SMTP Client with SSL Support.” Follow these instructions to install the Academic RIO Device software set add-on
“Internet not accessible, therefore making no attempt to send email message” (the “check internet access” subVI was unable to connect to the Microsoft Network Connectivity Status Indicator website, a sign that Internet access is limited or unavailable) – Check the Device Network Configuration page (browse to 172.22.11.2) to determine if one of the active network adapters has a “Gateway” IP addresses other than 0.0.0.0. Also try running the “check internet access” VI located under “My Computer” to learn whether or not your development system can reach the Internet.
“Error 56 occurred at LabVIEWSMTPClient.lvlib:Send.vi” (the network operation exceeded the user-specified or system time limit.) – This is one possible symptom of lack of Internet access. Try running the “check internet access (tcp)” VI under the “NI myRIO 1900” target to confirm that you have Internet access.
“Error 363504 occurred at LabVIEWSMTPClient.lvlib:Send.vi2280005” (Invalid username or password combination) – Double-check the username and password fields; you will also need to enable the “Allow less secure apps” option on your Gmail account “Sign-in & security | Connected apps & sites” tab.
“Error 363507 occurred at LabVIEWSMTPClient.lvlib:Send.vi” (LabVIEW could not verify the authenticity of the server) – Verify that the Device system date is reasonably close to the actual date, i.e., within a few days, so that the secured TLS connection may be established to the output mail server. The Device does not have an onboard real-time clock (RTC), therefore each power cycle resets the date back to the last time the Device executed a controlled shutdown, possibly many months into the past. You can adjust the power-on system date with NI MAX or a browser.
“Error 363513 occurred at LabVIEWSMTPClient.lvlib:Send.vi” (An error occurred while sending data on the network) – verify that the “Recipients” control contains either a single email address or comma-separated multiple addresses.