Introduction: Sending an Email From an Intel Edison (using Nodemailer)
This project demonstrates a method for sending email from an Intel Edison IOT computer by pushing a button connected to the Edison. While this may not seem particularly interesting or useful, one could imagine using this method as part of a more complex system. For example the Edison could be used as part of a monitoring system and it could send an email to alert whoever needed to be notified about the fault condition(s).
This instructable requires the following hardware:
Intel Edison<br>Grove Starter Kit (for the pushbutton and LCD display)
Note1: The LCD is optional (but kind-of cool looking)
Note2: You could probably do this project with a smaller breakout board as all that is really required is a single digital input pin (for the pushbutton).
Step 1: Replacing Yocto Linux With Ubilinux
The Intel Edison comes with Yocto Linux pre-installed. Yocto is a small version of Linux which is suited for many IOT project, but it does not include the Linux sendmail program and Yocto also does not include an apt-get capability to install sendmail, so I chose the alternate route of installing Ubilinux for the Intel Edison. I will not go into details on how to do this since it is documented here:
and also here:
Once ubilinux is installed, it is simple to install sendmail using apt-get
apt-get install sendmail
Note: Someone with better Linux expertise may be able to get sendmail to work on Yocto linux, but that can be their Instructable ;)
Step 2: Updating the Mraa Library
The mraa library is used to provide an interface to the Edison I/O. Most of the mraa I/O functions worked when I installed Ubilinux, but the LCD display did not. I followed these steps to update the mraa library
Note: This instructable used Ubilinux version: ubilinux-edison-150309. If a later version of Ubilinux includes updates to the mraa library, this step may no longer be needed.
Step 3: The Node.js Source Code
The code can be found here:
After you clone this github repository, you should see the following files and sub-directories:
config/ logs/ LICENSE main.js package.json
main.js: This file contains the main program.
package.json: This file contains version information.
config/default.json: This is the configuration file. You will need to modify this file to add your email account information. Note: Since file will contain your email account name and password information, you should be careful with the security of this file. (don't allow access to it by unauthorized users).
logs: This sub-directory will contain a log of email sent.
LICENSE: MIT open-source license. http://en.wikipedia.org/wiki/MIT_License
Step 4: Install the Required Node Modules Using Npm Install
The following node.js modules need to be installed (run the following command from within the directory that contains your code)
npm install nodemailer npm install winston npm install config
After this step, your code directory should have a new sub-directory called node_modules
config/ logs/ node_modules/ LICENSE main.js package.json
Step 5: Update Config/default.json
You will need to update this file with your email account information.
"user": "your_email_address_goes_here", "password": "your_email_password_goes_here", "service": "your_email_service_goes_here",
user: This is your email address (the full address with the .com extension)
password: Your email password
service: "Yahoo" or "Gmail" (other services may be possible but I have not tried them)
Note: Since file contains your email account name and password information, you should be careful with the security of this file. (don't allow access to it by unauthorized users).
Step 6: Connect the I/O Components (pushbutton and LCD)
connect the pushbutton to the D2 connector on the Grove shield
connect the LCD to any I2C connector (it should not matter which one)
Step 7: Run the Program
In the code directory, run this command:
If all previous steps were successful, then each time you push the button (attached to the D2 input pin) the Edison should send an email to the test address that you configured in the config.default.json file.
Step 8: Acknowledgements
This project was partially inspired by another project that I worked on during a recent hackathon event held at Portland State University on the weekend of March 7-8, 2015. I was a member of a team that developed a high-tech chicken coop monitor that used an Intel Edison to log coop data (temperature, battery voltage, etc.) to a cloud service. If errors are detected (e.g. coop door open at night) an SMS text message is sent to the coop owner. A web server running in the cloud provided remote monitoring of the coop (e.g. from your mobile phone).
Thanks much to my awesome teammates of this hackathon project. I learned a lot.