Sensor Value Triggered Email on Linkit One Using GoBetwino

by KedarP1 in Circuits > Sensors

841 Views, 7 Favorites, 0 Comments

Sensor Value Triggered Email on Linkit One Using GoBetwino

share.jpg

Hello!
If you are new to Gobetwino, it would be beneficial to go through by previous instructable on the same. Here's the link: https://www.instructables.com/id/LinkitOne-Sensor-D...

So as you know by now, GoBetwino is a tool for Windows platform which acts on commands received through your Serial print commands through Arduino based platforms.

As the title suggests, this project sends an email to a specified email ID when a threshold value of a sensor is crossed.
I have made an instructable for implementing the same using SMS on your MediaTek LinkitOne here: https://www.instructables.com/id/Sensor-Value-Trigg...

Mail Server Config

gobet1.png

Let us set up the GoBetwino with our email config.

  1. Open GoBetwino
  2. Click on Settings in the top menu bar and Go to 'mail' tab
  3. In the mail section, configure your mail server settings and add an email account
  4. Click on 'Update' and then close this window.

Command Config

gobet2.png

In the previous step, we setup the mail server and account that GoBetwino will use to send mails.
Now we will setup the command it will respond to.

  1. Go to the 'Commands' section in GoBetwino.
  2. Click on 'New Command'
  3. Select command type 'SMAIL'
  4. Here, 'Command Name' is a very significant field because this is what the LinkIt One should send via Serial.
    Enter a command name like 'SENDMAIL' (all caps, without quotes).
  5. Enter the email ID you want to notify in the 'To' field.
  6. Enter the subject, body and attachment (if any).
  7. Click on Save and then Exit.


    Now GoBetwino will send this email whenever it receives the command SENDMAIL through Serial Port.

Setting Up the LinkIt One

C360_2015-12-16-23-08-24-904.jpg
C360_2015-12-16-23-19-52-341.jpg

Now that we have setup the GoBetwino, let us move on to configure the LinkIt One!

What this project does (as I have specified previously too) is reads sensor values, compares it with a specified value and then if the current sensor value crosses this threshold, it sends an email using the command we have specified previously.

To implement this, I am using the DHT 22 temperature and humidity sensor of the Grove kit.
Whenever the temperature crosses my threshold of 30 degrees celsius, it will Serial print our Command.

The Setup
Setting up the Linkit One is pretty easy here, just connect your sensors and connect LinkIt to your PC.
Done!

Code!

We have established the logic in previous step, now let us implement it using the Arduino code!

#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

#define DHTTYPE DHT22 // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(9600);
dht.begin();
}

void loop()
{
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float t = 0.0;
float h = 0.0;
int temp = (int)t;

if(dht.readHT(&t, &h))
{
Serial.println("------------------------------");
Serial.print("temperature = ");
Serial.println(t);
Serial.print("humidity = ");
Serial.println(h);
}
if(temp>30)
Serial.println("#S|SENDMAIL|[]#"); // send email if temp is greater than 30 degree Celsius

delay(80000);
}