Click here to Skip to main content
14,926,277 members
Articles / Internet of Things
Article
Posted 12 Jul 2016

Stats

27.3K views
87 downloads
14 bookmarked

Smart Table Clock for Smart Home

Rate me:
Please Sign up or sign in to vote.
4.90/5 (16 votes)
17 Aug 2016CPOL11 min read
A real smart table clock with Gmail notification, Fire Alarm, temperature monitoring with Intel Edison

Image 1Image 2Image 3Image 4Image 5Image 6

Introduction

Ah! Another 'smart clock'!

You may well be thinking "what is even need of a clock project when phone does it?"

Well, an IoT connected embedded device does many things which smart phones do not do that well. They respond to hardware and sensor events in a faster and smarter ways. When you connect such devices to cloud, you get some awesome use cases which a simple mobile fails to do any days.

This is a project I worked on to explore the exciting new possibilities with a clock and connecting it to IoT.

So what is so special about the clock?

1) The clock shows date and time ( which obviously all the clock shows)

2) It shows temperature ( which many table stand clock shows)

3) It shows Gmail notification and can respond to that. For example "coming home" mail turns on home light and "leaving  home" mail turns off the home light.

4) Shoots up fire alarm in case a very high and abnormal temperature pattern is detected.

Because the clock is connected to cloud, you can perform several tasks like scheduling an event, automatic notification and many more.

Before we start, let me make an honest confession. Like many of you, I am also new to IoT and Intel Edison Board. But when I was learning the IoT fundamentals, I saw most of the tutorials are Windows based. There are many differences when you develop an IoT framework on Linuc than on Windows.

Even though Intel Edison runs on Yocto, configuring the board from a Linux platform and then coding needs many tweaks and twists. So, in this I would more or less share my learning experience with you.

How to work with Intel Edision Board in Linux

First you need to install putty on your linux system by using this command into your terminal

PowerShell
$sudo apt-get install putty

Putty is a ssh and telnet client.If you want to access your system remotely,for example suppose you have more than one systems with ubuntu , one with windows and another  with ssh server.Then you could be accessed ssh server from  the other systems using putty software by remotely login to the ssh server.

You need to configure putty in order to work with intel edison board.To connect the intel Edison board serially, you have to set the custom serial baud rate 115200 to the serial line /dev/ttyUSB0 .Because the default baud rate is 9600.To set a custom buad rate you need to give a command on the terminal:

PowerShell
$stty -F /dev/ttyUSB0 115200

When you execute this line ,you will get a error such as /dev/ttyUSB0 serial line permission denined.Because in the group category of /dev/ttyUSB0 serial line doesnot have read and write permission.Using the following command you can see the permissions of any file.

PowerShell
$ls -l /dev/ttyUSB0

 

Image 7

                                                  Figure: Attriutes of /dev/ttyUSB0

Now you can reset the permission then in the unix using chmod command to see the changed permission of files,you have to use the  command with -l option.The following commands are:

PowerShell
$sudo chmod a+rw /dev/ttyUSB0

$ls -l /dev/ttyUSB0

This is the following screen shot:

Image 8

                              Figure : Assign read and write permission to group category

So in the above screen if you notice,group category assigned read and write permission.Now you can set the custom baud rate 115200 to the /dev/ttyUSB0 serial line.No error will be shown.This is the following screen shot:

Image 9

                                                Fig:custom Baud rate 115200 set to /dev/ttyUSB0

Now configure the putty to access ssh server remotely,you can use the following command to open putty.

PowerShell
$sudo putty /dev/ttyUSB0 -serial -sercfg 115200

This command will open putty window and after pressing Enter ,it is asking for the login.

Image 10

                     Figure : Putty window open

Image 11       

                                        Figure : Asking for login name and password  

 

 

Now, you have to do the following steps.I am demonstrating  it using the following screen sorts:

Firstly, give login name(root) and password.If the authentication is correct then you got the Edison prompt.In the prompt write 'ifconfig' to configure and get the connected IP address.

Image 12

                           Figure : Configuring putty

Using this Ip address(192.168.1.2) you can also login using the command:

PowerShell
$ssh <a href="mailto:root@192.168.1.2">root@192.168.1.2</a>

Now to connect wi-fi,you need to write the following command:

PowerShell
$configure_edison –wifi

The wifi will be connected by giving the wifi password and this is the following screen sort:

