Introduction: Sensor Value Triggered SMS Alert Using LinkitOne

Picture of Sensor Value Triggered SMS Alert Using LinkitOne

Another great feature of the MediaTek LinkitOne development board is the support for SIM cards!
The opportunities of developing something really cool with the Linkit are endless.
In this instructable, let us look at how read sensor values and send a SMS alert to specified phone when the sensor values cross a threshold mark.

So let us get started!

Step 1: What You'll Need?

Picture of What You'll Need?

1. LinkitOne
2. SIM card
3. Sensor of your choice (here I will be using the Grove Kit sensors)

Step 2: Assembly

Picture of Assembly

The assembly for this project is pretty simple as you would have guessed already.
Just insert the SIM card in the slot on your Linkit One, connect your sensor and you are good to go!

Make sure you have an appropriate text messaging plan in your SIM before proceeding! :)

Step 3: The Code!

Let me explain what exactly the program should be doing.

As the project title states, the Linkit will send a text message to a specific number after a certain value on the analog sensor is crossed. So basically what we need to do is to write a program which reads the sensor value after specific periods of time and checks the value with a specified threshold. If the value crosses this mark, a pre defined SMS will be sent to the number given!

Sounds easy, doesn't it?

Let's code!

Make sure to include GSM and your sensor libraries. I have connected the Grove temp sensor which is based on DHT 22.

#include "LGSM.h"
#include "DHT.h"

#define DHTPIN 2 // what pin we've connected the temp sensor to
#define DHTTYPE DHT22 // DHT 22 (AM2302)

String message = "Attention! Temperature crossed 30 degrees Celsius.";

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(9600);
dht.begin();
while (!LSMS.ready()) // Wait for the sim to initialize
{
delay(1000); // Wait for a second and then try again
}
Serial.println("Sim initialized"); // When SIM is started, print "Sim initialized" in the serial port
LSMS.beginSMS("0123456789"); // Saves the number where user wants to send SMS. To be changed before uploading sketch
}

void loop()
{
float t = 0.0;
float h = 0.0;
LSMS.print(message); // Prepare message variable to be sent by LSMS
if(dht.readHT(&t, &h))

{
Serial.println("------------------------------");
Serial.print("temperature = ");
Serial.println(t);
Serial.print("humidity = ");
Serial.println(h);
}
int temp=(int)t;
if(temp>30)
{
if (LSMS.endSMS())
// If so, send the SMS
{
Serial.println("SMS sent"); // Print "SMS sent" in serial port if sending is successful
}
else
{
Serial.println("SMS is not sent");
// Else print "SMS is not sent"
}
}

else
{
Serial.println("Temperature not more than 30.");
}
delay(10000);

//make it wait for 10 seconds!
}

Step 4: Epilogue - Applications

This project has many real life applications.

It can be used in a cold chain truck to monitor temperatures.. Keep it in your house to monitor dust levels, if you are allergic to dust (like me :) ), or in your car if you are lending it to someone to keep a check on the speed and acceleration!

Just like I said, the possibilities are endless! :D

Comments

About This Instructable

1,097views

34favorites

License:

More by KedarP1:Sound Level Detector Using LinkIt OneMediaTek Sandbox Interfacing With LinkIt OneSensor Value Triggered Email on Linkit One Using GoBetwino
Add instructable to: