Temboo and Arduino Yún Workshop


Purpose

This workshop is designed to introduce participants to the programming of Arduino Yúns using Temboo. The target audience includes people with all levels of experience with Arduino, but who are not familiar with Temboo. This lesson plan includes basic examples from the Temboo website to help participants understand how Temboo’s integration with Arduino works and what can be done with an Arduino board using Temboo’s software, and also allows time for participants to tackle more challenging projects of their own choosing.

Time

This workshop will take between 1.5 and 2 hours, depending on how comfortable participants are with wiring Arduinos and how enthusiastic they are about tackling complicated projects of their own at the end.

Materials

Required

  • Arduino Yúns (1 per person)

    One per person is ideal, but there should be at least one for every three people.

  • Micro USB cables (1 per Yún)
  • Laptops (1 per Yún)

    Ideally, every participant will simply bring his or her own.

  • Ethernet cables (1 per Yún)

    These are not strictly necessary because the Yún is WiFi-enabled, but they can make connecting to the Internet go more smoothly in some cases. It is also good to bring a couple of USB to Ethernet adaptors for those whose computers do not have Ethernet ports.

  • LEDs (1 per Yún + a few spares)
  • Sensors (1 per Yún + a few spares)

    Sensors that can return a range of values (e.g., photo, proximity, and temperature sensors) are better than sensors that return only two values (e.g., push-button and motion sensors), but it is good to have a mix of both if possible.

  • Resistors (as needed for each sensor and LED)

    Remember to calculate the required resistance for your sensors and LEDs.

Optional

  • Breadboards

    Bring a couple in case some participants are more comfortable with wiring breadboards or are building more complex circuits.

  • Wires

    Bring a spool and cutters or a few pre-cut jumper wires to go with the breadboards.

  • Camera or other interesting hardware components

    These are fun for advanced participants who are quickly ready to do something more complex than turn on an LED.

Class Size

The workshop is best with a small group (15 – 20 people maximum). Ideally, there will be about 1 instructor or knowledgeable helper for every 5 participants.

Opening

10 Minutes

1[Optional]
Use IoT Mode to set up a Yún with a button that will send an SMS when pressed; that can be done here. You will need a Twilio account for the demo, which you can set up here. As participants come in, invite them to save their phone number in the Profile you are using and then press the button to send themselves a “Welcome” text message (assure them that you are not keeping their phone numbers!). As an alternative, you can send an email instead of a text message if you do not want to create a Twilio account or are concerned about soliciting phone numbers.

2Project a slide instructing the participants to:

Introduction

15 Minutes

3Let the participants take 10 minutes to get everything set up, and go around the room helping where needed.

4Offer a brief overview of the workshop and its goals, which are:

  • Get the Yún and Temboo set up.
  • Work through some basic examples to become familiar with the setup.
  • Work on more complicated ideas of participants’ choosing at the end.

5Introduce participants to Temboo

  • Show the Temboo Library page.
  • Explain that Temboo is a library of APIs, databases, and code utilities, and show some of the supported APIs on the Library page.
  • Point out the different programming languages that you can generate code for, and mention that for this workshop, the Wiring language (used by Arduino and based on C/C++) will be used.
  • Explain that Temboo runs processes (called “Choreos”) on the cloud and generates 5 – 6 lines of code needed to call those processes from a program, which makes it an ideal tool for programming a memory-constrained, Internet-connected device like an Arduino Yún.

6Introduce participants to Arduino

  • Ask how many people have used Arduino before to gauge familiarity.
  • Explain that Arduino is an open source MCU platform developed to introduce people to hardware programming.
  • Note that Arduino manufactures several boards, including the WiFi-compatible Yún, which we will be using for the workshop.

7Demonstrate the Temboo “turn on the light with your phone” example

  • For this demo, you will trigger a phone call from your Yún, and use your phone to turn on a light on the Yún.
  • Attach a sensor (a button will be sufficient for this) and an LED to your Yún.
  • Use IoT Mode to generate a sketch that will make a phone call in response to whatever type of sensor you have hooked up to your Yún; you can do this here. For this, you will need a free Nexmo test account, which you can set up here.
  • Copy the sketch and header file into the Arduino IDE.
  • In the sketch, directly after the digitalWrite command that turns on the LED, you can add some code to turn off the LED after a 5 second delay. Be sure to replace "PIN_NUMBER" with the number of the pin to which the LED is attached.
    delay(5000);
    digitalWrite(PIN_NUMBER, LOW);
    

  • Upload and run the sketch.
  • Ask for someone in the audience to volunteer his or her phone number. Plug the number into the Profile you have created in IoT Mode, save the Profile, and trigger the call with the sensor.
  • Ask for another phone number from the audience, put it into the Profile, and re-save the Profile. Point out that the sketch is still running, and that thanks to the Profile, you don’t need to re-upload it after changing the number; you can show that the serial monitor is still collecting values from the sensor as you change the phone number in the Profile to illustrate this.
  • Trigger the call again.

8Take questions if there are any.

Set Up the Yún

10 Minutes

9Plug in the Yún and open the Arduino IDE. If anyone didn’t finish installing the IDE at the beginning of the workshop, that should be done now.

