Before You Start
Since this tutorial uses the Arduino Yún, you’ll need to download and install the latest version of the Arduino IDE. Once you've got it, make sure that you have the latest version of the Temboo library for Arduino by going to the Sketch > Include Library > Manage Libraries... menu in the Arduino IDE, finding the Temboo library, and upgrading to the latest version as necessary.
You’ll also need to connect your Yún to the internet. If you need help with that, take a look at Arduino's excellent documentation.
Finally, go to the File > Examples > Temboo > ArduinoYun menu and run the CloudControlsConfig
sketch to prepare your Yún for running a Cloud Controls application. Now you're ready to start generating code!
Set Up Your Actuator
1Log in to Temboo. If you don't already have an account, you can sign up for free.
2Once you're logged in, go to our code generation tool and find the Gmailv2 > Messages > SendMessage Choreo. A Choreo is a cloud-based process that connects your Yún to any web-based service, and every Temboo application is associated with an least one Choreo.
3Select Arduino from the drop down menu at the top of the Choreo page, then select the Arduino Yún.
4The first step in remotely controlling an actuator is to specify what exactly you want to control, and which pin it's attached to on your development board. You do this via the interactive virtual board. For this tutorial, we're going to generate an application that controls the Yún's onboard LED associated with pin 13. If you'd rather control any other actuator, you can use that and still follow along.
Now, set up your actuator on pin 13 in the manner shown below.
5When you've created an actuator, you have the option to turn the actuator on or off, or modify its analog value, based on the output of the Choreo that your application is running. For example, in this case we could turn on/off our LED based on whether our email sent successfully. Since we're not focusing on running Choreos in this tutorial, we'll ignore this option for now, but it's worth noting this very useful option for when you need to trigger actions in the physical world based on virtual events.
Register your device
6While we were setting up our actuator on the virtual board, Temboo was generating all the code we need to remotely control the actuator from the browser. Now, we'll download that auto-generated application and try it out.
Scroll down and find the Code section. Click the gear icon and choose Compiled. Click the Download button that appears.
7Now, register your device. You can use whatever values you like to register your device, and then hit save.
Upload the .hex file and run the app
8To run the app on your Yún, find the downloaded .zip
file and extract the contents (hint: the file name will contain the ID of the device your just registered). Locate the .hex
file within - this is the compiled version of the application that you just set up via our website.
9Next, open a terminal window and we'll run some commands to upload the .hex
file to your Arduino Yún. Here's a good intro to running shell commands if you need help.
We'll begin by using the SCP command to copy the compiled application to your Yún. In the command below, make sure to substitute in the name of your .hex
file in place of the your_app
placeholder. If you're on a network with more than one Arduino Yún you should use your Yún's IP address instead of arduino.local
. You can find the IP address for your Yún in the Tools > Port menu of the Arduino IDE.
When you've edited the command as necessary, navigate to the location of your .hex
file and run your command. Remember, unless you've changed it, your Yún's password is arduino.
scp your_app.hex root@arduino.local:/tmp
Next, SSH into your Yún by running the command below. Again, swap in your IP address in place of arduino.local
as necessary. If you need help getting started with SSH on the Yún, Arduino have instructions specific to the Yún that will tell you what you need to know.
ssh root@arduino.local
Once you've gained access to your Yún via SSH, run the following command to merge your sketch with the boot loader. Make sure to swap in your .hex
file name in place of the your_app
placeholder value.
merge-sketch-with-bootloader.lua /tmp/your_app.hex
Finally, run this command to program your microcontroller to run the application (again, swap in your .hex
file in place of the placeholder value). With the application running on your Yún, you're ready to check out your sensor data graphs and remotely control your Yún.
run-avrdude /tmp/your_app.hex
Remotely Control Your Device
10Now that your Cloud Controls app is running on your Yún, head over to your Devices page to see it in action. A virtual representation of your device will be waiting for you.
11Select the device that you registered and you'll be taken to the controls for that device. Go ahead and hit the button and you'll see two things happen - the red LED on your Arduino Yún will turn on, and your browser will update to reflect the state of your actuator.
That's it! You now know how to remotely control actuators from your browser with Temboo. The process that we just covered for the Yún's LED applies to any other type of actuator, meaning you're just a few steps away from making something extraordinary. With Temboo handling all the small stuff, you're free to think big.
Need help?
We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.