Posts | Comments

Planet Arduino

Archive for the ‘temboo’ Category

Jun
17

Internet of Everything – Flip the Switch and Get Going

arduino, iot, temboo, Yun Comments Off on Internet of Everything – Flip the Switch and Get Going 

Temboo Iot

Our friends at Temboo are releasing more cool stuff for your Internet of Everything. Here’s some news from their blog.

———————————-

Now you can connect even more Arduinos with the power of Temboo by simply flipping our IoT Mode on. This new feature opens up a whole new world of possibilities for the Internet of Things.

What is IoT mode, you ask?

It’s a new way to access our 2,000+ Choreos on any of your Arduino or Arduino-compatible boards. By just hitting a switch at the top right of any Choreo page, you “got the power” to call that Choreo with a sketch tailored specifically for the device you pick from our drop down menu. Previously, this feature was only available for the Yún, but now it is open to the larger Arduino family. All you have to do is select the type of shield your board uses and the code will generate accordingly.

So how do I begin using this amazing IoT feature?

Select a Choreo from our vast Library and turn on IoT Mode. In the example below, we chose the Data.gov API and the GetCensusIdByCoordinates Choreo. Data.gov is a cool way to access APIs from a number of US governmet agencies and to query government datasets, including the US Census!

The “Arduino” option encompasses compatible boards that lack the Yún’s built-in wifi capabilities, but can connect to the internet with a shield. Fill out your shield’s specifics when the popup appears and save for future use. Run your Choreo and scroll down to retrieve the code for the sketch, ready to be pasted into your Arduino IDE. You can even plug this into a sketch generated by our nifty Device Coder to start mixing and matching!

We are thrilled just thinking of all of the possibilities this unlocks for the Internet of Things. We want to hear all about what you cook up with this new capability, so if you are working on an interesting project, reach out to us at hey@temboo.com!

Find out more on their blog!

Feb
07

Program a Yún without writing code! Temboo’s Sketch Builder

arduino, Arduino Yún, Internet of Things, temboo, Yun Comments Off on Program a Yún without writing code! Temboo’s Sketch Builder 

Sketch Builder - Sensor Selection

Today’s guest blogger Vaughn Shinall from Temboo‘s team updates us with a new feature to ease your way into smart homes.

————————-

Choose your sensor, choose what action you want it to trigger, and voila–your  Arduino Yún is doing it. Sending texts when a light sensor detects night, logging temperature data to a Google spreadsheet while you’re away, calling you when it sees an intruder in your home.

With our new Sketch Builder you can program your Yún to do all these things and more in no time. After choosing from multiple sensor types and actions, you can set the conditions and pins for your set up and have the code generated in an instant right on Temboo’s website. Then it’s just a simple copy-paste-upload job, and you’re on your way.

Sketch Builder - code generation page

Go give the Sketch Builder a try today. Support for more sensor types and actions are on the way, so let us know what you’d like us to add.

Watch the Sketch Builder in action:

 

PS – You should also check out this cool Arduino Yún project where the user managed to get Temboo running straight from the board’s Linux distribution by installing the Temboo Python SDK on the Yún.

Nov
11

Tutorial – Google Docs and the Arduino Yún

arduino, Docs, DS3232, google, Google Docs, iot, lesson, review, spreadsheet, temboo, tronixstuff, tutorial, wifi, Yun Comments Off on Tutorial – Google Docs and the Arduino Yún 

Introduction

This is the second in a series of tutorials examining various uses of the Arduino Yún. In this article we’ll examine how your Arduino Yún can send data that it captures from the analogue and digital inputs and a real-time clock IC to an online Google Docs spreadsheet. Doing so gives you a neat and inexpensive method of capturing data in real-time and having the ability to analyse the data from almost anywhere, and export it with very little effort.

Getting Started

If you haven’t already done so, ensure your Arduino Yún can connect to your network via WiFi or cable – and get a Temboo account (we run through this here). And you need (at the time of writing) IDE version 1.5.4 which can be downloaded from the Arduino website. Finally, you will need a Google account, so if you don’t have one – sign up here.

Arduino Yun Yún front

Testing the Arduino Yún-Google Docs connection

