Posts | Comments

Planet Arduino

Archive for the ‘internet’ Category

Nov
15

Arduino powered Lucky Cat as physical webcounter

arduino, arduino ethernet, ethernet, gallery, internet, RGB LED, servo, webcounter Commenti disabilitati su Arduino powered Lucky Cat as physical webcounter 

Rebuilt my lucky cat: whenever a page of my website is loaded, the cat will be waving its arm. There’s a light sensor so when its dark, the cats RGB-LED is changing the color instead of waving the arm. Changing the color of the LED is also possible with one of the buttons on the cats ears. The other one is the reset button. Used an arduino ethernet, a servo, two buttons, an RGB LED and two small yellow LEDs. The seven segment display is one that I harvested from an old stereo. It’s driven by the arduino and two shift registers. unfortunately I’ve soldered that one together for an older project, so that it doesn’t fit into the cat too. It shows the number of pageviews of the website.

via [instructables] visit the page of [Janwil]

Set
21

Control your Arduino over the web

arduino, Firmata, internet, javascript, Web Commenti disabilitati su Control your Arduino over the web 

Breakout – [via]

Breakout is a prototyping tool for exploring the intersection of the web and the physical world. The popularArduino platform and the Firmata protocol are leveraged to enable users to access physical input and output purely from javascript. This makes it easy for anyone familiar with javascript and basic web development to explore the possibilities of using physical I/O in their web applications. Furthermore, the Breakout framework includes a growing library of hardware abstractions such as buttons, leds, servo motors, accelerometers, gyros, etc enabling the user to easily interface with a range of sensors and actuators using just a few lines of javascript code.

Breakout grew out of a need for a simple platform to enable designers to prototype functional web-based interfaces to the physical world. It is based largely on the Funnel toolkit and informed by the experiences of the developers of both Funnel and Breakout as designers, technologists and educators.

Control your Arduino over the web - [Link]

Set
14

Internet-controlled relays with teleduino and Freetronics RELAY8:

arduino, ethernet, freetronics, i2c, internet, lesson, lessons, Relay, relay8:, remote, shield, teleduino, tronixstuff, tutorial, tutorials Commenti disabilitati su Internet-controlled relays with teleduino and Freetronics RELAY8: 

Control relays over the Internet with Arduino in chapter forty-seven of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 24/11/2012

In this article we’re going to look at controlling relays over the Internet. In doing so you will then be able to turn almost anything on and off as long as you have http access on an Internet-enabled device. Why would you want to do this? Connect an outdoor light – and turn it on before arriving home. Control the power to your TV setup – then you can control childrens’ TV viewing at a whim. Control farm water pumps without getting out of the truck. We’ll break this down into two stages. First we’ll explain how the RELAY8: relay control shield works and control it locally, then control it remotely using the teleduino service. We will be using Arduino IDE v1.0.1.

This tutorial will assume you have an understanding from three other articles – so please have a quick read of I2C bus, the MCP23017 I/O expander and teleduino. But don’t panic – we’ll try and keep it simple here.

The RELAY8: shield

First – our relay shield. We’ll be using the Freetronics RELAY8: shield:

Using the RELAY8: you can control eight relays using the I2C bus and the MCP23017 I/O expander – which saves your digital outputs for other purposes. There are three hardware settings you need to consider when using the shield:

  1. Power – how will you power the relay coils?
    • You can directly connect between 5 and 24V DC using the terminal block on the right-hand side of the shield – great for stronger relay coils.
    • You can power the relay coils using power from the Arduino. So whatever power is going to the Arduino Vin can power the shield. To do this jumper the two pins next to the Vin shield connector. In doing so – you must check that the combined current draw of all your relays on at once will not exceed what is available to the Arduino. Usually OK when using solid-state relays, as most examples use around 15mA of current to activate. However double-check your relay specifications before doing so.
    • You can also power the Arduino board AND the shield by feeding in external power to the shield and jumpering the two pins described above
  2. Which I2C address to use for each shield? By default it is 0×20. However you can alter the last three bits of the address by changing the jumpers at the bottom-left of the shield. Each jumper represents one bit of the bus address – no jumper means zero, and a jumper means one. So if you jumper ADDR0, the address will be 0×21 – etc. Using this method you can then stack up to eight shields – and control 64 relays!
  3. Are you using an Arduino Leonardo board? If so – your shield I2C pins aren’t A4/A5 – they’re over near the top of the board:

However this isn’t a problem. Solder in some header pins to the shield’s SCL/SDA holes (next to AREF). Then turn over the RELAY8: board and you will see some solder pads as shown below. With a thin knife, cut the copper tracks shown with the blue lines:

Doing this will redirect the I2C bus from the microcontroller to the correct pins at the top-left. Once you have decided on your power and I2C-bus options, it’s time to connect the relays. Doing so is simple, just connect the +  and – from the relay coil to the matching position on your RELAY8: shield, for example:

Today we’re just using prototyping wires, so when creating a permanent installation ensure the insulation reaches the terminal block. When working with relays you would use a diode across the coil to take care of back-EMF – however the shield has this circuitry, so you don’t need to worry about that at all. And if you’re wanting to control more than one shield – they stack nicely, with plenty of clearance between shields, for example:

Now to test the shield with a quick demonstration. Our sketch will turn on and off each relay in turn. We use the addressing format described in table 1.4 of the MCP23017 data sheet,  The relays 1 to 8 are controlled by “bank A” of the MCP23017 – so we need to set that to output in our sketch, as shown below:

// Example 47.1
#include "Wire.h" // for I2C bus
#define I2C_ADDR 0x20 // 0x20 is the address with all jumpers removed
void setup()
{
 Wire.begin(); // Wake up I2C bus
 // Set I/O bank A to outputs
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x00); // IODIRA register
 Wire.write(0x00); // Set all of bank A to outputs
 Wire.endTransmission();
}
int period = 500;
void loop()
{
 byte relay = 1;
 for (int i=1; i<9; i++)
 {
 // turn on relay 
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x12); // Select bank A
 Wire.write(relay); // Send value to bank A
 Wire.endTransmission(); 
 delay(period);
// turn off all relays
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x12); // Select bank A
 Wire.write(0); // Send value to bank A
 Wire.endTransmission(); 
 delay(period);

 relay = relay * 2; // move to next relay
 }
}

The sketch simply sends the values of 1, 2, 4, 8, 16, 32, 64 and 128 to the shield – each value in turn represents relays 1 to 8. We send 0 to turn off all the relays. Here’s a quick video showing it in action – the LEDs on the shield show the relay coil power status:

Now there is one small caveat – every time you send a new command to the MCP23017, it overwrites the status of the whole bank of pins. For example if relay 3 is on, and we send the value 2 – this will turn on relay 2 and turn off 3. Why? Because the values are converted to binary when heading down to the relay shield. So if we send 1, in binary this is:

00000001

which turns on relay 1 – and turns off relays 2 to 7. But then if we send 4 to turn on relay 3, in binary this is:

00000100

which turns on relay 3, but turns off relays 1, 2, and 4 to 8. So how do we turn on or off all eight relays at once? Just do a little binary to decimal conversion. Let’s say you want relays 1, 3, 5 and 7 on – and 2, 4, 6 and 8 off. In binary our command value would be:

01010101

and in decimal this is 85. Want to turn them all on at once? Send 255. Then all off? Send zero.

Now let’s do it via the Internet…

You’re going to need an Ethernet-enabled Arduino board. This could involve adding an Ethernet shield to your existing board, or using an all-in-one board like the Freetronics EtherTen. We will now use the teleduino service created by Nathan Kennedy to send commands to our Arduino boards via the Internet. At this point, please review and understand the teleduino article – then, when you can successfully control a digital output pin – return here to continue.

First, get the hardware together. So ensure your relay shield is in the Arduino and you have uploaded the

TeleduinoEthernetClientProxy.ino

sketch. For the first couple of times, it’s good to still have the teleduino status LED connected – just to keep an eye on it. Plug your Arduino into your router and the power. After it connects to teleduino (four blinks of the status LED) we have to send three commands via http. The first tells teleduino that we’re sending I2C commands. You only do this once after every Arduino reset or power-up situation. It is:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999r=defineWire

Remember to replace 999999 with your teleduino key. Then we send:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%00%00

At this stage the relay shield is now ready to accept your bytes to turn on and off the outputs. Again, just like the sketch – we send two bytes. For example:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%FF

turns on all the outputs – however with the URL we need to send the byte representing the outputs in hexadecimal. So 255 is FF, 0 is 0, etc. For example to turn them all off, use:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%00

or to turn on outputs 1, 2, 3 and 4 use:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%0F

Simple. You can simply bookmark your URLs for later use as well – and don’t forget to use a URL-shortener such as bit.ly to makes things simpler for you.

Conclusion

Now you have a way to control many relays either locally or remotely over the Internet. I hope you found this article useful or at least interesting. If you have any suggestions for further articles (and not thinly-veiled methods of asking me to do your work for you…) – email them to john at tronixstuff dot com. Thanks to Freetronics for the use of their hardware and Nathan Kennedy for teleduino, his support and advice.

LEDborder

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, or join our 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 Internet-controlled relays with teleduino and Freetronics RELAY8: appeared first on tronixstuff.

Set
14

Internet-controlled relays with teleduino and Freetronics RELAY8:

arduino, ethernet, freetronics, i2c, internet, lesson, lessons, Relay, relay8:, shield, teleduino, tronixstuff, tutorial, tutorials Commenti disabilitati su Internet-controlled relays with teleduino and Freetronics RELAY8: 

This is chapter forty-seven of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 24/11/2012

In this article we’re going to look at controlling relays over the Internet. In doing so you will then be able to turn almost anything on and off as long as you have http access on an Internet-enabled device. Why would you want to do this? Connect an outdoor light – and turn it on before arriving home. Control the power to your TV setup – then you can control childrens’ TV viewing at a whim. Control farm water pumps without getting out of the truck. We’ll break this down into two stages. First we’ll explain how the RELAY8: relay control shield works and control it locally, then control it remotely using the teleduino service. We will be using Arduino IDE v1.0.1.

This tutorial will assume you have an understanding from three other articles – so please have a quick read of I2C bus, the MCP23017 I/O expander and teleduino. But don’t panic – we’ll try and keep it simple here.

The RELAY8: shield

First – our relay shield. We’ll be using the Freetronics RELAY8: shield:

Using the RELAY8: you can control eight relays using the I2C bus and the MCP23017 I/O expander – which saves your digital outputs for other purposes. There are three hardware settings you need to consider when using the shield:

  1. Power – how will you power the relay coils?
    • You can directly connect between 5 and 24V DC using the terminal block on the right-hand side of the shield – great for stronger relay coils.
    • You can power the relay coils using power from the Arduino. So whatever power is going to the Arduino Vin can power the shield. To do this jumper the two pins next to the Vin shield connector. In doing so – you must check that the combined current draw of all your relays on at once will not exceed what is available to the Arduino. Usually OK when using solid-state relays, as most examples use around 15mA of current to activate. However double-check your relay specifications before doing so.
    • You can also power the Arduino board AND the shield by feeding in external power to the shield and jumpering the two pins described above
  2. Which I2C address to use for each shield? By default it is 0×20. However you can alter the last three bits of the address by changing the jumpers at the bottom-left of the shield. Each jumper represents one bit of the bus address – no jumper means zero, and a jumper means one. So if you jumper ADDR0, the address will be 0×21 – etc. Using this method you can then stack up to eight shields – and control 64 relays!
  3. Are you using an Arduino Leonardo board? If so – your shield I2C pins aren’t A4/A5 – they’re over near the top of the board:

However this isn’t a problem. Solder in some header pins to the shield’s SCL/SDA holes (next to AREF). Then turn over the RELAY8: board and you will see some solder pads as shown below. With a thin knife, cut the copper tracks shown with the blue lines:

Doing this will redirect the I2C bus from the microcontroller to the correct pins at the top-left.

Once you have decided on your power and I2C-bus options, it’s time to connect the relays. Doing so is simple, just connect the +  and – from the relay coil to the matching position on your RELAY8: shield, for example:

Today we’re just using prototyping wires, so when creating a permanent installation ensure the insulation reaches the terminal block. When working with relays you would use a diode across the coil to take care of back-EMF – however the shield has this circuitry, so you don’t need to worry about that at all. And if you’re wanting to control more than one shield – they stack nicely, with plenty of clearance between shields, for example:

Now to test the shield with a quick demonstration. Our sketch will turn on and off each relay in turn. We use the addressing format described in table 1.4 of the MCP23017 data sheet,  The relays 1 to 8 are controlled by “bank A” of the MCP23017 – so we need to set that to output in our sketch, as shown below (download sketch):

