Project tutorial
Secure YUN

Secure YUN

In this project I am trying to use amazon SQS and IOT services with temboo and arduino YUN to detect intruders.

  • 1 comment
  • 12 respects

Components and supplies

Apps and online services

About this project

Updated for 2019 China-US Young Maker Competition

The project revolves around building a messaging interface for the arduino yun incorporating Amazon AWS services for detecting intruders . For a beginner like me, it was quite difficult to get the AWS quickly. So I relied on the temboo services which are actually very easy to get and learn. It offers choreos from a lot of different services like youtube and khanacademy. Having said that I particularly used it to communicate with the arduino yun. I used the Amazon SQS and IOT services to send messages to my arduino yun which was retrieved on the serial console of the arduino yun. The yun is particularly impressive in this regard. The Yun is very easy to setup and operate.


Arduino Yun

PIR Motion sensor

Getting started with YUN

Install the Arduino IDE 1.5.4 or later from this link :

Yun can be easily configured to connect to your local network. Connect the new arduino yun to the computer and wait for a minute for the yun to boot. When you first start the Yun, it will create a WiFi network called ArduinoYun-xxx. Connect to this network.

Once you've obtained an IP address, open chrome, and enter http://arduino.local or After a few moments, a web page will appear asking for a password. Enter "arduino" and click the Log In button.

Press configure and in the consequent webpage enter the required details like password and credentials of your wifi network basically the SSID, password and network security type.

Save the changes and reboot.

Configure Temboo

Now connect to your local wifi network and enter http://arduino.local/ to confirm if the arduino is connected to the network. When the arduino is connected move on to the next part temboo :

Create a temboo user account and login.

In the left side choose the Amazon choreo. In the amazon services choose the SQS services.

Configure AWS SQS

Now move to the AWS IOT page to create a free AWS account.

Complete the account registration and move to the Security Credentials under the dropdown on your username.

 Download the Key file and save it for future reference.

Change the region on the upper right corner of the AWS account near the username to U.S. East. Among the Services dropdown choose SQS from Application services. Create a new queue. Give your queue a name and ignore the rest of the details. 

Configure AWS IOT (Windows)

Download the AWS-IoT-Arduino-Yún-SDK zip package and extract it from here :

Download Putty and WinSCP from and

Download AWS IOT CA file from here. Move the AWS IOT CA file, private key and certificate into certs folder of the Arduino Yun SDK. With WinSCP upload the certs and file to the root directory of Yun. ssh into the yun and execute :

opkg update

opkg install distribute

opkg install python-openssl

easy_install pip

pip install paho_mqtt

Copy the AWS-IOT-ARDUINO-YUN-LIBRARY to the arduino libraries folder in My Documents. Restart the arduino IDE and the examples will appear in the IDE.

Send the Message

In the SendMessage choreo turn on the IOT mode and connect the Arduino Yun to the computer.

In the Send Message choreo choose "Is this choreo triggered by a sensor event?" and choose Digital pin 0 to be the trigger event so that when pin 0 is high the choreo is run and the message is sent. Connect the PIR motion sensor to the Arduino Yun's VCC, GND and D1 of the sensor to pin 0 of the Yun. 

Now fill the Input fields AWSAccessKeyId with the Access key Id and AWSSecretKeyId with the Secret Access Key. Fill the AWSAccountId with your account ID from account settings. For the message body insert "Intruder detected". The QueueName field should be filled with the name of the new queue created in the Configure AWS field. Run the choreo and download the code.

Uploading the Sketch

Download the Sketch and the header file representing your temboo account, make necessary changes and compile. Upload the sketch on the arduino yun .

When any intruder is detected in front of the PIR motion sensor the D1 signal is high, the port 0 is triggered and the choreo is run. Open the serial monitor and you will get the message "Intruder detected".    

For AWS IOT create an instance of the aws_iot_mqtt_client through :

aws_iot_mqtt_client inst1;

Then load the configuration in setup() and connect like :

if((x = inst1.setup(AWS_IOT_CLIENT_ID)) == 0) {


if((x = inst1.connect()) == 0) {

success_connect = true;

Now subscibe to a topic and then publish messages as in :

myClient.subscribe("topic", 1, msg_callback);

myClient.publish("topic", msg, strlen(msg), 1, false);

In this way the Intruders detected can be monitored from the AWS IOT platform.


#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information   

// 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 = 0;

void setup() {
  // For debugging, wait until the serial console is connected
  // 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 SendMessage Choreo...");
    } else {
      Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");

void runSendMessage(int sensorValue) {
  TembooChoreo SendMessageChoreo;

  // Invoke the Temboo client

  // Set Temboo account credentials

  // Identify the Choreo to run

  // Run the Choreo
  unsigned int returnCode =;

  // Read and print the error message
  while (SendMessageChoreo.available()) {
    char c =;
Header FileArduino
IMPORTANT NOTE about TembooAccount.h

TembooAccount.h contains your Temboo account information and must be included
alongside your sketch. To do so, make a new tab in Arduino, call it TembooAccount.h,
and copy this content into it. 

#define TEMBOO_ACCOUNT ""  // Your Temboo account name 
#define TEMBOO_APP_KEY_NAME ""  // Your Temboo app key name
#define TEMBOO_APP_KEY ""  // Your Temboo app key

The same TembooAccount.h file settings can be used for all Temboo SDK sketches.  
Keeping your account information in a separate file means you can share the 
main .ino file without worrying that you forgot to delete your credentials.




Similar projects you might like

Secure Your Home by a Password

Project tutorial by يمنى السيد ندا

  • 3 respects

Ultrasonic Map-Maker using an Arduino Yun

Project tutorial by Satyavrat Wagle

  • 171 respects

IoT Home Security Model

Project showcase by Aaron Kow

  • 197 respects

Plant Monitoring System using AWS IoT

Project tutorial by CJA3D

  • 87 respects

Yun Light

Project tutorial by Tony ZHANG

  • 25 respects

Secure Package Delivery Trunk for Your Front Porch

Project tutorial by Team Castle Locker

  • 24 respects
Add projectSign up / Login