In this first example we’ll run through the sketch provided by Temboo so you can confirm everything works as it should. First of all, create a spreadsheet in Google Docs. Call it “ArduinoData” and label the first two columns as “time” and “sensor”, as shown in the screen shot below:

Arduino Yun Google Docs Spreadsheet

Always label the required columns. You can call them whatever you need. For new Google users, the URL shown in my example will be different to yours. Next, copy the following sketch to the IDE:

/*
  SendDataToGoogleSpreadsheet

  Demonstrates appending a row of data to a Google spreadsheet from the Arduino Yun 
  using the Temboo Arduino Yun SDK.  

  This example code is in the public domain.

*/

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information

/*** SUBSTITUTE YOUR VALUES BELOW: ***/

// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.

const String GOOGLE_USERNAME = "your-google-username";
const String GOOGLE_PASSWORD = "your-google-password";

// the title of the spreadsheet you want to send data to
// (Note that this must actually be the title of a Google spreadsheet
// that exists in your Google Drive/Docs account, and is configured
// as described above.)
const String SPREADSHEET_TITLE = "your-spreadsheet-title";

const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds)

// the last time we ran the Choreo 
// (initialized to 60 seconds ago so the
// Choreo is run immediately when we start up)
unsigned long lastRun = (unsigned long)-60000;

void setup() {

  // for debugging, wait until a serial console is connected
  Serial.begin(9600);
  delay(4000);
  while(!Serial);

  Serial.print("Initializing the bridge...");
  Bridge.begin();
  Serial.println("Done");
}

void loop()
{
  // get the number of milliseconds this sketch has been running
  unsigned long now = millis();

  // run again if it's been 60 seconds since we last ran
  if (now - lastRun >= RUN_INTERVAL_MILLIS) {

    // remember 'now' as the last time we ran the choreo
    lastRun = now;

    Serial.println("Getting sensor value...");

    // get the value we want to append to our spreadsheet
    unsigned long sensorValue = getSensorValue();

    Serial.println("Appending value to spreadsheet...");

    // we need a Process object to send a Choreo request to Temboo
    TembooChoreo AppendRowChoreo;

    // invoke the Temboo client
    // NOTE that the client must be reinvoked and repopulated with
    // appropriate arguments each time its run() method is called.
    AppendRowChoreo.begin();

    // set Temboo account credentials
    AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
    AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);

    // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
    AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");

    // set the required Choreo inputs
    // see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/ 
    // for complete details about the inputs for this Choreo

    // your Google username (usually your email address)
    AppendRowChoreo.addInput("Username", GOOGLE_USERNAME);

    // your Google account password
    AppendRowChoreo.addInput("Password", GOOGLE_PASSWORD);

    // the title of the spreadsheet you want to append to
    AppendRowChoreo.addInput("SpreadsheetTitle", SPREADSHEET_TITLE);

    // convert the time and sensor values to a comma separated string
    String rowData(now);
    rowData += ",";
    rowData += sensorValue;

    // add the RowData input item
    AppendRowChoreo.addInput("RowData", rowData);

    // run the Choreo and wait for the results
    // The return code (returnCode) will indicate success or failure 
    unsigned int returnCode = AppendRowChoreo.run();

    // return code of zero (0) means success
    if (returnCode == 0) {
      Serial.println("Success! Appended " + rowData);
      Serial.println("");
    } else {
      // return code of anything other than zero means failure  
      // read and display any error messages
      while (AppendRowChoreo.available()) {
        char c = AppendRowChoreo.read();
        Serial.print(c);
      }
    }

    AppendRowChoreo.close();
  }
}

// this function simulates reading the value of a sensor 
unsigned long getSensorValue() {
  return analogRead(A0);
}

Now look for the following two lines in the sketch:

const String GOOGLE_USERNAME = "your-google-username";
const String GOOGLE_PASSWORD = "your-google-password";

This is where you put your Google account username and password. For example, if your Google account is “CI5@gmail.com” and password “RS2000Escort” the two lines will be:

const String GOOGLE_USERNAME = "CI5@gmail.com";
const String GOOGLE_PASSWORD = "RS2000Escort";

Next, you need to insert the spreadsheet name in the sketch. Look for the following line:

const String SPREADSHEET_TITLE = "your-spreadsheet-title";

and change your-spreadsheet-title to ArduinoData. 

Finally, create your header file by copying the the header file data from here (after logging to Temboo) into a text file and saving it with the name TembooAccount.h in the same folder as your sketch from above. You know this has been successful when opening the sketch, as you will see the header file in a second tab, for example:

Arduino Yun sketch header file

Finally, save and upload your sketch to the Arduino Yún. After a moment or two it will send values to the spreadsheet, and repeat this every sixty seconds – for example:

Arduino Yun Google Docs Spreadsheet data

If your Yún is connected via USB you can also watch the status via the serial monitor.

 One really super-cool and convenient feature of using Google Docs is that you can access it from almost anywhere. Desktop, tablet, mobile… and it updates in real-time:

Arduino Yun_ Google Docs Spreadsheet_data_mobile

So with your Yún you can capture data and view it from anywhere you can access the Internet. Now let’s do just that.

Sending your own data from the Arduino Yún to a Google Docs Spreadsheet

In this example we’ll demonstrate sending three types of data:

With these types of data you should be able to represent all manner of things. We use the RTC as the time and date from it will match when the data was captured, not when the data was written to the spreadsheet. If you don’t have a DS3232 you can also use a DS1307.

If you’re not familiar with these parts and the required code please review this tutorial. When connecting your RTC – please note that SDA (data) is D2 and SCL (clock) is D3 on the Yún.

The sketch for this example is a modified version of the previous sketch, except we have more data to send. The data is captured into variables from the line:

// get the values from A0 to A3 and D7, D8

You can send whatever data you like, as long as it is all appended to a String by the name of rowdata. When you want to use a new column in the spreadsheet, simply append a comma “,” between the data in the string. In other words, you’re creating a string of CSV (comma-separated values) data. You can see this process happen from the line that has the comment:

// CSV creation starts here!

in the example sketch that follows shortly. Finally, you can alter the update rate of the sketch – it’s set to every 60 seconds, however you can change this by altering the 60000 (milliseconds) in the following line:

const unsigned long RUN_INTERVAL_MILLIS = 60000;

Don’t forget that each update costs you a call and some data from your Temboo account – you only get so many for free then you have to pay for more. Check your Temboo account for more details.

So without further ado, the following sketch will write the values read from A0~A3, the status of D7 and D8 (1 for HIGH, 0 for LOW) along with the current date and time to the spreadsheet. Don’t forget to update the password, username and so on as you did for the first example sketch:

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
#include "Wire.h"
#define DS3232_I2C_ADDRESS 0x68

unsigned long analog0, analog1, analog2, analog3;
int digital7 = 7;
int digital8 = 8;
boolean d7, d8;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // for RTC

const String GOOGLE_USERNAME = "your-google-username";
const String GOOGLE_PASSWORD = "your-google-password";
const String SPREADSHEET_TITLE = "your-spreadsheet-title";

// update interval in milliseconds (every minute would be 60000)
const unsigned long RUN_INTERVAL_MILLIS = 60000; 
unsigned long lastRun = (unsigned long)-60000;

void setup() 
{
  // activate I2C bus
  Wire.begin();  
  // for debugging, wait until a serial console is connected
  Serial.begin(9600);
  delay(4000);
  while(!Serial);
  Serial.print("Initializing the bridge...");
  Bridge.begin();
  Serial.println("Done");
  // Set up digital inputs to monitor
  pinMode(digital7, INPUT);
  pinMode(digital8, INPUT);
}

// for RTC
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

void readDS3232time(byte *second, 
byte *minute, 
byte *hour, 
byte *dayOfWeek, 
byte *dayOfMonth, 
byte *month, 
byte *year)
{
  Wire.beginTransmission(DS3232_I2C_ADDRESS);
  Wire.write(0); // set DS3232 register pointer to 00h
  Wire.endTransmission();  
  Wire.requestFrom(DS3232_I2C_ADDRESS, 7); // request 7 bytes of data from DS3232 starting from register 00h
  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.read() & 0x7f);
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}

void setDS3232time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
// sets time and date data to DS3232
{
  Wire.beginTransmission(DS3232_I2C_ADDRESS);  
  Wire.write(0); // sends 00h - seconds register
  Wire.write(decToBcd(second));     // set seconds
  Wire.write(decToBcd(minute));     // set minutes
  Wire.write(decToBcd(hour));       // set hours
  Wire.write(decToBcd(dayOfWeek));  // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1~31)
  Wire.write(decToBcd(month));      // set month
  Wire.write(decToBcd(year));       // set year (0~99)
  Wire.endTransmission();
}

void loop()
{
  // get the number of milliseconds this sketch has been running
  unsigned long now = millis();

  // run again if it's been 60 seconds since we last ran
  if (now - lastRun >= RUN_INTERVAL_MILLIS) {

    // remember 'now' as the last time we ran the choreo
    lastRun = now;
    Serial.println("Getting sensor values...");
    // get the values from A0 to A3 and D7, D8
    analog0 = analogRead(0);
    analog1 = analogRead(1);
    analog2 = analogRead(2);
    analog3 = analogRead(3);
    d7 = digitalRead(digital7);
    d8 = digitalRead(digital8);

    Serial.println("Appending value to spreadsheet...");
    // we need a Process object to send a Choreo request to Temboo
    TembooChoreo AppendRowChoreo;

    // invoke the Temboo client
    // NOTE that the client must be reinvoked and repopulated with
    // appropriate arguments each time its run() method is called.
    AppendRowChoreo.begin();

    // set Temboo account credentials
    AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
    AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);

    // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow)
    AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");
    // your Google username (usually your email address)
    AppendRowChoreo.addInput("Username", GOOGLE_USERNAME);
    // your Google account password
    AppendRowChoreo.addInput("Password", GOOGLE_PASSWORD);
    // the title of the spreadsheet you want to append to
    AppendRowChoreo.addInput("SpreadsheetTitle", SPREADSHEET_TITLE);

    // get time and date from RTC
    readDS3232time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

    // smoosh all the sensor, date and time data into a String
    // CSV creation starts here!
    String rowData(analog0);
    rowData += ",";
    rowData += analog1;
    rowData += ",";
    rowData += analog2;
    rowData += ",";
    rowData += analog3;
    rowData += ",";
    rowData += d7;
    rowData += ",";
    rowData += d8;    
    rowData += ",";
    // insert date
    rowData += dayOfMonth; 
    rowData += "/";
    rowData += month; 
    rowData += "/20";
    rowData += year; 
    rowData += ",";    
    // insert time    
    rowData += hour;  
    if (minute<10)
    {
        rowData += "0";  
    }    
    rowData += minute; 
    rowData += "."; 
    if (second<10)
    {
        rowData += "0";  
    }    
    rowData += second; 
    rowData += "h";     

    // add the RowData input item
    AppendRowChoreo.addInput("RowData", rowData);

    // run the Choreo and wait for the results
    // The return code (returnCode) will indicate success or failure 
    unsigned int returnCode = AppendRowChoreo.run();

    // return code of zero (0) means success
    if (returnCode == 0) {
      Serial.println("Success! Appended " + rowData);
      Serial.println("");
    } else {
      // return code of anything other than zero means failure  
      // read and display any error messages
      while (AppendRowChoreo.available()) {
        char c = AppendRowChoreo.read();
        Serial.print(c);
      }
    }
    AppendRowChoreo.close();
  }
}

… which in our example resulted with the following:

Arduino Yun Google Docs Spreadsheet time date data

… and here is a video that shows how the spreadsheet updates in real time across multiple devices:

 Conclusion

It’s no secret that the Yún isn’t the cheapest devleopment board around, however the ease of use as demonstrated in this tutorial shows that the time saved in setup and application is more than worth the purchase price of the board and extra Temboo credits if required.

And if you’re interested in learning more about Arduino, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Tutorial – Google Docs and the Arduino Yún appeared first on tronixstuff.

Oct
29

Tutorial – twitter and the Arduino Yún

