Introduction: 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?
2. SIM card
3. Sensor of your choice (here I will be using the Grove Kit sensors)
Step 2: 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?
Make sure to include GSM and your sensor libraries. I have connected the Grove temp sensor which is based on DHT 22.
#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);
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
float t = 0.0;
float h = 0.0;
LSMS.print(message); // Prepare message variable to be sent by LSMS
Serial.print("temperature = ");
Serial.print("humidity = ");
// If so, send the SMS
Serial.println("SMS sent"); // Print "SMS sent" in serial port if sending is successful
Serial.println("SMS is not sent");
// Else print "SMS is not sent"
Serial.println("Temperature not more than 30.");
//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
We have a be nice policy.
Please be positive and constructive.