Quickstart: Configure rules and actions for your device in Azure IoT Central

In this quickstart, you configure an IoT Central rule. IoT Central rules let you automate actions that occur in response to specific conditions. The example in this quickstart uses accelerometer telemetry from the phone to trigger a rule when the phone is turned over.

In this quickstart, you:

  • Create a rule that detects when a telemetry value passes a threshold.
  • Configure the rule to notify you by email.
  • Use the smartphone app to test the rule.

Prerequisites

Create a telemetry-based rule

The smartphone app sends telemetry that includes values from the accelerometer sensor. The sensor works differently on Android and iOS devices:

When the phone is lying on its back, the z value is greater than 9, when the phone is lying on its front, the z value is less than -9.

  1. To add a new telemetry-based rule to your application, in the left pane, select Rules.

  2. To create a new rule, select Create a rule.

  3. Enter Phone turned over as the rule name.

  4. In the Target devices section, select IoT Plug and Play mobile as the Device template. This option filters the devices the rule applies to by device template type. You can add more filter criteria by selecting + Filter.

  5. In the Conditions section, you define what triggers your rule. Use the following information to define a single condition based on accelerometer z-axis telemetry. This rule uses aggregation, so you receive a maximum of one email for each device every five minutes:

    Field Value
    Time aggregation On, 5 minutes
    Telemetry Acceleration / Z
    Operator Is less than
    Aggregation Minimum
    Value -9

    Screenshot that shows the rule condition.

  6. To add an email action to run when the rule triggers, in the Actions section, select + Email.

  7. Use the information in the following table to define your action and then select Done:

    Setting Value
    Display name Your phone moved
    To Your email address
    Notes Your phone is face down!

    Tip

    To receive an email notification, the email address must be a user ID in the application, and the user must have signed in to the application at least once.

    Screenshot that shows an email action added to the rule

  8. Select Save. Your rule is now listed on the Rules page.

Test the rule

Shortly after you save the rule, it becomes live. When the conditions defined in the rule are met, IoT Central sends an email to the address you specified in the action.

To trigger the rule, make sure the smartphone app is sending data and then place it face down on your desk. After five minutes, IoT Central sends you an email to notify you that your smartphone is face down.

After your testing is complete, disable the rule to stop receiving the notification emails in your inbox.

Next step

In this quickstart, you learned how to create a telemetry-based rule and add an action to it.

To learn more about integrating your IoT Central application with other services, see: