-
1Step 1
The first thing you'll need to do is set up the Intel Edison. There are a number of very comprehensive guides scattered around the Internet on how to do that. This one in particular is my favourite if you plan to develop many more applications on your Edison.
http://www.instructables.com/id/Absolute-Beginners...
However, in the interests of thoroughness, I'll go over some basic procedures here as well.
- Download the Intel Edison Drivers ( https://software.intel.com/en-us/iot/hardware/edis...)
- Connect your Intel Edison to your PC using the J3 and J15 micro USB ports
- Start the Driver setup and follow the instructions given
Now you've completed the basic setup for your Edison. Now we'll get to configuring your Edison to your WiFi at home.
- Go to Start Menu >> Device Manager >> COM (Ports and LPT)
- There will be a device labelled "USB Serial Port". Note the COM number written in brackets in front of it.
- Open PuTTY and start a session with the following parameters
- COM Port = (Number you noted down)
- Baud Rate = 115200
- Click "Open"
- Hit Enter twice and type in "root" when prompted
- Type in "configure_edison --setup"
- Follow the instructions to set your password and WiFi. It will show you the IP address of your Edison when you're done.
- To test the connection type in "ping www.google.com". If you see that Google is returning your pings, your Edison is connected to the Internet!
-
2Step 2
For every sentry, you're going to need a watchful eye that is capable of capturing images.
Good news is, you don't need to buy an expensive camera or camcorder! You can make one using an old Android phone lying around the house! Just make sure its running an Android version post 2.3.4 Gingerbread.
I'll be using an old Sony Xperia Play that was catching dust in my drawer. It shipped with a snazzy little dock onto which it sits pretty comfortably and so I don't have to worry about propping it up!
What you're going to want to do is install an app called IP Webcam on your old Android device from the play store from the following link;
https://play.google.com/store/apps/details?id=com....
Once you're done, make sure you're connected to your home wifi network and open up IP Webcam and scroll to the bottom.
Select "Start Server" and note the IP address that appears near the bottom of the screen.
It should look something like "http://192.168.x.xxx:8080";To check if your camera is connected to the network, open up a browser on your computer and type in the IP address you saw on your phone including the 8080 at the end.
The tab will be named "IP Webcam", and you should see a number of options regarding the video recorder.
Select the "Browser" button in front of the "Video Renderer" option and you should see a live stream of the video on your Android device!Alright! Now that you've configured your sentry, let's see how we can get it to send image data to the Internet!
-
3Step 3
In order to communicate with a Twitter account, we will need some credentials. These credentials are stored by Twitter in keys which it allows developers to use for their apps. To get your keys, do the following;
- Go to https://apps.twitter.com and select "Create New App"
- Fill in your app details like its name and description. In the Website field, you may put in a dummy webpage. Agree to the conditions and hit "Create your Twitter Application"
- Once your application has been created, go to the "Permissions" tab and select "Read,Write and Access
direct messages" and hit "Update Settings" - You can check your keys in the "Keys and Access Tokens" tab. Scroll down and click on "Create my Access Token"
- Once the tokens have been created, make note of;
- Consumer Key
- Consumer Secret
- Access Token
- Access Token Secret
Great work! Now you've configured Twitter to send and receive data from your account!
-
4Step 4
Now, what we essentially want the Intel Edison to do is;
- To keep checking your Twitter feed for any command
- Once it gets a command, to get a photograph from your Android Ward
- To upload that photograph as a reply to the command.
To talk to our Edison, we are going to use Python. It's an open source language with lots of resources and a growing pool of users. It is also very easy to learn and understand. So let's get started!
Python uses files known as libraries to pick and choose between the tools it needs to execute a certain code. The aim of our code is to upload a photograph taken by our sentry Twitter every time we tweet "Click!" to our handle.
To do that, we are going to use a library called Tweepy. Tweepy is basically a collection of files which makes sending and receiving data from Twitter to Python much easier. So in order to install Tweepy on your Edison, you'll have to do the following steps;
- Open PuTTY and SSH into your Edison as described in the Tutorial
- Type in "sudo pip install tweepy"
- Wait for the package to install, and you're good to go!
In order to get the image from the Android Ward, we also need to have a Python library which can handle images. A very popular library which does that is calledOpenCV.
To install OpenCV, you need to follow the same procedure as for Tweepy, except that instead of "sudo pip install tweepy", you type in "opkg install opencv"
Awesome! Now you've made sure that your Edison has all the tools it needs to handle images and send them to Twitter!
-
5Step 5
Download the code attached to this step, and fill in the following parts with your own keys and access codes;
- consumer_key
- consumer_secret
- access_token
- access_token_secret
Also fill in your own camera IP in the indicated field along with your Twitter handle
Once you've written this code, save it as "tweetpic.py"
Now, open up FileZilla and connect to your Edison.
In the left pane, navigate to the location where you saved your script. Right click on it and click on upload. The Transfer bar on the bottom should indicate a successful transfer.Once that is done, open the PuTTY terminal and type in python tweetpic.py
Great! Now your Edison is constantly sniffing your Twitter feed for commands!
-
6Step 6
Now for the fun part!
Go to your Twitter account and tweet "@(your Twitter Handle) Click!"
Wait for a few moments, till you get a notification. Is it what you think it is?
Yes!
Your Edison has successfully read your command, processed it, then it grabbed a photograph from your Android Ward and uploaded it as a reply to your tweet!
Congratulations!
You now have a fully functioning IoT Ward which allows you to look at what's happening at home from anywhere in the world!
-
7Step 7
Now, you'll be preparing your very own light sensor which allows the Edison to detect if the lights around it are on or off!
For that, you'll have to do a little soldering, or if you aren't sure about it, you can build the circuit on a breadboard as well!
Arrange the components as shown, and solder them according to the circuit diagram.Please make note of the supply voltage and ground pins.
What the photoresistor does, is that it varies its voltage according to the light incident on it, and thus voltage changes can be tracked when it is connected in series with another resistor. The configuration of our circuit reflects in the fact that the voltage increases with an increase in incident light.
Once you've built the circuit, use the jumper wires to connect the sensor to the breakout board as follows;
- Connect the supply terminal of the sensor to the 5V on the board
- Connect the ground terminal to the GND terminal of the board
- Connect the output terminal of the sensor to the A0 terminal of the board
Cool! Now your Edison has a sensor to detect any changes in the light around it!
-
8Step 8
Now, in order to get the Edison to work as a security system, you'll have to change some code that you've fed to it. To do that, just use the attached code, and upload it to the Edison, just as you did in the earlier step.
Use the attached code, named tweetint.py.
Once you've done that, it's time to test your new security system!
Open up a PuTTY terminal, and use the command python tweetint.py
Now switch off the lights in the room, and open up your Twitter account.
Now if your Twitter Handle is say; "chucknorris", tweet the following message "@chucknorris Start!"You should see a message on your PuTTY Terminal saying "Security System started!"
Now, switch on your lights.
You should get a photograph as a reply to your tweet on Twitter!
All Done? Great!
Congratulations! You've built your very own home made security system that you can use to detect any unwanted presence in your house!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.