10In the Arduino IDE, go to Tools > Board and Tools > Port, and select the Yún in both.

11Connect the Yúns to the Internet.

  • If you are using WiFi, follow the tutorial on the Arduino website found here. Note that some networks, such as those at universities, may require that the MAC address of the Yún be registered ahead of time for it to be able to connect. If this is the case, it may be easier to use Ethernet.
  • To connect your Yún via Ethernet, the easiest way is to plug your cable into your Yún and your laptop. Then, configure your sharing settings on your laptop to allow WiFi sharing via Ethernet.
    • On a Mac, this is done by going to System Preferences > Sharing. Select Internet Sharing from the Service menu on the left, share your connection from: WiFi, and to computers using: Ethernet.
    • On Windows, this is done by right-clicking on your wireless network, selecting Properties, going to the Sharing tab, checking the Allow other users to connect through this computer’s Internet connection box, and selecting Local Area Connection from the dropdown menu.

Yún Test [Optional]

10 Minutes

If the workshop participants have some experience using Arduinos, this is probably an unnecessary exercise that may be omitted. It uses an example sketch that comes in the Arduino IDE, and is a good way to confirm that the board itself is operational.

12If you are working with digital sensors (such as push buttons), go in the Arduino IDE to File > Examples > 02.Digital > Button; this will open a pre-written sketch that blinks an LED in response to a digital input. If you are working with analog sensors (such as photo sensors), go to File > Examples > 03.Analog > AnalogInput for a sketch that does the same in response to an analog input.

13Follow the wiring instructions given in the sketch; a link to a wiring diagram is also provided in the sketch.

14Run the sketch, and ensure that the LED is lighting up properly to confirm that the Yún is running.

Introduce the Library, Choreos, and Profiles

10 Minutes

15Starting at the Library page, point out some of the different APIs in the Library, and then navigate to the Google > Gmail > SendEmail Choreo.

16With IoT Mode off, generate the code for the Choreo in Java. Point out how you can create and save a Profile.

17Explain what a Profile is, and how it helps to decrease the memory needed to call a Choreo in addition to making it possible to change inputs without re-uploading, both of which are good for connected hardware.

18Run the Choreo from the browser, and have the participants check their emails to see that the Choreo executed successfully from the web. Note that the first time they run the sketch, they may be blocked by Google’s security features; to authorize access, follow the directions here.

19Scroll down the page and explain the various elements (optional inputs, the output, and the generated code). Point out how, after the successful Choreo execution, the output now shows the response returned as “Success.” Also show how to switch languages with the language dropdown. Note that the generated code for each language will execute the same Choreo process from a program that you just executed from the web.

20Take questions if there are any.

Send Email Example

10 Minutes

21While still on the Google > Gmail > SendEmail Choreo page, turn on IoT mode and show how the code for the Choreo can be generated as, in this case, a complete Arduino sketch that will work on the hardware you specify in the dropdown menus at the top of the page.

22Using the IoT Mode interface, add an input condition to the sketch so that it is triggered by the sensor you are working with. When selecting the pins, walk the participants through the interface, and give them time to wire their boards. It is simplest to direct them to use the same pins that you are using, at least at first. For this sketch, you’ll only need to initialize an input—outputs can be added later. Note: Depending on the experience level of the participants, this may be tricky for some of them. Be prepared to take a break, walk around the room, and help everyone get set up.

23Push the code to the Arduino, and test it out.

24Take questions if there are any.

Google Spreadsheets Example

10 Minutes

25Next, generate a sketch in IoT Mode to log data from your sensor in a Google spreadsheet using the Google > Spreadsheets > AppendRow Choreo.

26Use the same Profile from the original run in Java, and point this out.

27Use the IoT Mode interface to add an output condition that will turn on an LED when the Choreo executes successfully. Point out that this is a straightforward way to have hardware respond to information returned by a Choreo, and that it is especially useful for other APIs that return more than just a success or failure message.

28Note that all of the Choreos in the Temboo Library work the same way, so you could build like this with any of them from IoT mode. The participants will have the opportunity to do this soon.

29Set up a Google spreadsheet, noting that exactly one column must have a header.

30Push the code to the Arduino, and test it out.

31Show how you can use the spreadsheet to create a graph that updates in real time using the “Insert Chart” function in Google spreadsheets.

32Take questions if there are any.

Open Time

30–60 minutes

33Tell the participants that they can now work on an idea of their own using Temboo and their Yúns.

34Remind them that they have the entire Temboo Library and any sensors you have with you at their disposal, and that the Temboo integration will work the same way for everything.

35Note that Arduino has plenty of resources on its website in addition to what Temboo has.

36Suggest several ideas for people of varying comfort levels (listed here from least challenging to most challenging):

  • Send an SMS from Twilio
  • Turn on a light from your phone using Nexmo
  • Add another column (possibly a time variable) to the Google spreadsheet example
  • Post a tweet
  • Have the Arduino react to the text of a tweet

37Go around the room helping people who have questions.

Conclusion

5 Minutes

38Take any final questions.

39Clean up!

Questions?

We're always happy to help. Just email us at education@temboo.com, and we'll answer your questions.


Back