arduino, lesson, temboo, tronixstuff, tutorial, twitter, wifi, Yun Comments Off on Tutorial – twitter and the Arduino Yún 

Introduction

After spending almost $100 on an Arduino Yún to see what the fuss was about, it seemed like a good idea to find and demonstrate some uses for it. So in this article we’ll examine how your Yún can send a tweet using some simple example sketches – and the first of several Arduino Yún-specific tutorials.

Getting Started

If you haven’t already done so, ensure your Arduino Yún can connect to your network via WiFi or cable – and get a Temboo account (we run through this here). And you need (at the time of writing) IDE version 1.5.4 which can be downloaded from the Arduino website. Finally, if you don’t have a twitter account – go get one.

Arduino Yun Yún front

Sending a tweet from your Yún

Thanks to Arduino and Temboo, 99% of the work is already done for you. To send a tweet requires the Arduino sketch, a header file with your Temboo account details, and also the need to register an application in the twitter development console.

Don’t panic, just follow the “Get Set Up” instructions from the following page. When you do – make sure you’re logged into the Temboo website, as it will then populate the header file with your Temboo details for you. During the twitter application stage, don’t forget to save your OAuth settings which will appear in the “OAuth Tool” tab in the twitter developer page, for example:

Arduino Yun OAuth twitter

… as they are copied into every sketch starting from the line:

const String TWITTER_ACCESS_TOKEN =

When you save the sketch, make sure you place the header file with the name TembooAccount.h in the same folder as your sketch. You know this has been successful when opening the sketch, as you will see the header file in a second tab, for example:

Arduino Yun sketch header file

Finally, if you’re sharing code with others, remove your OAuth and TembooAccount.h details otherwise they can send tweets on your behalf.

OK – enough warnings. If you’ve successfully created your Temboo account, got your twitter OAuth details, fed them all into the sketch and header file, then saved (!) and uploaded your sketch to the Arduino Yún - a short tweet will appear on your timeline, for example:

Arduino Yun twiiter

If nothing appears on your twitter feed, open the serial monitor in the IDE and see what messages appear. It will feed back to you the error message from twitter, which generally indicates the problem.

Moving on, let’s examine how to send tweets with your own information. In the following example sketch we send the value resulting from analogRead(0) and text combined together in one line. Don’t forget twitter messages (tweets) have a maximum length of 140 characters. We’ve moved all the tweet-sending into one function tweet(), which you can then call from your sketch when required – upon an event and so on. The text and data to send is combined into a String in line 26:

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
                           // as described in the footer comment below

const String TWITTER_ACCESS_TOKEN = "aaaa";
const String TWITTER_ACCESS_TOKEN_SECRET = "bbbb";
const String TWITTER_CONSUMER_KEY = "ccccc";
const String TWITTER_CONSUMER_SECRET = "dddd";

int analogZero;

void setup() 
{
  Serial.begin(9600);
  delay(4000);
  while(!Serial);
  Bridge.begin();
}

void tweet()
{
    Serial.println("Running tweet() function");

    // define the text of the tweet we want to send
    String tweetText("The value of A0 is " + String(analogZero) + ". Hooray for twitter");

    TembooChoreo StatusesUpdateChoreo;
    // invoke the Temboo client
    // NOTE that the client must be reinvoked, and repopulated with
    // appropriate arguments, each time its run() method is called.
    StatusesUpdateChoreo.begin();
    // set Temboo account credentials
    StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT);
    StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY);
    // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate)
    StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");
    // add the Twitter account information
    StatusesUpdateChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN);
    StatusesUpdateChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET);
    StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY);    
    StatusesUpdateChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET);
    // and the tweet we want to send
    StatusesUpdateChoreo.addInput("StatusUpdate", tweetText);
    // tell the Process to run and wait for the results. The 
    // return code (returnCode) will tell us whether the Temboo client 
    // was able to send our request to the Temboo servers
    unsigned int returnCode = StatusesUpdateChoreo.run();
    // a return code of zero (0) means everything worked
    if (returnCode == 0) {
        Serial.println("Success! Tweet sent!");
    } else {
      // a non-zero return code means there was an error
      // read and print the error message
      while (StatusesUpdateChoreo.available()) {
        char c = StatusesUpdateChoreo.read();
        Serial.print(c);
      }
    } 
    StatusesUpdateChoreo.close();
    // do nothing for the next 90 seconds
    Serial.println("Waiting...");
    delay(90000);
}

void loop()
{
  // get some data from A0. 
  analogZero=analogRead(0);
  tweet();
  do {} while (1); // do nothing
}

Which results with the following example tweet:

Arduino Yun sends twitter data

With the previous example sketch you can build your own functionality around the tweet() function to send data when required. Recall that the data to send as a tweet is combined into a String at line 26.

Please note that you can’t blast out tweets like a machine, for two reasons – one, twitter doesn’t like rapid automated tweeting – and two, you only get 1000 free calls on your Temboo account per month. If you need more, the account needs to be upgraded at a cost.

Conclusion

Well the Yún gives us another way to send data out via twitter. It wasn’t the cheapest way of doing so, however it was quite simple. And thus the trade-off with the Arduino platform – simplicity vs. price. If there is demand, we’ll examine more connected functions with the Yún.

And if you’re interested in learning more about Arduino, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Tutorial – twitter and the Arduino Yún appeared first on tronixstuff.

Sep
18

First look – Arduino Yún

AR9331, arduino, Atheros, iot, lesson, Linino, Linux, review, temboo, tronixstuff, tutorial, wifi, Yun Comments Off on First look – Arduino Yún 

Introduction

After being announced in May this year, the new Arduino Yún has arrived in the crowded marketplace – and I snapped up one of the first to arrive in Australia for an initial review. The purpose of which is to run through the out of box experience, and to see how easy it was to get the Yún working with the promised new features.

[Update - over time we'll publish tutorials specifically for the Yún, which are listed here.]

The Yún introduces some interesting new combinations of hardware and connectivity, all within the familiar form-factor. Which gives us plenty to examine and write about, so let’s get started. First, a quick look around the Yún:

Arduino Yun Yún front

Notice the stickers on the header sockets, useful for beginners or the absent-minded…

Arduino Yún Yun right side

The usual TX/RX and D13 LEDs, plus notifiers for power, WiFi, LAN and USB use…

Arduino Yún Yun sockets

Ethernet, USB programming, USB host…

Arduino Yun Yún top side

Again with the stickers…

Arduino Yun Bottom Yún

The rear is quite busy. You can also see “Made in Taiwan” – a first for Arduino. I believe the reason for this was due to the new Atheros chipset requirements. Did you notice the multiple reset buttons? There are three – one for the Arduino, one for wifi and one to reboot Linino. As you can see there’s a lot of circuity on the bottom of the Yún, so it would be prudent to use some short standoffs to elevate the board and protect the bottom. Before moving on, you might like the following video where the Arduino team introduce the Yún:

Specifications

The Yún is based around the Arduino Leonardo-specification board – thus you have the ATmega32U4 microcontroller and the usual Leonardo functions. Note you cannot feed wild DC voltages into the Vin pin – it must be a regulated 5V. And the DC socket has gone, so for a solid connection you might want to make or buy your own power shield.

However there is so much more… underneath a small metal shield below the digital I/O pins is an Atheros AR9331 CPU running a Linux distribution based on OpenWRT named Linino. This Atheros part of the board is connected to a microSD socket, 10/100 Ethernet port, a USB 2.0 socket for host-mode functions and also has IEEE 802.11b/g/n WiFi, and Power-over-Ethernet support (with an optional adaptor).

And all of that is connected to the Arduino side of things via a simple serial “bridge” connection (with it’s own library) – which gives the Arduino side of the board very simple methods of controlling the other onboard hardware.

Getting started with the Yún WiFi

First thing is to download and install the new IDE, version 1.5.4. This is for Due and Yún, so keep your older installations as well. On the general Arduino side of things nothing has changed, so we’ll move on to the more interesting side of the board. The first of these is to setup and experiment with the onboard WiFi. After connecting your board to USB for power, you can connect to it with your PC’s WiFi:

Arduino Yun Yún office wifi

… at which point you connect to the Yún network. Then visit 192.168.240.1 from a web browser, and you’re presented with a page that asks for the default password, which is … “arduino”:

Arduino Yún Yun wifi setup

At which point you’re presented with the relevant details for your Yún:

Arduino Yún  Yun wifi details

… such as the IP address, MAC address, etc. Make note of your MAC address, you might need it later. From here you can configure the Yún WiFi details, for example the name and password, and also the details of your existing WiFi network which can be used to access the Yún. Once you save those, the Yún reboots and tells you to connect the PC back to the existing WiFi network:

Arduino Yun Yún WiFi setup complete

If for some reason it doesn’t work or you entered the wrong settings – hold down the “WLAN RST” button (next to the USB host socket) for five seconds. This sets the WiFi details in the Yun back to the default … and you can start all over again.

Note that the Yún’s preset IP of 192.168.240.1 may not be suitable for your own network. For example, if your home router is 10.1.1.1 you need to do some detective work to find out the IP address for the Yún. Head into your router’s administration pages and look for your DHCP Client Log. It will show a list of devices that are connected to the network, including their MAC and IP address – for example:

Arduino Yún Yun new IP address DHCPThen it’s a simple matter of finding the MAC address in the list and the matching IP. Once you have the IP address, enter that into a web browser and after being prompted for the Yún’s password, you’re back to the welcome page with the IP, MAC addresses etc.

WiFi Sketch Uploading

Once your Yún is on the same WiFi network as the PC running the IDE – you can upload a sketch over WiFi! This is possible due to the bridge between the Atheros section on the board and the Arduino hardware. Just select the board type as normal in the IDE, and the port (the IP address version):

Arduino Yun WiFi sketch upload  Yún

… then hit Upload as normal, enter the password:

Arduino Yun WiFi sketch upload  Yún

and you’re done. Awesome.

Console-based control of Arduino over WiFi

There’s a neat example that demonstrates how you can control the Arduino over the WiFi using a console terminal on the PC. Upload this sketch (from http://arduino.cc/en/Guide/ArduinoYun#toc13):

#include <Console.h>

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  Bridge.begin();
  Console.begin(); 

  while (!Console){
    ; // wait for Console port to connect.
  }
  Console.println("You're connected to the Console!!!!");
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // see if there's incoming serial data:
  if (Console.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Console.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    } 
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
    }
  }
}