Image 13

                              Figure: connecting wifi

 

Image 14

                         Figure : Assigning wifi password

 

 

Now if you want to check the internet connection ,you can ping to the terminal using the command:

PowerShell
$ping google.com

Image 15

                           Figure  : Checking Wifi connecton

Image 16

                                         Figure : Command prompt appear

when the edison prompt will return,it is ready to start with IoT(Internet of things).Here I am demonstrating my work on IoT(smart clock for smart home).This project is developed by javacript environment with node.js module on Linux based (ubuntu).

Background

 The smart clock is doing various different smart works.It consists with two modules.1. It displays current date and current time on the LCD. 2. Temperature indication with alarm,LCD display with background colour change and send  mail to Gmail Address.

In the first module it displays time and date on the LCD with green backgroud color.In second module if temperature is crossed the limit temperature then smart clock display the temperature value and with current time and generate notification with alarm,change background colour of LCD(green to red) and send email to the gmail address.

Using the code

1.To display current time and date on the LCD , you have to connect LCD with the Intel Edison board.Intel Edison has I2C port,you have to connect the LCD with the I2C.It is just like that:

Image 17

                                 Fig: LCD connected with Intel Edison Board

 

Now need to remotely log in to the ssh server using putty(steps given above) and create a file using the command

JavaScript
$vi clock.js

and write the code following to display date and time:

JavaScript
var currentdate=new Date();
var jsUpmI2cLcd=require('jsupm_i2clcd');

var lcd=new jsUpmI2cLcd.Jhd1313m1(6,0x3E,0x62);

var loop=function()

{

var time=currentdate.getHours()+":"+currentdate.getMinutes()+":"+currentdate.getSeconds();

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,3);

lcd.write(time);

var date=currentdate.getFullYear()+"-"+('0'+(currentdate.getMonth()+1)).slice(-2)+"-"+('0'+currectdate.getDate)).slice(-2);

lcd.setCursor(1,2);

lcd.write(date);

setTimeout(loop,500);

}

loop();

 

In the above code i have used getHours(),getMinutes and getSeconds() methods to display current hours,minute and second.Time is displayed on LCD starting from 0 number row and 3 rd numer column.Display time on the LCD using write method.And getFullYear(),getMonth() and getDate() methods to display current date.It displays date from the 2nd row.

To run this above code you need to write the following command:

JavaScript
$node clock.js

This is the following output:

Image 18

                                                      Fig:current time and date displayed

Image 19

                                                Fig: smart clock with date time       

Smart clock also can display the current time and date in the different way using the following code.

JavaScript
var currentdate=new Date();

var jsUpmI2cLcd=require('jsupm_i2clcd');

var lcd=new jsUpmI2cLcd.Jhd131m1(6,0x3E,0x62);

var loop=function()

{


currentdate=new Date();

var targetTime=new Date(currentdate);

var timeZoneFromDB=+5.30;

var tzDifference=timeZoneFromDB*60+targetTime.getTimezoneOffset();

var offsetTime=new Date(targetTime.getTime()+tzDifference*60*1000);

//to separate the time

var time=offsetTime.getHours()+":"+offsetTime.getMinutes()+":"+offsetTime.getSeconds();

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,3);

lcd.write(time);

var date=new Date();

lcd.setCursor(1,0);

lcd.write(date.toGMTString());

setTimeout(loop,1000);

}

loop();

using the above code we display the current time in HH:MM:SS and display the date into 'thu, 28 Jul 2016'.This is the following screen shot:

Image 20

                                Fig: Diffferent format time date display                                  

2.In the second module you need to connect the temperature sensor groove connector with the Intel Edison board.You can connect it with any of the analog port of groove board.Here I connect it with A0 port.Here is the image is as follows:

Image 21

2.Second you have to connect buzzar groove connector with any of the data port.Here I connect it

with D5 data port.Here is the image is as follows:

Image 22

You can connect a LCD for the notification also.It is display the current temperature and background colour is set to green.if temperature cross the threasold value then backgroung color change to red.This is the following way you can connect the LCD to the I2C port of Intel Edison board.

Image 23

Afterwards you need to connect the Intel Edison board and get into the Edision command prompt.

This is the following screen sort.

Image 24

This is the following code that you can use to read single value temperature using temperature sensor.

var mraa=require('mraa');

console.log('The varsion o0f mraa is:' + mraa.getVersion());

var AnalogPin0=new mraa.Aio(0);

var B=3975;

var a=AnalogPin0.read();

var resistance=(1023.0-a)*10000.0/a;

var temperature=1/(Math.log(resistance/10000.0)/B+1/298.15)-273.15;

var value=Math.round(temperature*100)/100;

console.log(value);

In the above code signal of the temperature sensor is connected with A0.The B value is the value of thermistor.Formula (1023-a)*10000.0/a is used to get the registance of the sensor.Formula 1/(Math.log(resistance/10000.0)/B+1/298.15)-273.15 is converting to temperature via NBSP datasheet catalog.

This is the following screen sort is as follows:

Image 25

 

Now if the displayed temperature cross the threasold value then notification is generated.This is the following code is as follows:

JavaScript
var digitalPin5=new mraa.Gpio(5);

digitalPin5.dir(mraa.DIR_OUT);

if(value>35)

{

digitalPin5.write(1);

}

You can write code for LCD color change notificaion .This is the following code is as follows:

JavaScript
var AnalogPin0=new mraa.Aio(0);

var jsUpmI2cLcd=require('jsupm_i2clcd');

var lcd=new jsUpmI2CLcd.Jhd1313m1(6,0x3E,0x62);

var B=3975;

var a=AnalogPin0.read();

var resistance=(1023.0-a)*10000.0/a;

var temperature=1/(Math.log(resistance/10000.0)/B+1/298.15)-273.15;

var value=Math.round(temperature*100)/100;

console.log(value);

var digitalPin5=new mraa.Gpio(5);

digitalPin5.dir(mraa.DIR_OUT);

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);

if(temperature>25)

{

lcd.clear();

lcd.setColor(255,0,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);
lcd.setColor(0,255,0);
lcd.setCursor(1,3);
lcd.write("It is hot");

digitalPin5.write(1);

}

In the above code if the temperature is normal then LCD display in such a way.

Image 26

                                             Figure : Normal Temperature

If temperature is crossed the threasold value then red backcolor will on.

Image 27

                     Figure :  Temperature crossed threshold

But if you want to check the temperature frequently then generate notification after cross the threasold value than the code is like that

JavaScript
var mraa=require('mraa');

var jsUpmI2cLcd=require('jsupm_i2clcd');

var lcd=new jsUpmI2CLcd.Jhd1313m1(6,0x3E,0x62);

console.log('The varsion o0f mraa is:' + mraa.getVersion());

var AnalogPin0=new mraa.Aio(0);

var B=3975;

var digitalPin5=new mraa.Gpio(5);

digitalPin5.dir(mraa.DIR_OUT);

var loop=function()

{


var a=AnalogPin0.read();

var resistance=(1023.0-a)*10000.0/a;

var temperature=1/(Math.log(resistance/10000.0)/B+1/298.15)-273.15;

var value=Math.round(temperature*100)/100;

console.log(value);

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);

if(value>25.0)

{

lcd.clear();

lcd.setColor(255,0,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);
lcd.setCursor(1,3);
lcd.write("Its hot");

digitalPin5.write(1);

setTimeout(loop,500);

}

}

loop();

You can also vary the value of temperature sensor  variation of temperature value.When you hold the increase temperature sensor value, the temperature is increasing and when you keep it far from the sensor then the temperature is normal.Here I am showing temperature variation in screensort:

Image 28

                                     Fig:Temperature variations are displayed on the terminal

Temperature displays on the Putty is as follows:

Image 29

                                Figure : Temperature displays on putty

If temperature is crossed threshould value(25) then you can display a text message "Too hot" on the terminal.This is as follows:

Image 30

                               Figure : temperature indication through text on terminal

To get the above text indication we need to write  the following code :

JavaScript
if(value>25.00)

{

lcd.clear();

lcd.setColor(255,0,0);

lcd.setCursor(0,3);

lcd.write(" "+ds);

console.log("Too hot"); //to display on the terminal

lcd.setCursor(1,0);

lcd.write("Too hot"+ value);//to

digitalPin5.write(1);

}

I would like to add a Emoji image as a indication of temperature using the small change in coding.

This is the following output:

Image 31

                              Figure :  temperature indication with Emoji image

To get the above output we need to write the following code by small changes need to be done:

JavaScript
if(value>25.00)

{

lcd.clear();

lcd.setColor(255,0,0);

lcd.setCursor(0,3);

lcd.write(" "+ds);  //to dislay the current time

console.write("Too hot "+ '\uD83D\uDE2D'); //to display message with Emoji symbol

digitalPin5.write(1); //To on a buzzar

}

You can select any emoji image from the following link http://apps.timwhitlock.info/emoji/tables/unicode.On the page we got unicode values of Emoji images.click on unicode number we got the surrogate values.To display the particular Emoji image we need to write the value in the above maintioned way in the coding.

You can comine the above coding such as current date and time and temterature display with text and alarm notification.This is the combing code is as follows:

JavaScript
var mraa=require('mraa');
var jsUpmI2cLcd=require('jsupm_i2clcd');
var lcd=new jsUpmI2cLcd.Jhd1313m1(6,0x3E,0x62);
console.log('The mraa version is:' + mraa.getVersion());
var Analogpin0=new mraa.Aio(0);
var digitalpin5=new mraa.Gpio(3);
digitalpin5.dir(mraa.DIR_OUT);
var B=3975;

var avg=0;
var n=0;

var loop=function()
{

var analogvalue=Analogpin0.read();
var registance=(1023.0-analogvalue)*10000.0/analogvalue;
var temperature=1/(Math.log(registance/10000.0)/B+1/298.15)-273.15;
var value=Math.round(temperature*100)/100;
avg=avg+value;

lcd.setColor(0,255,0);

lcd.setCursor(0,12);

lcd.write(""+value);

lcd.setCursor(1,0);

var d=new Date();
d=d.getTime()-(d.getTimezoneOffset()*60000);
d=new Date(d+(3600000*5.5));
lcd.write(""+d);

var ds=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
lcd.write(ds);

lcd.setCursor(0,1);

lcd.write(""+ds);

if(value>35.0)
{

 lcd.clear();

lcd.setColor(255,0,0);

lcd.setCursor(0,3);

lcd.write(""+ds);

lcd.setCursor(1,0);

lcd.write("Too hot"+ value);

digitalPin5.write(1);

}

setTimeout(loop,500);

}

loop();

These are the  outputs:

When temperature is normal then smart clock displays current date time and temperature.This is the output.

Image 32

                                    Figure : normal smart clock

If temperature will cross the threshould value the smart clock display current time and "Too hot " message with value with red backcolor.This is the  following output.

Image 33

                              Figure : Temperature notification

Now if you want to send information mail to a specific Gmail id or the several ids then you can use the general code:

JavaScript
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt"><span style="text-decoration: none">var nodemailer = require('nodemailer');</span></font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">// create reusable transporter object using SMTP transport</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">var transporter = nodemailer.createTransport({</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">service: 'Gmail',</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">auth: {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">user</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">das25391890@gmail.com</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">',//</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">receiver mail id</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">pass: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">123456</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">'//</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">password of the above mail</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">}</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">});</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">v</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">ar mailOptions = {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">f</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">rom: 'sender address', // sender address </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">to: </font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">'das25391890@gmail.com'</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt"> ,// list of receivers </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">subject: 'Password Reset', // Subject line </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">html: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">Temperature is increasing do the needfull</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt"> : <b>' + temporaryPassword + ' </b>' // html body </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">};</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">transporter.sendMail(mailOptions, function (error, info) {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">if(error){</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">return console.log(error);</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">}</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">console.log(</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="3" style="font-size: 12pt">'Message sent:'+info.response</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="1" style="font-size: 8pt">);</font></font></font></code>

In the above code to send the mail I use nodemailer module.It is the easy to use module to send mail with node.js through SMTP , nodemailer is the windows friendly but you can use the nodemailer in the unix system also.To use the nodemailer module you need to install it with npm, with the following commands:

$ sudo apt-get install npm

$npm install nodemailer

$npm install googleapis --save

$npm install google-auth-library --save

You have to set the turn on access the less secure apps to the gmail addresss to receive the mail.

To send mail you need  a transporter object using SMTP transport,Which is used in the above code to specify the service provider,user and password.If the mail will be send successfully then message send is displayed otherwise error message displayed.In the above code the perticular message will be send to the specified das25391890@gmail.com mail id.

You can integrate the above send mail code with the temperature sensor using IOT application in such a way, if thetemperature is gradually increasing and it crossed the limit, then you can send a mail to the authorised person's gmail address.you can write the integrated code in such a way:

JavaScript
var mraa=require('mraa');

var jsUpmI2cLcd=require('jsupm_i2clcd');

var lcd=new jsUpmI2cLcd.Jhd1313m1(6,0x3E,0x62);

console.log('The varsion o0f mraa is:' + mraa.getVersion());

var AnalogPin0=new mraa.Aio(0);

var B=3975;

var digitalPin5=new mraa.Gpio(5);

digitalPin5.dir(mraa.DIR_OUT);

var loop=function()

{

var a=AnalogPin0.read();

var resistance=(1023.0-a)*10000.0/a;

var temperature=1/(Math.log(resistance/10000.0)/B+1/298.15)-273.15;

var value=Math.round(temperature*100)/100;

console.log(value);

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);

if(value>35.0)

{

lcd.clear();

lcd.setColor(0,255,0);

lcd.setCursor(0,1);

lcd.write("Temprature"+value);

digitalPin5.write(1);

}

setTimeout(loop,500);

}

loop();

<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt"><span style="text-decoration: none">var nodemailer = require('nodemailer');</span></font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">// create reusable transporter object using SMTP transport</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">var transporter = nodemailer.createTransport({</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">service: 'Gmail',</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">auth: {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">user</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">das25391890@gmail.com</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">',//</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">receiver mail id</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">pass: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">123456</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">'//</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">password of the above mail</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">}</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">});</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">v</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">ar mailOptions = {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">f</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">rom: 'sender address', // sender address </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">to: </font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">'das25391890@gmail.com'</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt"> ,// list of receivers </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">subject: 'Password Reset', // Subject line </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">html: '</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">Temperature is increasing do the needfull</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt"> : <b>' + temporaryPassword + ' </b>' // html body </font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">};</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">transporter.sendMail(mailOptions, function (error, info) {</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">if(error){</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">return console.log(error);</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">}</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">console.log(</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">'Message sent:'+info.response</font></font></font></code><code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">);</font></font></font></code>
<code class="western"><font color="#000000"><font face="Liberation Sans, sans-serif"><font size="2" style="font-size: 11pt">}</font></font></font></code>
 

In the above code if the temperature is crossed 35 then mail will be send to the specified gmail address.And on the terminal the following message will desplayed:

Image 34

                                          Fig : email send message on the terminal

This is the screen sort of the mail in the gmail address:

Image 35

                                            Fig:mail reveived into gmail address

 

Here is my combined final product a smart table clock.This make my desk smater.It displays current date and time,temperature notification and gmail notification.Step by step I am displaying  the product's different viewes.

Image 36

                Figure : Front view

Image 37

          Figure : Back view

Image 38  

          Figure : Side View

Image 39

      Figure :side view

   Image 40

                   Figure : 3D View

Image 41

 Figure : Pen stand with  current date time and normal temperature

Image 42

 Figure : Pen stand with current time and temterature text and alarm notification

Image 43

            Figure : Pen stand with time and mail notification for temperature

Try to make it according to your own way.It will make your desk smarter.

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Moumita Das
Software Developer Integrated Ideas
India India
No Biography provided

Comments and Discussions

 
PraiseInnovative Pin
Bhuvanesh Mohankumar11-Aug-16 7:53
MemberBhuvanesh Mohankumar11-Aug-16 7:53 
GeneralRe: Innovative Pin
Moumita Das11-Aug-16 16:03
MemberMoumita Das11-Aug-16 16:03 
GeneralMy vote of 5 Pin
Member 123643908-Aug-16 3:23
MemberMember 123643908-Aug-16 3:23 
GeneralMy vote of 5 Pin
Chrris Dale7-Aug-16 14:16
MemberChrris Dale7-Aug-16 14:16 
GeneralRe: My vote of 5 Pin
Moumita Das7-Aug-16 14:37
MemberMoumita Das7-Aug-16 14:37 
QuestionMore code explanation is needed Pin
Grasshopper.iics16-Jul-16 20:14
MemberGrasshopper.iics16-Jul-16 20:14 
AnswerRe: More code explanation is needed Pin
Nelek22-Jul-16 1:19
protectorNelek22-Jul-16 1:19 
AnswerRe: More code explanation is needed Pin
Moumita Das22-Jul-16 2:23
MemberMoumita Das22-Jul-16 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.