I bet as a child you tried at least once if you can move objects with your thoughts and hand movements like a Jedi knight... Well, I tried but of course with no success. My followers probably know that I am a huge Star Wars fan, and the Star Wars universe or the SW Saga inspired a few projects that I shared with you. This time we are going to build a home automation system that is working only with hand gestures.
You will be able to control your TV, your house lights, your toaster, your charger... Everything, just like a Jedi knight (or a Sith, I don't know which side do you prefer).
And now you are probably thinking how is this even possible but don't worry I am here to explain you all that you need to build this project. If you think it is interesting just read each step carefully and then you can start your own project. Don't worry if you are a beginner I am sharing schematics, codes and full explanation on how to build it. We will learn to code in JavaScript and Arduino and some C language.
I am going to show you how to make applications on a Pebble smartwatch, it is very simpe... I hope will also teach you some new tricks in Arduino. We will use an Arduino like microcontroller, the Particle Photon that has an on-board WiFi module. I found some great insipration in TVMillers's project.
Now let's get started!
Step 1: VideoIn this short video I am going to show you how this device actually works. I am not a native speaker sorry for my very accent, but I hope you like it. I explain the theory behind my device and how to make it yourself. Don't forget to watch it in 1080p.
Step 2: The Idea - Being Able to Use the ForceI think that even those who don't really like the Star Wars series like the idea of moving objects only with your thoughts. I wanted so bad to make this real and then I started thinking then one day the idea came in like a lightning. I could use my smartwatch as a gesture sensor...
But what is the Force?
After Wookipedia: "The Force was an energy field that connected all living things in the galaxy. The power of the Force could be used by individuals who were sensitive to it, a power that was tapped through the midi-chlorians." You can give your girlfriend fruits and move warships with the Force, but for me is the most majestic and beautiful movie element ever used. Let me explain why. It made my childhood richer and I think if you read this as a Star Wars fan you can say the same thing. Fighting with wooden rods thinking they are lightsabers is one of the the best things in my life. I bet you have memories like this. This is why we all love this mysterious thing... The "Force" gave us so many good experiences.
"It’s an energy field created by all living things. It surrounds us and penetrates us; it binds the galaxy together." - Ben Kenobi
Read more here: http://www.starwars.com/news/6-great-quotes-about-...
Now that we now more about the Force, it's time to learn some science.
Step 3: How It Works?In JavaScript programming language I made a relatively simple application on my Pebble smartwatch, that I bought last year and really like to use it. It is probably one of the most elegant smartwatches no the market and it is programmable so you can make any application on it. And also made a program on my Particle micro-controller that actually controls our home.
To make it clear:
- The Accelorometer in the Pebble Smartwatch detects special hand gestures.
- Via Bluetooth the watch transmits signals to the phone.
- The phone sends signals to a web address.
- The Particle Photon reads signals with its WiFi module.
- Depending on what signal he gets controls the TV, lights, toaster...
Why do we need home automation?
For me one of the most annoying things is when I have to walk to the other corner of my room just to turn off the lights before I sleep. With this gadget and IoT things get a lot easier.
How easy is to make it?
It is not a beginner's project but I am going to explain how the codes and the circuits work. It is not that hard, we will learn some JavaScript and Arduino.
How easy is to use it? What is so special about it?
I designed a SmartPlug basically. (That is smarter than the average.) All you have to do is plug in your device in a wallplug then wait until it is connected and make hand gestures. You will be able to turn on your TV or lights and switch channels, then turn them off. It is so simple to use. Don't worry it will never happen that you accidentally control something, because I made a build-in filter in the code.
Why do I use Particle Photon?
The Particle Photon is an Arduino-like microcontroller, with the same price and the size of an Arduino Mini Pro but has an on-board WiFi module that makes everything so much easier.
If you decided to make this project please be careful, we will be working with high voltage.
Step 4: What Is Pebble?Pebble (https://www.pebble.com/) is one of the worlds best smartwatch brands. I think they are making the most elegant watches worldwide with amazing e-Paper screens and extra-long battery life. The reason why is my No. 1 smartwatch is that it is open source so you can do many stuffs with it.
What happened to them? Does it still worth to buy a Pebble?
Ufortunately Pebble went bankrupt... That is probably because their bad growing or marketing strategy, but I am not sure about why did they fail. You can still buy Pebble watches from Amazon and their servers are still functioning, so the project works fine, just makes me sad that such an amazing company ended up like this. I bought my Pebble Time Steel a few months ago and love it. You can see the PTS update at the bottom of the article.
Step 5: Based on One Sensor - What Is an Accelerometer?In this project we will learn how to use an accelerometer in a smartwatch. I did a documentation on the Development Guide I found a good description about the accelerometer. An accelerometer is a device that measures proper acceleration; proper acceleration is not the same as coordinate acceleration (rate of change of velocity). For example, an accelerometer at rest on the surface of the Earth will measure an acceleration due to Earth's gravity, straight upwards (by definition) of g ≈ 9.81 m/s2. By contrast, accelerometers in free fall (falling toward the center of the Earth at a rate of about 9.81 m/s2) will measure zero.
Actually is a tiny chip that can detect acceleration in 6 directions, this is more than enough for us to create this project, because we can detect a few special gestures this way. What makes a gesture detectable? If you take a look on how the Jedi knights move their hands you can figure out what physical forces affect on that. I just had to make a program for it.
Let me show what do you need for this project!
Step 6: Gathering Parts and ToolsI can't say that this is the cheapest project that I have ever made, but the truth is that I had all parts at home, and most of them is salvaged from old electronics. The Particle Photon costs $19 and the Pebble watch only $39.95 on the Amazon so I can say that is relatively cheap. You can use any version of Pebble watch, but I am using the basic model, that I like the most. Everything else is salvaged. You will also need some soldering and crafting tools.
Tools:- Soldering Iron
- Solder
- Third Hand Safety Gloves (optional)
- Rotary Tool
- Glue Gun
- Smartphone
- 230/110v connector male and female (depending on where do you live)
- Some Wires
- Plastic Case
- PCB - Premade
- Header Pins
- 230V to 5V adapter (salvaged from old phone charger)
I gave Amazon purchase links for three components. Everything else is salvaged from old electronics but you can buy them from a local hobby shop. As you see the hardware parts in this project is simple, but we will have to suffer a little bit with progamming... (Well you don't, you just have to copy + paste, I had to suffer.)
Step 7: Using the Pebble Cloud IDECoding is easy on the Pebble Cloud IDE... In this step I teach you how to begin a project.
First download the Pebble phone app:
Then pair your smartwatch with it. (I am using Android) Go in the app settings, and enable Developer Connection. Voila, now sign in to your Pebble account here: https://cloudpebble.net/ide/. And create a new project. Go to the next step to find out how to make a project.
Step 8: Starting a ProjectPress "Create" button to make a new project and you will be redirected to a page like me on the second picture. On the APP SOURCE part you can find the code. Copy-paste here the code that I will share in the next step. At the RESOURCES you can add pictures and icons to make your app look much better. I actually used a selfmade pixel Darth Vader.
See the project files in the next step.
Step 9: Project FilesDownload the ZIP file below and import in your Cloud Pebble. Now you actually made an application. You can add other images or icons. See up there. If you want to, chech out the code. Feel free to use but don't forget to credit. Compile in JavaScript.
<p>//Project created by Tamas Imets for Jedi Home Automation Project</p><p>var Accel = require('ui/accel'); //enabling accelerometer
Accel.init();
var UI = require('ui');
var ajax = require('ajax');
var Vector2 = require('vector2');</p><p>// Create Window
var main_window = new UI.Window();</p><p>// Open Button and Display
var txtOnLabel = new UI.Text({
position: new Vector2(0, 60),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'USE THE FORCE',
textAlign: 'center',
color: 'white'
});</p><p>//making text
var info = new UI.Text({
position: new Vector2(2, 90),
size: new Vector2(142, 60),
font: 'Gothic 14',
text: 'Move your hand like a Jedi to control objects, lights and your home...',
textAlign: 'center',
color: 'white'
}); </p><p>//adding image
var image = new UI.Image({
position: new Vector2(0, 8),
size: new Vector2(144, 50),
alignImage: 'center',
image: 'images/negativevader.png'
});</p><p>// Display Main Window
main_window.backgroundColor('black');
main_window.add(txtOnLabel);
main_window.add(info);
main_window.add(image);
main_window.show();</p><p>// URL To Particle Cloud
function Toggle(function_name,function_value){
var URL = 'https://api.particle.io/v1/devices/your code/' + function_name +'?access_token=your token';</p><p> ajax(
{
url: URL,
method: 'post',
type: 'json',
data: { "args": function_value}
}
);
}</p><p>// Accelerometer Poll and Function (Default 100Hz 25)
//Different Gestures
Accel.on('data', function(e) {
console.log(e.accel.z);
if (e.accel.z > 1200) { //if I make this gesture...
if(e.accel.y > 200) {
if(e.accel.x < 400) {
Toggle('jedi','pull'); //send this signal
}}}});</p><p>Accel.on('data', function(e) {
console.log(e.accel.x);
if (e.accel.x > 700) {
Toggle('jedi','push');
}});</p><p>Accel.on('data', function(e) {
console.log(e.accel.y);
if (e.accel.y > 1200) {
if(e.accel.z < -200) {
if(e.accel.z < 100) {
Toggle('jedi','throw');
}}}});</p><p>// Button Function and Photon Parameters
main_window.on('click', 'up', function() {
Toggle('jedi','pull');
});</p><p>main_window.on('click', 'select', function() {
Toggle('jedi','push');
});</p><p>main_window.on('click', 'down', function() {
Toggle('jedi','throw');
});</p>
Step 10: Particle Web IDEIn this project you can program from the internet. Isn't that awesome? All you have to do is to plug in your circuit, your Particle Photon in a 5v source and with the help of the Particle phone app (https://play.google.com/store/apps/details?id=io.p...) connect to your local WiFi. This is very easy... Create a Particel account here: https://build.particle.io/build/ and you can start coding. It is the same as Arduino but with a better user interface with online libraries and etc...
Step 11: Writing the CodeI am sharing the code with you here. Copy and paste to your project file then "Verify" and after this press "Flash". And you are actually done. Now your system should work. The tutorial did not allowed me to paste my code here so please download this.TXT file. I have used a SAMSUNG TV so the commands and those long numbers are only available for Samsung TV users. If you have a different TV just Google it: "xyz brand arduino tv remote codes".
Step 12: Testing the Codes - Making a PrototypeIn this project we use digital pin D1, D7 and D6 on the Particle Photon. Build a circuit using LEDs to test if the code is working properly. At this point parts should connect to each other wirelessly with no problem. Make Force movements like I did in the video and if the relay switches on at D7 that means you did a good work. Congratulations! Now we have to make it useful and user friendly.
Step 13: The CircuitI made this circuit in Fritzing and I haven't found a normal AC adapter, but that Hi-Link module does the same thing that our salvaged phone charger does. Following this schematic and the next steps build the circuit.
Step 14: SolderingAs the schematics shows solder the wires to a piece of PCB that has two lines of header pins soldered to it. Plug in your Particle Photon to test if it fits correctly. After this you can solder a wallplug connector to the 5v adapter circuit, just like I did. Just take apart an old smartphone charger and you will find a circuit like this for free. This way you don't have to work so much with dangerous voltages. These are very well designed circuits, it is safe to use.
Step 15: Making a CaseI found this plastic case in project inventory and its size seemed to be perfect! Not too small and not too big. It is the same size like a laptop charger. I used my rotary tool to cut one hole for the 230v input voltage and one for the 230v output voltage on next to the input connector. Cut another 5MM hole for the IR LED that controls your TV.
Step 16: Final ProductWith some glue gun I fixed all parts inside the project box so it is safe to use. You can open the plastic case anytime but if it is plugged in never try this! ONLY UNPOWERED! I can say that looks great and needs small space. From now just plug in your device to a connector and then wait until your Particle's LED has a light blue color.
Step 17: TestingPlug in your gadget and connect a lamp to it for example. Make a hand movement and wait until switches ON or OFF. If everything works enjoy it!! From now you can enter your like a Sith or a Jedi. Just make a Force pull and your light will b turned on!
Step 18: Use the Force!Enjoy your new ability! The smartwatch's battery lasts for about three days with intensive use and charges up in one hour. From now you can use your smart-plug with no external wires or other embarrassing things. You will have a simple and elegant system, I really like to use...
Step 19: Thank You Very Much for Watching!I really hope you enjoyed my project tutorial, it would make me very happy if I succeeded to show you something mind-blowing. Follow my tutorials page for more projects like this. Huge thanks for Basa András who made the filming and the editing of this video.
If all goes well next time we will build intelliegent drones!
May the Force be with you!
Step 20: 2018 Update!I just bought a new Pebble, because I liked my previous watch so much. Everything should work fine. Install the Pebble app like you normally would.
Thanks again for reading! If you have any questions feel free to ask!
Comments