[Arduino Etheret -W5100 Project] Hey You!! Get Away From My Home!!!
[Arduino Etheret -W5100 Project] Hey You!! Get Away From My Home!!!
0
Components
Hardware componentsUltrasonic sensor for measure distance
x 1
IRLED
x 1
Twitter account
x 1
TEMBOO & GOOGLE account
x 1
Project description
- Check every 1sec what body there is or not with ultrasonic sensor
- If there is a body, turn on the TV to make trespasser frighten with IRLED
- Send twitter message to me for alram & send a google email using Temboo with Ethernet Shield
Step 1: What We Need for This Project
- Arduino Uno
- Arduino Ethernet Shield
- Ultrasonic sensor for measure distance
- IRLED
- Prototyping PCB for making "ultrasonic & IRLED" shield
- And several pin headers and registers.
Step 2: Circuit of This Project (Fritzing)
- Arduino ethernet shield is stack on Arduino uno.
- Ultrasonic sensor connect to pin #7 of Arduino uno.
- IRLED connect to pin #3 of Arduino uno with 100ohm register.
Step 3: Complete Making Hardware of This Project
- Preparing electric parts for making shield (ultrasonic sensor, IRLED, pin header, 100 ohm, color cable)
- Soldering
Step 4: Preparing Software of This Project (Flowchart)
- Setup : Initialize (Ethernet setting, Twitter account setting, TEMBOO & GOOGLE account setting, IRLED & Ultrasonic sensor pin setting)
- Check distance by ultrasonic sensor.
- Compare measured distance with initial distance.
- If measured distance is not initial distance we can assume that there is a trespasser.
- Turn on TV for alram and frighten tresspasser by IRLED
- Send twitter message to my account
- Send google email to me and/or my family.
- How to control IRLED to turn on the TV
- How to send twitter message from Arduino
- How to send google email from Arduino through TEMBOO
Step 5: How to Control IRLED to Turn on the TV
/*
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
void loop() {
if (Serial.read() != -1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
}
}
Do you know how to install new library can be use in Sketch?
Just unzip file and copy to your arduino installed directory (ex : ../arduino-1.0.5-r2/libaries/)
Then you can use this library like as already installed other libraries.
Attachments
Step 6: How to Send Twitter Message From Arduino
- Make a/more twitter account to receive a tweet message from Arduino.
- Get a token to post a message using OAuth
- Download attatched twitter library and install like as IRLED library to your Arduino installed directory
- Run below sample sketch to tweet.
#if defined(ARDUINO) && ARDUINO > 18 // Arduino 0019 or later
#include <SPI.h>
#endif
#include <Ethernet.h>
//#include <EhternetDns.h> Only needed in Arduino 0022 or earlier
#include <Twitter.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
Twitter twitter("<<< your token here >>>");
char msg[] = "Hello, World! I'm Arduino!";
void setup()
{
delay(1000);
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("connecting ...");
if (twitter.post(msg)) {
int status = twitter.wait();
if (status == 200) {
Serial.println("OK.");
} else {
Serial.print("failed : code ");
Serial.println(status);
}
} else {
Serial.println("connection failed.");
}
}
void loop()
{
}
Attachments
Step 7: How to Send Google Email From Arduino Through TEMBOO
- Make google account. [Make Google account]
- Need a google App-specific password that generated after 2-Step Verfication. [Google App-specific password setting]
- Download attatched TEMBOO library and install like as IRLED/Twitter library to your Arduino installed directory
- Make TEMBOO accout first [TEMBOO accout]
- There are many APIs already prepared by TEMBOO. We will use "send google email" API in this project, so we have to go [Google > Gmail > SendEmail]
- [Important] And you have to select "IoT Mode [ON]" which is located in top/right with yellow charactor.
- And test send email with fillout pink box and click Run. (See Picture)
- We can see the Arduino sketch source code for send gmail from TEMBOO as below
- Now we can use TEMBOO for send gmail
/* Setup shield-specific #include statements */
#include <SPI.h> #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; int numRuns = 1; // Execution count, so this doesn't run forever int maxRuns = 10; // Maximum number of times the Choreo should be executed
void setup() { Serial.begin(9600); // For debugging, wait until the serial console is connected. delay(4000); while(!Serial); Serial.print("DHCP:"); if (Ethernet.begin(ethernetMACAddress) == 0) { Serial.println("FAIL"); while(true); } Serial.println("OK"); delay(5000); Serial.println("Setup complete.n"); } void loop() { if (numRuns <= maxRuns) { Serial.println("Running SendEmail - Run #" + String(numRuns++)); TembooChoreo SendEmailChoreo(client); // Invoke the Temboo client SendEmailChoreo.begin(); // Set Temboo account credentials SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT); SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); SendEmailChoreo.setAppKey(TEMBOO_APP_KEY); // Set Choreo inputs String MessageBodyValue = "Message what you want to send"; SendEmailChoreo.addInput("MessageBody", MessageBodyValue); String SubjectValue = "subject of email"; SendEmailChoreo.addInput("Subject", SubjectValue); String PasswordValue = "generated_password"; SendEmailChoreo.addInput("Password", PasswordValue); String UsernameValue = "youraccount"; SendEmailChoreo.addInput("Username", UsernameValue); String ToAddressValue = "destination_address@abcdef.com"; SendEmailChoreo.addInput("ToAddress", ToAddressValue); // Identify the Choreo to run SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail"); // Run the Choreo; when results are available, print them to serial SendEmailChoreo.run(); while(SendEmailChoreo.available()) { char c = SendEmailChoreo.read(); Serial.print(c); } SendEmailChoreo.close(); } Serial.println("nWaiting...n"); delay(30000); // wait 30 seconds between SendEmail calls }
["TembooAccount.h", Header file]
/*
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" // Your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // Your Temboo app key name
#define TEMBOO_APP_KEY "1eb4e************************39a61" // Your Temboo app key
#define ETHERNET_SHIELD_MAC {}
/*
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.
*/
Attachments
Step 8: Complete Arduino Sketch Source Code for This Project
- IR remote library
- Twitter library
- TEMBOO library for send gmail
Attachments
Step 9: RUN Arduino to Know Existance of Trespasser
Documents
-
Arduino-IRremote-master
-
Library-Twitter
-
temboo-arduino-sdk
-
irremode_tweet_temboo_release.ino
















