ThingSpeak

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

TimeControl App

TimeControl works with other ThingSpeak™ apps to perform an action at a specific time or on a regular schedule. You can use

  • TimeControl with ThingHTTP to communicate with devices, websites, or web services

  • ThingTweet to send alerts via Twitter®

  • TalkBack to queue up commands for a device

For example, you can make a ThingHTTP request that calls someone via Twilio®, controls a device, or connects to a thermostat that accepts HTTP requests.

    Note:   The number of Time Controls is limited to 12 per user.

TimeControl App Introduction

The TimeControl app triggers MATLAB Analysis, ThingHTTP, ThingTweet, or TalkBack apps at a specific future time or at recurring times. Specify an action before you schedule it using the TimeControl app. For example:

  • Trigger MATLAB® Analysis to act on your data.

  • Make a ThingHTTP request that calls someone using Twilio's HTTP-based API.

  • Send tweets at specified times.

  • Add commands to TalkBack to your devices, and trigger them to act at specific times.

Schedule Actions with TimeControl

  1. Sign into ThingSpeak.

  2. Select Apps > TimeControl.

  3. Click New TimeControl.

  4. Edit TimeControl settings:

    • Name: Enter a unique name for this TimeControl.

    • Time Zone: The time zone is based on your account settings. To change this, click edit.

    • Frequency: Choose whether TimeControl runs once or at recurring intervals.

    • Recurrence: Choose a recurrence pattern.

      • Week: Every week day specified

      • Day: At a specified time daily

      • Hour: At a specified hourly interval

      • Minute: At a specified minute interval

    • Time: Enter the time at which TimeControl runs.

    • Fuzzy Time: Select the number of minutes around a scheduled time for TimeControl to run.

    • Action: Select the action to trigger when the specified parameters are met.

      • MATLAB Analysis: Run scheduled code.

      • ThingHTTP: Connect to a web server and read or write data.

      • ThingTweet: Tweet to a specified Twitter account.

      • TalkBack: Queue commands to send to your device.

Execute a TimeControl

ThingSpeak servers automatically execute TimeControls at the specified time, based on your time zone. Make sure that your time zone is correctly specified in your ThingSpeak profile.

    Tip   TimeControls run in strict 24-hour cycles. Modify your TimeControls to account for Daylight Saving time changes.

Time Control Replacements

TimeControl can trigger other ThingSpeak apps. Use replacement keys to access time data and channel values to replace values in a ThingHTTP body or a ThingTweet message.

Time Data

  • %%datetime%%: The full date and time, for example: 2014-09-24 5:32 p.m.

  • %%day%%: The name of the weekday, for example: Wednesday

  • %%day_index%%: The zero-based index of the weekday starting on Sunday, for example: 3

  • %%hour%%: The hour of the day, for example: 5 p.m.

  • %%minute%%: The minute of the day, for example: 32

  • %%time%%: The time of the day, for example: 5:32 p.m.

Last Channel Value

To retrieve the last value from a ThingSpeak channel field, include the following in a TimeControl form field:

%%channel_CHANNEL_ID_field_FIELD_NUMBER%%

For example, to retrieve the last value from Channel 1417, field 1, use:

%%channel_1417_field_1%% 

Update Channel Status Using ThingHTTP

This example shows how to update a ThingSpeak channel "field1". In this example, a TimeControl triggers a ThingHTTP request to update channel data at a specified time with a status message and timestamp.

Create a ThingHTTP Request

In ThingHTTP, enter the name ThingSpeak Channel Updater with these parameters:

  • URL: http://api.thingspeak.com/update

  • Method: POST

  • Body:

    api_key=THINGSPEAK_WRITE_KEY&field1=TimeControl%20test&status=Executed at %%time%%.

Create a TimeControl

Name the TimeControl, and enter these parameters:

  • Check the One Time box.

  • Select today's date.

  • Select an hour and minute in the near future.

  • Select ThingHTTP as your action.

  • In the then perform ThingHTTP field select the ThingHTTP you created to trigger this TimeControl.

  • Save the TimeControl.

At the specified hour and minute, verify that your channel updates automatically.

TimeControl App with MATLAB Analysis Code Errors

When you have MATLAB Analysis code that uses a TimeControl, TimeControl stops running if there are a number of consecutive errors in the MATLAB Analysis code. You can choose to receive an alert via email by checking the box Notify me via email if this MATLAB Analysis fails when triggered by TimeControl or React in the MATLAB Analysis app.

Was this topic helpful?