Main Content

Detect People with Notification from IFTTT on Android Devices

This example shows how to use the HTTP Client block from the Simulink® Support Package for Android® Devices to trigger an HTTP request to IFTTT for any person detected and send push notification to any smart phone with IFTTT application.

IFTTT (if this then that) is an external web service that lets you create applets and act in response to a trigger action. You can configure the IFTTT Webhook service to create web requests to trigger an action. In this example, the camera from your Android device detects people. This even acts as an incoming action to trigger an HTTP request to the web server. The outgoing action is a notification on your smart phone having IFTTT application.


For more information on how to use the Simulink Support Package for Android Devices to run a Simulink model on your Android device, see Getting Started with Android Devices.

Required Hardware

Android device, such as a phone or tablet

Create IFTTT Applet

1. Create an IFTTT account if you do not already have one. Log in to your account.

2. Create an applet. Select your user icon and then click Create.

3. Select the input action. Click the word this.

4. Select the Webhooks service. Enter Webhooks in the search field. Select the Webhooks card. After you select Webhooks as the trigger, click the Receive a web request card to continue.

5. Complete the trigger fields. Enter an event name. This example uses people_detect as the event name. Click Create Trigger.

6. Select the resulting action. Click the word that. The trigger word this is now the Webhooks icon.

7. Enter notification in the search bar and click the Notifications box. Then select Send a notification from the IFTTT app.

8. Click Create action to finish the new applet. For this example, the name of the event is people_detect. IFTTT will pass this name of the event where the variable {{EventName}} occurs in the message. You can also pass data about the event that triggered your message using ingredients. For example, including {{OccurredAt}} adds the event time to your notification.

9. Retrieve your Webhooks trigger information. Select My Applets > Services, and search for Webhooks. Select Webhooks, and then click Documentation. You see your key and the format for sending a request. Enter the event name. The event name for this example is people_detect.{event}/with/key/XXXXXXXXXXXXXXXXXXXXXX

9. You can test the service using the test button or by pasting the URL into your browser. Note that the IFTTT event trigger is not always instantaneous.

Configure Simulink Model and Calibrate Parameters

Open the androidPeopleDetect Simulink model.

The example uses the Camera block to capture video frames from the back camera of an Android device. The Detection subsystem takes in the video frame to create a bounding box around the people detected in the video frame. Double-click Subsystem. Configure the event name and API key from the IFTTT applet as input parameters to the Compose block. Every time a person is detected, the Subsystem is enabled. The HTTP Client block triggers the HTTP request to IFTTT and sends a notification to your Android device.

Deploy Simulink Model on Android Device

1. On the Hardware tab of the Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start. The androidPeopleDetect application launches automatically.

2. Point the Android device camera towards people and observe the bounding box with the label around the detected people. You will receive a notification on your Android device.

See Also

Read and Write to ThingSpeak Channel Using Android HTTP Client Block