Android Core

IoT project: Arduino sends push notification to Android using Temboo,

This post describes how to create an IoT project that uses Arduino to send push messages to Android smart phones using Temboo and As example, we will build an alarm system based on Arduino and Android, this is an interesting example of Internet of things (IoT) and the aim of this project is building an alarm using an infrared sensor (PIR) connected to Arduino board that sends push messages to Android smart phone. This project mixes different technologies and platforms and we make them working together!

The alarm system uses two platforms that help simplyfing the project:

  • Temboo 

IoT Project overview

Before diving into the project it is useful to describe these two platforms.

Temboo is a platform that has a set of “connectors” that can be used to exchange data with other platforms or service providers (i.e eBay, Yahoo! Weather, Google and so on). The interesting part of Temboo is that it is compatible with
Arduino board, so that these connectors can be exported on Arduino. is the platform we used in the last post to send android push messages.

The main overview of the internet of things project is shown below:


As it is clear, there are several parts that build the IoT project. The first part is Arduino board with PIR sensor that is used to detect movements. Arduino runs a Temboo agent that sends data to Parse platform. This agent is triggered when one of the Arduino digital input gets HIGH. The Temboo platforms is used to create the agent without writing too much code lines. Using Temboo choreo, Arduino can send JSON data directly to that in turns send a push message to our smart phone.

Arduino Sketch

The first step is setting up the Arduino sketch that uses PIR sensor and test it. This step is very simple, we have to connect the sensor to Arduino board using three wires: Power, Ground and Signal.

The sensor is very simple, the output gets high when it detects movements. For this example we can suppose it is connected on digital pin 8.

To check that our sensor works correctly and it is connected in the right way to Arduino board so that it detects movements,  try to load this code into arduino:

int stato = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(8, INPUT);

void loop() {
  // put your main code here, to run repeatedly:
  stato = digitalRead(8);


Now runs the code and move your hand in front of the sensor and give a look at the serial monitor to check if it works!

Now the Arduino component is ready!

Temboo choreo

The next step is setting up the agent that connects Arduino board to In this case, we need a Ethernet shield to connect Arduino to internet. I’ve used Wiznet W5500. Once you have created your account, it is time to configure your Temboo chores. We want to connect Arduino to Parse so we check Parse -> Push Notification. Parse choreos requires some information before using it:

  • Application ID
  • RestAPI Key

These two parameters are used to connect the agent to You can find these info in

Schermata 2015-09-14 alle 21.36.51

You have to copy the required key into Temboo:


Ok we are ready. If you want you can try to send a notification from Temboo to

Now set the trigger that control the agent:

Schermata 2015-09-21 alle 22.03.45

At the end Temboo will create the Arduino code ready to use!! finally copy and paste the code into your Arduino IDE.

The code generated by Temboo is shown below:

#include <dhcp.h>
#include <dns.h>
#include <ethernet.h>
#include <ethernetclient.h>
#include <temboo.h>
#include "TembooAccount.h" // Contains Temboo account information

byte ethernetMACAddress[] = ETHERNET_SHIELD_MAC;
EthernetClient client;

// The number of times to trigger the action if the condition is met
// We limit this so you won't use all of your Temboo calls while testing
int maxCalls = 10;

// The number of times this Choreo has been run so far in this sketch
int calls = 0;

int inputPin = 8;

IPAddress ip(192, 168, 1, 130); // Arduino IP Add

void setup() {
  // For debugging, wait until the serial console is connected

 Ethernet.begin(ethernetMACAddress, ip) ;


  // Initialize pins
  pinMode(inputPin, INPUT);

  Serial.println("Setup complete.\n");

void loop() {
  int sensorValue = digitalRead(inputPin);
  Serial.println("Sensor: " + String(sensorValue));

  if (sensorValue == HIGH) {
    if (calls < maxCalls) {
      Serial.println("\nTriggered! Calling SendNotification Choreo...");
    } else {
      Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");

void runSendNotification(int sensorValue) {
  TembooChoreo SendNotificationChoreo(client);

  // Set Temboo account credentials

  // Set profile to use for execution
  // Set Choreo inputs
  String NotificationValue = "{\"channel\": \"temboo\", \"type\": \"android\", \"data\": {\"message\": \"This is a test alert!\"}}";
  SendNotificationChoreo.addInput("Notification", NotificationValue);

  // Identify the Choreo to run

  // Run the Choreo
  unsigned int returnCode =;

  // Read and print the error message
  while (SendNotificationChoreo.available()) {
    char c =;

Configure channel and build Android app

Temboo requires we use a Parse channel to send our notifications. We have then to modify our Android app to use a channel to listen to incoming notification. If you don’t know how to write an android app that handles push messages you can read my previous post describing how to send android push messages with

Modify slightly the in this way:

    public void onCreate() {
        Parse.initialize(this, "sfFzOxotpsdOHWJE3nMmD0erLgFoecttKvC9CzIc", "nwbMEy7l4STpyNrABdrQxpEjdKIynSbuec56QbEz");


where temboo is the channel.

We are ready!! Runs the app and move your hand near the sensor, Arduino will send a push message to the Android smart phone!!

The final result is shown here:


At the end of this post, you know how to build an IoT project using Arduino and Android and how to integrate these two ecosystems through Temboo and

Want to know how to develop your skillset to become a Java Rockstar?

Join our newsletter to start rocking!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Francesco Azzola

He's a senior software engineer with more than 15 yrs old experience in JEE architecture. He's SCEA certified (Sun Certified Enterprise Architect), SCWCD, SCJP. He is an android enthusiast and he has worked for long time in the mobile development field.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button