Interact with Arduino over the Internet with Teleduino

Introduction

[Updated 06/12/2013]

Recently a new method of interacting with an Ethernet-enabled Arduino board and the Internet was brought to my attention – a new system called Teleduino. In this article we test a few of the basic features and see what is possible. Please note that these are my own experiments and that Teleduino is a work in progress. So follow along and see for yourself.

Getting Started

  1. You will need an Arduino Uno (or compatible) board and Ethernet shield with the Wiznet chip – or a Freetronics EtherTen (a much neater solution). Teleduino now supports Arduino Mega and the awesome EtherMega.
  2. Download and install the Teleduino Arduino library. This is available from the resources section of the home page. You will also need to be running Arduino IDE v1.0 or greater.
  3. Request an API key. This identified your particular Arduino from the rest.
  4. Get together some basic electronics components for testing, such as some LEDs and 560R resistors; sources of analog input such as an LDR or TMP36 temperature sensor; and a solderless breadboard.
  5. Don’t forget the Ethernet cable from your Arduino stack to the router!
  6. Finally, some rudimentary knowledge about networking will be useful. (IP address, DHCP, etc.)
The Teleduino system uses pin D8 for a status LED, so you may find connecting one up now useful while experimenting. Connect as such:

Controlling digital outputs

In this example we control an LED, turning it on and off. For demonstration purposes, connect another LED with a resistor to D6 in the same method as shown above. Next, you need to upload a sketch to the Arduino. It is the

which is included with the library examples. Before uploading, you need to make some modifications. The first of these is to add your API key. Go back to the email you received from Teleduino, and click on the link provided. It will take you to a website that shows a byte array variable named byte key[]. You will copy this into the sketch, replacing the same array full of hexadecimal zeros in the sketch – as shown below – with your own:

Next, scroll down to

… and change one of the hexadecimal numbers to 0x00… just in case there is a clash with other addresses on your network. You never know. Finally – depending on your network router, you may need to manually allocate the IP address for your Ethernet shield and/or set the DNS server to use. To do this, scroll down to

where you can change the useDHCP and/or useDNS variables to false, and update those values below. However if you’re not sure, just leave them be unless you need to change them. Finally – upload the sketch to your Arduino, get the hardware together and plug it into the network.

Watch your status LED – it will blink a number of times, depending on the status of things. The blink levels are:

  • 1 blink – initialising
  • 2 blinks – starting network connection
  • 3 blinks – connecting to the Teleduino server
  • 4 blinks – authentication successful
  • 5 blinks – session already exists for supplied key (sometimes happens after a quick restart – will work on next auto-restart)
  • 6 blinks – Invalid or unauthorised key – check your API key is correctly entered in the sketch as described earlier
  • 10 blinks – connection dropped

If all is well, after a minute yours should be on blink level 4, then it will idle back to blink level 1. Now to test the connection with our first command.

You send commands to the Arduino using a set of URLs that will contain various parameters. You will need your API key again for these URLs which is then inserted into the URL. The first will report the version of software on the Arduino. Send

however replace 999999 with your API key (and in all examples shown here). If successful, you should see something similar to the following in the web browser:

However if something is wrong, or there are connection difficulties you will see something like:

Before using digital outputs, and after every reset of the Arduino) you need to set the pin mode for the digital output to control. In our example, we use:

Note that the pin number and mode are set with single digits, as you can see above this is for pin 6, and we use mode=1 for output. You should save this as a bookmark to make life easer later on. When the command has been successfully sent, a message will be shown in the webpage, for example:

Moving forward – you turn the digital output on with the following:

and to turn it off, set the final part of the URL to

Easy. How did you go? It really is amazing to see it work. Now you can control your Arduino from almost anywhere in the world. Again, saving these as bookmarks to make things easier, or a URL shortening service.

At this point you should now have the gist of the Teleduino service and how it is operated.

There is so much more you can do, and currently the list includes (From the author):

  • Reset, ping, get version, get uptime, get free memory.
  • Define pin modes, set digital outputs, set analog outputs, read digital inputs, read analog inputs, or read all inputs with a single API call.
  • Define up to 2 ‘banks’ of shift registers. Each ‘bank’ can contain up to 32 cascaded shift registers, giving a total of 512 digital outputs.
  • Shift register outputs can be set, or merged, and expire times can be set on merges (you could set an output(s) high for X number of milliseconds).
  • Define, and read and write from serial port.
  • Read and write from EEPROM.
  • Define and position up to 6 servos.
  • Set preset values for the above functions, which get set during boot. Preset values are stored in the first 160ish bytes of the EEPROM.

[22/09/2012] New! You can also control the I2C bus – check out this tutorial for more information. For more information check the Teleduino web site, and further tutorials can be found here. Here is a simple example of Teleduino at work – controlling a light switch:

Conclusion

At this moment Teleduino is simple, works and makes a lot of ideas possible. We look forward to making more use of it in future projects, and hope you can as well. Kudos to Nathan Kennedy, and we look forward to seeing Teleduino advance and develop over the future. If all this Arduino is new to you, check out the tutorials.  Thanks to Freetronics for the use of their Ethernet-enabled hardware.

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 following two tabs change content below.

John Boxall

Founder, owner and managing editor of tronixstuff.com.

10 Responses to “Interact with Arduino over the Internet with Teleduino”

  1. attu says:

    I have never seen a sucsefull internet example with the Arduino. I think the reason is that there is not
    a readily availble GUI interface. I have used industrial type controllers in this manner but have had
    no sucess here. It seems to me that the interactive form in excel could be used as the GUI internet
    graphics platform. You could draw shapes and change status, just a thought. Who likes to look at text
    only via serial terminal? I dont know the answers but i bet alot more interactive com products woud be sold if this could be fixed.
    attu

    • John Boxall says:

      There are many options available. Teleduino appeals due to the simplicity. Note the results from each URL action, they are nicely formatted for reading by a PHP script or other code. You might be interested in Ninja Blocks, much more GUI interface and user-friendly for the beginner wanting that level of interface – http://ninjablocks.com/

  2. taher says:

    i am not able to make it run it gives me “status: 403″……. all the time please help me…

    • nathanknz says:

      A 403 error would indicate that either your device key is incorrect, or the device is offline. Is your device connecting successfully? The status LED should provide some clues. Thanks.

    • nathanknz says:

      A 403 error would indicate that either the device is offline or the key is incorrect. Do youknow if the device is getting online? The Status LED should provide some clues. Thanks.

  3. Steve56 says:

    I’m running on Bigpond using a Sierra modem with WiFi.

    Can the EtherTen connect to that system ? If not what else do I need ?

  4. Ezu says:

    this is one of my preferred tutorial from where I learn how to use the Ethernet shield together with teleduino

Trackbacks/Pingbacks


Leave a Reply

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: