iotapp-soil-quality-monitor [] [] {"id":"soil-quality-monitor","title":"Soil Quality Monitor: Build IoT applications to monitor soil quality","metaDesc":"Build a connected soil monitoring system that sends alerts when the soil is dry and lets you automate and remotely control watering from a mobile device.","tweet":"I'm building an #IoT soil quality monitoring system with @temboo, and you should too!","device_count":"single","devices":{"arduinoyun":"Arduino Y\u00fan","samsung_artik_ten":"Samsung ARTIK 10","samsung_artik_five":"Samsung ARTIK 5"},"description":"We've created a system that has both an automated recurring watering schedule, and senses moisture level to allow remote control of sprinklers, ensuring that crops receive the right amount of water without waste.","categories":["environment","farming"],"choreos":{"GetNextEvent":{"uri":"Library\/Google\/Calendar\/GetNextEvent","templateName":"GoogleCalendar","credentialDescription":"View calendar, event, and settings metadata, and create and update calendars and calendar events.","description":"Retrieves the next upcoming event in a Google calendar based on the current timestamp and the specified calendar's timezone setting.","credentialInputs":[{"name":"ClientID","type":"string","description":"The Client ID provided by Google. Required unless providing a valid AccessToken.","placeholder":"123myClientId","callout":"Save your API Credentials to with use any Google Calendar Choreo in the Library."},{"name":"ClientSecret","type":"string","description":"The Client Secret provided by Google. Required unless providing a valid AccessToken.","placeholder":"mySecretKeyId"},{"name":"RefreshToken","type":"string","description":"An OAuth Refresh Token used to generate a new access token when the original token is expired. Required unless providing a valid AccessToken.","placeholder":"myRefreshToken"}],"inputs":[[{"name":"CalendarID","type":"string","description":"The unique ID for the calendar with the next event to retrieve.","placeholder":"calendarID","callout":"Our board will turn the water on for the duration of the next event in the calendar."}]]},"SendEmail":{"uri":"Library\/Utilities\/Email\/SendEmail","templateName":"UtilitiesEmail","credentialDescription":"Sends an email using a specified email server.","description":"Sends an email using a specified email server.","credentialInputs":[{"name":"Username","type":"string","description":"Your username for your email account.","placeholder":""},{"name":"Password","type":"password","description":"The password for your email account.","placeholder":"myPassword123"}],"inputs":[[{"name":"FromAddress","type":"string","description":"The name and email address that the message is being sent from.","placeholder":""},{"name":"Port","type":"integer","description":"Specify the port number (i.e. 25 or 465).","placeholder":"465"},{"name":"Server","type":"string","description":"The name or IP address of the email server.","placeholder":""},{"name":"Subject","type":"string","description":"The subject line of the email.","placeholder":"Soil moisture levels are low.","callout":"When the moisture level is too low, an email alert will be triggered."},{"name":"ToAddress","type":"string","description":"The email address that you want to send an email to.","placeholder":""}]]},"StoreToken":{"uri":"Library\/Utilities\/TokenStorage\/StoreToken","description":"Stores a token.","inputs":[[{"name":"Name","type":"string","description":"The token name associated with the first motor.","placeholder":"MySprinklerPump"},{"name":"Value","type":"string","description":"The token value associated with the first motor.","text":"off","callout":"This value can be changed from an iOS app, and will be used to remotely control the state of the water pump."}]]}},"oauthWizard":{"title":"Obtain a Refresh Token","subtitle":"for use with Google Choreos","oauthBundle":"\/Library\/Google\/OAuth\/","steps":[{"title":"Populate your<br \/>Credentials","description":"<p>Copy the Client ID and Client Secret provided by Google, and paste them below.<\/p>","inputs":[{"name":"ClientID","type":"string","placeholder":"The client ID provided by Google when you register your application."},{"name":"ClientSecret","type":"string","placeholder":"The client Secret provided by Google when you register your application."},{"name":"Scope","type":"hidden","value":"https:\/\/\/auth\/calendar"}]},{"title":"Grant&nbsp;Authorization<br \/>from Google","description":"<p>Visit the URL below, or click \"Launch Authorization\" to grant Authorization from Google.<\/p>","authorization":true,"inputs":[{"name":"AuthorizationURL","type":"string","text":"","fromOutput":true}]},{"title":"Voila!<br \/>Your Refresh Token","description":"","templateName":"GoogleOAuth","inputs":[{"name":"ClientID","type":"string","fromOutput":true},{"name":"ClientSecret","type":"string","fromOutput":true},{"name":"RefreshToken","type":"string","fromOutput":true}]}]}}

Nurturing crops on a large-scale farm can require time consuming testing of soil quality. We've created a system that has both an automated recurring watering schedule, and senses moisture level to allow remote control of sprinklers, ensuring that crops receive the right amount of water without waste.

We'll show you how you can build it.

Moisture Sensor
Like this soil hygrometer
12v Pump
We used this one
TIP120 Transistor
iOS Device
Requires iOS 8.3 or higher
We used potting soil


  • 12v battery pack
  • 8 AA batteries

First, Log In or Sign up with Google.

Create a new Calendar. You can call it Watering Schedule or anything you'd like.

Add a repeating watering event. Your board will retrieve events from this calendar to determine when the water should be turned on.

Create a New Project from the Google developers console.

Enable the Calendar API. This will allow your board to retrieve the next watering event from the calendar.

Add an OAuth 2.0 client ID credential. You may be prompted to configure a consent screen where you'll need to save a Product Name. Specify Web Application, then use the line below as the Redirect URI.

Find your Calendar ID in Calendar Settings in the Calendar Address section.

This application uses your board's local time when calculating Google Calendar dates. To ensure accuracy, your board's timezone should be set to UTC.

Connect the power and ground of your board to your breadboard.

When our sensor value is higher than 1.0 our moisture level is too low, and will trigger an email alert indicating when the next watering will be.

We'll add some smoothing to our data in the final code by looking at the average of the last 100 readings.

Connect the first pin of your moisture sensor to

Connect the third pin of your moisture sensor to ground, and the fourth to power.

The pump can be turned on and off via the iOS app which will change the value of the Token we set earlier.

When moisture levels are low, and an alert is sent, the board will retrieve the Token value for instruction on what to do with the pump.

Connect the ground of the water pump to the Collector pin of the TIP120 Transistor.

Connect the Base pin of the TIP120 Transistor to

Connect the Emitter pin of the TIP120 Transistor to ground.

IMPORTANT! Never connect the positive side of the 12v power source to your board. If connected improperly, your board will have a new career as a door stop.

Connect the ground of the 12v power supply to the same ground as your board.

Connect the positive end of the 12v power supply to the rail with the power end of the pump.

Need help running the code?
Need help running the iOS code?

Install for Samsung ARTIK

If this is the first time using Temboo, you'll need to set up your ARTIK board to find the Temboo libraries. To do so, you'll need to create the file temboo.conf in /etc/ Inside of temboo.conf, you'll want to copy the line below and paste it into the file:


After saving temboo.conf, run ldconfig from the command line to add the Temboo library directory to the system library search path.

You’ll also need to get the IP address of your ARTIK board using ifconfig. The example below shows the results when the ARTIK board is connected to the internet through an ethernet cable. The IP address you'll want to use is listed next to inet.

[root@localhost ~]$ ifconfig
eth0: flags=4163  mtu 1500
inet  netmask  broadcast

Run the code

Download and unzip the IoT Application file. In your IoT Application folder, you'll find a Samsung folder containing the SoilQualityMonitor folder with code for the Artik. Copy the Samsung folder to your ARTIK board using scp. From your computer, go to the directory where the Samsung folder is located and type the command below. Make sure you use the IP address for your board you found using ifconfig.

[root@localhost ~]$ scp -r SoilQualityMonitor

Now cd into the directory on your Artik where you placed the folder and and compile and run your code using the command below.


Need help?

We're always happy to help. Just email us at, and we'll answer your questions.

Install for TI LaunchPad

Open the .ino file with Energia. While the sketch is running, open the Serial Monitor and you should see your app running.

Congratulations! Now that you know how to make your LaunchPad run any Choreo, you're just a few steps away from making something extraordinary.

You can find more examples of how to use Temboo with your LaunchPad here.

Need help?

We're always happy to help. Just email us at, and we'll answer your questions.

Run the Sketch and rejoice

Save and upload your sketch to the Arduino Yún, and open the serial monitor.

Congratulations! You've just run an IoT Application. With Temboo handling all the small stuff, you're free to think big.

You can find lots of examples of how to use Temboo with your Yún here.

Need help?

We're always happy to help. Just email us at, and we'll answer your questions.

Running the iOS Application

Make sure you have the latest Xcode, which can be downloaded here.

Download the Code

Download the code at the link above.

Unzip the files where you can find them. You should see one folder containing the iOS code, and another containing the hardware device code.

Open the Xcode Project

Locate the .xcodeproj file in the iOS code. Open the file with Xcode and you should see all of the accompanying files in the Project navigator.

If the file titles in your Project navigator are red, you'll need to relink them by clicking control and selecting "Add Files to ", then select and add all of the files from the iot application folder contained in the iOS folder you downloaded. Control click and delete any of the unlinked files that appear in the Project navigator.

Download the iOS SDK

The latest Temboo iOS SDK can be downloaded here. Save and unzip it to a folder where you can find it.

Once again, you'll need to control-click on the top-level folder in your Xcode Project navigator. Select "Add Files to " and browse to where you saved the Temboo SDK, locate and click on the "core" folder inside the SDK "src" folder. Make sure that "copy items if needed" is unchecked and "Create groups" is selected, then and select "Add".

Repeat the above steps to add the appropriate files located in the SDk's src/library folder.

Run the App

Make sure you have a device selected in the simulator, and click the run button.

Congratulations! You should see the app displayed in the simulator window. Go ahead and try it out, and you should see the Choreo results printed to the console.

Need help?

We're always happy to help. Just email us at, and we'll answer your questions.