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.
- 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.
- 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.
- Request an API key. This identified your particular Arduino from the rest.
- 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.
- Don’t forget the ethernet cable from your Arduino stack to the router!
- Finally, some rudimentary knowledge about networking will be useful. (IP address, DHCP, etc.)
Controlling digital outputs
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 0×00… 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:
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:
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.
Latest posts by John Boxall (see all)
- Kit Review – Jaycar “Short Circuits” 3 Digit Counter - December 5, 2013
- Arduino Tutorials – Chapter 30 – twitter - December 4, 2013
- Tutorial – Send email with the Arduino Yún - November 23, 2013