This tutorial is originally created by AdrianFer.
Fortunately enough, there are tools available that make it easy for developers to rapidly prototype their own solution using the TI LaunchPad development tools
In this tutorial, I'll walk you through how to create your very own Internet-connected flower pot moisture sensor that will send you a text message when your plant needs water!
Here's what you'll need
Here's a quick video on how to plug everything together! In this tutorial, we will have the Grove Moisture sensor connected to pin 23 of the
Now that our hardware is ready to go, let's switch our focus to the software. In this case, we will be using Energia to write our firmware. Energia offers a simple API for reading analog inputs, called analogRead() that we will be using. Fortunately enough, Energia offers a nice example that we can use to simply print out our raw analog readings to its built-in Serial Monitor.
You can find this example at FILE > EXAMPLES > BASIC > ANALOGREADSERIAL
Next, we need to tell Energia which board we want to compile this code to. We can select the appropriate LaunchPad board by navigating to: TOOLS > BOARD > [Select your board. In my case, I am using MSP430F5529 LaunchPad (25MHz)]
We will also need to tell Energia which Serial/COM port our LaunchPad is connected to. typically it is the last one on the list available at TOOLS > SERIAL PORT > [Select your serial port. Check your device manager if you are unsure]
Here's a quick video on how to use Energia to read the analog values coming from your moisture sensor:
At this point, our hardware should be reading moisture sensor data from the Grove moisture sensor. Now, that we have this baseline functionality, let's figure out how to interact with the cloud to trigger a text message. To do this, we are going to leverage Temboo.
You can learn more about Temboo at www.temboo.com/hardware/ti
You will need to sign up for a Temboo account. We are also going to need a Twilio account, since this is the web service that we will use to trigger our text message. You can get one at www.twilio.com.
TI has collaborated with Temboo to provide a seamless development experience for enabling internet-connected hardware to interact with various websites & web services. In this case, we are going to use Temboo to generate Energia code that will allow our LaunchPad to send a text message using the Twilio web service.
Temboo makes it really easy to generate the right Energia code by simply asking for a few parameters from the developer. Once the Energia code is generated, we can simply copy & paste the code into Energia to be compiled & flashed into the LaunchPad.
Here's a video that demonstrates how easy it is to generate Energia code:
Now that we have the Temboo-generated code, we can copy-and-paste it intoEnergia. Temboo generates both an application sketch as well as a TembooAccount.h file, which includes all of our Temboo and WiFi credentials. We can copy and paste both of these files into Energia & can flash this into the LaunchPad. At this point, our LaunchPad will trigger a text message every 30 seconds. Without writing any code, Temboo makes it really easy to enable our LaunchPad to interact with various cloud services; in this case, Twilio for triggering SMS messages.
Here's a video of our LaunchPad sending a text message with the help of Temboo and Twilio:
At this point, we have all of the required components for pulling together our application - we are successfully reading moisture sensor values from the Grove Base BoosterPack and Moisture sensor AND we are able to successfully send text messages with the help of Temboo and Twilio. Now, we need to tie these pieces together. In short, all we really need to do is encapsulate the Temboo-generated code in an if-statement. That way, we will only trigger off the text message when the if-statement condition is met. In our case,we only want to trigger the text message when the analogRead(23) function returns a value that is passed a certain threshold. In our case, we only want to send a text message when the moisture sensor returns a reading of 0, indicating that no water is present.
Here's a video of how we combined the two code examples to build our complete application:
With this tutorial, hopefully you were able to see how simple it can be to use modular hardware to rapidly prototype a complete Internet of Things application using easy-to-use and intuitive software tools. With these components, it becomes much simpler to enable real-world hardware to interact with the cloud.
So go ahead and get started!