Then load your terminal software. We use PuTTY on Windows. Run the terminal software, then login as root, then telnet to “localhost 6571″:

Arduino Yún  Yun terminal console putty

You can then send characters to the Yún just as you would with a USB-connected Arduino via the serial monitor. With the example above you’re turning the D13 LED on and off, but you can get the idea.

The “Internet of Things”

Arduino has teamed up with a service called “Temboo” – which gives you over 100 APIs that your Yún can hook up with to do a myriad of things, such as send tweets, get weather data from Yahoo, interact with Dropbox, etc. This is done easily and explained quite well at the Temboo website. After signing up for Temboo (one account seems to be free at the moment) we tried the Yahoo weather API.

You enter the parameters using an online form in Temboo (in our example, the address of the area whose weather forecast we required), and the Temboo site gives you the required Arduno sketch and header file to upload. And you’re done. With this particular example, I wanted the weather in Sydney CBD – and once running the data is returned to the serial monitor, for example:

Temboo Arduino Yun yahoo weather Yún

It was great to see that work the very first time, and a credit to Temboo and Arduino for making it happen. But how?

There is a Temboo client in the Linino OS, which is the gateway to the API via WiFi, and also communicates with the Arduino via the serial bridge. The Arduino Temboo library can then interact with the Linino client without complex code. The weather data is then returned back from the Internet via the Temboo client and fed to the Arduino serial port, where you can parse it with your own code. This looks like a lot of fun, and also could be quite useful – for example capturing data and sending it to a Google Docs spreadsheet. For more information, check out the Temboo website.

However you can delve deeper and create your own APIs, matching code – and perhaps other services will develop their own APIs in the near future. But for now, it’s a good start.

Where to from here? And support?

This article has only scratched the surface (but not bad considering the board arrived a few hours ago). There’s plenty more examples on the getting started page, in the IDE (under “Bridge”) – plus a dedicated Arduino Yún forum. And check out this gmail notifier. In the near future we’ll create some of our own tutorials, so stay tuned.

Is the Yún a completely open-source product? 

Well it says “open source electronics prototyping platform” on the rear, but is this true? The Arduino Leonardo-side of the board is. However the Atheros AR9331 chip is not. Nevertheless, are you really going to reproduce your own AR9331? So it doesn’t really matter. Being a pragmatist I propose that the Yún solves the problem of Arduino and Internet connectivity quite well for the non-advanced user – so not being totally OSHW isn’t an issue.

Support

This board is very new to us here, so for questions or support please ask on the dedicated Arduino Yún forum.

Conclusion

Since the popularity of various single-board computers has increased exponentially over the last few months, some may say that the Yún is perhaps too little, too late. After only having the Yún for a few hours before writing this article, personally I disagree with this statement – the Yún is a device that still gives us the wide range of hardware control, and what looks to be a very simple method of connectivity that surely is cheaper and less prone to issues than the original Arduino WiFi shield.

What the Yún gives us is a simple, well-executed method of getting our Arduino connected to the outside world – and in a manner that won’t confuse or put off the beginner or intermediate user. So for now, it’s a win.

What do you think? Leave a comment below.

And for more detail, full-sized images from this article can be found on flickr. And if you’re interested in learning more about Arduino, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post First look – Arduino Yún appeared first on tronixstuff.

Sep
11

The Power of Temboo: connect the Yún to 100+ APIs

api, arduino, Arduino Yún, social media, temboo, Yun Comments Off on The Power of Temboo: connect the Yún to 100+ APIs 

1 - Arduino Temboo schema

(Guest post by Temboo Team)

Ever wish your Arduino could respond to the weather on the other side of the world? Or send you an email to let you know what it’s up to? Upload stuff to your Dropbox account? Or detect if you’re at risk of exposure to toxic chemicals?

Now it can. The Arduino Yún can easily grab all sorts of data and interact with tons of web-based services like Fitbit, Facebook, and Google because every Yún comes loaded with the power of Temboo. Using the Yún’s built in wi-fI capabilities, Temboo makes it easy for the Yún to connect to over 100 Application Programming Interfaces (APIs).

Don’t know what an API is or how to use one? Don’t worry. You don’t need to. With Temboo you can start using APIs with your Yún in minutes. We’ve standardized how to program with them and made sure they play nice with Arduino.

So how do you get your Yún to Temboo?

That’s easy too. When you’re setting up your Arduino account, you can quickly register for a free Temboo account right from your Arduino profile page. All you need to do for that is pick a Temboo username, and we’ll automatically email you your Temboo account details along with some ideas on where to begin. You should definitely check out the dedicated Arduino section of our website. We’ve created several how-to examples to get you Tweeting, texting, and more from your Yún in minutes. We’ve even put some examples right into the Arduino IDE (File->Examples>Bridge->Temboo).

Temboo's special page for the Arduino Yún.

 

Click on the image below to see one of the Temboo examples on Arduino IDE

 

One of the Temboo examples in the Arduino IDE.

What’s under the hood?

Temboo has written a special Python program on the Linino processor that interacts with the Temboo platform, sending and receiving data. A C++ library we created for the Arduino processor allows makers to communicate with the Linino-side Temboo program in a powerful yet user-friendly way. Sketch code for interacting with any Temboo process is generated live on our site for copying into the Arduino IDE. We’ve even developed a unique way for users to select the particular data they need from APIs and web-based resources, filtering out extraneous information and reducing the load on the board. For all the power that Temboo provides, our technology leaves a remarkably light footprint.

The Temboo website generates sketch code for the Arduino Yún. Above: Create an event on a Google Calendar.

We can’t even begin to imagine all the cool stuff that makers will do with the Yún. We’ll be adding more Arduino examples to our site as we continue to brainstorm, but we’d love to feature your ideas and projects as well. Shoot us an email at hey [at] temboo.com or tweet at us at @Temboo to tell us about what you’re working on or to ask any questions.

 

 



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook