Lesson 4: Text Message

While logging data is great for science experiments, most security application require somebody to be notified in the event a sensor registers an abnormal value. This can be done by adding another function to your Google spreadsheet. Add the following function below your doGet function:


Code Breakdown
  • Line 10 should be your 10 digit phone number followed by the domain your carrier has set up for users to send text from email. Verizon customers would use something like 0123456789@vtext.com.
  • Line 11 is the subject. In the future you will customize it.
  • Line 12 is a simple message. In the future you will add sensor data.
  • Line 13 actually sends the email.
Authorize
Before you are able to send a text message, you will need to publish your app again. You will be prompted to authorize additional permissions, specifically the ability to send an email.

Send a Text Message
To test your function, choose your sendText function from the drop down menu.

Then click the run button. It will take a few seconds before you receive the text message.
 

Now you need to figure out how to send a text message when the temperature(or humidity) reaches a certain level.

To not spam yourself, you need to set some kind of flag that prevents the if statement from running over and over. Here is some example code that you can implement to the code that you already have.

Put this code idea into your ARDUINO code.

int flag = 0;

if(condition is triggered & flag = 0) {
flag = 1;
run the rest of the function

} else if(condition not triggered & flag = 1)
 flag = 0;
}




Comments