// Example 47.1
#include "Wire.h" // for I2C bus
#define I2C_ADDR 0x20 // 0x20 is the address with all jumpers removed
void setup()
{
 Wire.begin(); // Wake up I2C bus
 // Set I/O bank A to outputs
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x00); // IODIRA register
 Wire.write(0x00); // Set all of bank A to outputs
 Wire.endTransmission();
}
int period = 500;
void loop()
{
 byte relay = 1;
 for (int i=1; i<9; i++)
 {
 // turn on relay 
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x12); // Select bank A
 Wire.write(relay); // Send value to bank A
 Wire.endTransmission(); 
 delay(period);
// turn off all relays
 Wire.beginTransmission(I2C_ADDR);
 Wire.write(0x12); // Select bank A
 Wire.write(0); // Send value to bank A
 Wire.endTransmission(); 
 delay(period);

 relay = relay * 2; // move to next relay
 }
}

The sketch simply sends the values of 1, 2, 4, 8, 16, 32, 64 and 128 to the shield – each value in turn represents relays 1 to 8. We send 0 to turn off all the relays. Here’s a quick video showing it in action – the LEDs on the shield show the relay coil power status:

Now there is one small caveat – every time you send a new command to the MCP23017, it overwrites the status of the whole bank of pins. For example if relay 3 is on, and we send the value 2 – this will turn on relay 2 and turn off 3. Why? Because the values are converted to binary when heading down to the relay shield. So if we send 1, in binary this is:

00000001

which turns on relay 1 – and turns off relays 2 to 7. But then if we send 4 to turn on relay 3, in binary this is:

00000100

which turns on relay 3, but turns off relays 1, 2, and 4 to 8. So how do we turn on or off all eight relays at once? Just do a little binary to decimal conversion. Let’s say you want relays 1, 3, 5 and 7 on – and 2, 4, 6 and 8 off. In binary our command value would be:

01010101

and in decimal this is 85. Want to turn them all on at once? Send 255. Then all off? Send zero.

Now let’s do it via the Internet…

You’re going to need an Ethernet-enabled Arduino board. This could involve adding an Ethernet shield to your existing board, or using an all-in-one board like the Freetronics EtherTen. We will now use the teleduino service created by Nathan Kennedy to send commands to our Arduino boards via the Internet. At this point, please review and understand the teleduino article – then, when you can successfully control a digital output pin – return here to continue.

First, get the hardware together. So ensure your relay shield is in the Arduino and you have uploaded the

TeleduinoEthernetClientProxy.ino

sketch. For the first couple of times, it’s good to still have the teleduino status LED connected – just to keep an eye on it. Plug your Arduino into your router and the power. After it connects to teleduino (four blinks of the status LED) we have to send three commands via http. The first tells teleduino that we’re sending I2C commands. You only do this once after every Arduino reset or power-up situation. It is:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999r=defineWire

Remember to replace 999999 with your teleduino key. Then we send:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%00%00

At this stage the relay shield is now ready to accept your bytes to turn on and off the outputs. Again, just like the sketch – we send two bytes. For example:

 https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%FF

turns on all the outputs – however with the URL we need to send the byte representing the outputs in hexadecimal. So 255 is FF, 0 is 0, etc. For example to turn them all off, use:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%00

or to turn on outputs 1, 2, 3 and 4 use:

https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%0F

Simple. You can simply bookmark your URLs for later use as well – and don’t forget to use a URL-shortener such as bit.ly to makes things simpler for you.

Conclusion

Now you have a way to control many relays either locally or remotely over the Internet. I hope you found this article useful or at least interesting. If you have any suggestions for further articles (and not thinly-veiled methods of asking me to do your work for you…) – email them to john at tronixstuff dot com. Thanks to Freetronics for the use of their hardware and Nathan Kennedy for teleduino, his support and advice.

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, or join our 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.


Giu
12

Interact with Arduino over the Internet with Teleduino

api, arduino, control, ethermega, ethernet, etherten, freetronics, internet, ip, lesson, remote, teleduino, tutorial Commenti disabilitati su Interact with Arduino over the Internet with Teleduino 

Introduction

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 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:

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 post Interact with Arduino over the Internet with Teleduino appeared first on tronixstuff.

Giu
12

Interact with Arduino over the Internet with Teleduino

api, arduino, control, ethernet, etherten, freetronics, internet, ip, remote, teleduino Commenti disabilitati su Interact with Arduino over the Internet with Teleduino 

Introduction

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). At this stage Teleduino doesn’t support other boards such as the Mega.
  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
TeleduinoEthernetClientProxy.ino

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

… 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

// User configurable variables

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

http://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=getVersion

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:

http://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=definePinMode&pin=6&mode=1

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:

http://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setDigitalOutput&pin=6&output=1

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

output=0

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.



  • 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