---

Wednesday, December 21, 2011

Freetronics EtherTen Review

If you have read some of my other blog posts, you will know that I am a bit of a fan of Freetronics.

They may not be the cheapest Arduino boards and shields, but the quality of both design and manufacture is of the highest standard.

This is a review of the Freetronics EtherTen board. This board effectively combines an Arduino Uno with an Ethernet shield. This board costs AUD 69.95 (about USD 70) which is cheaper than an Uno + Ethernet card (29.95 + 45.95 =  USD 79) and a lot smaller and more convenient.



Features
The EtherTen has a Micro SD slot (why would you need anything bigger?). This is very handy if you are using the EtherTen to serve a lot of content or are using it for any kind of data logging application.

Connection to your computer is by a miniUSB which saves space. There are various headers that allow you to do clever things like use PoE (Power over Ethernet) as well as status LEDs that let you know what's going on.

In common with all Ethernet devices it gets pretty warm, and I left my project (see below) running all night, with no ill effects.

The board functions just like an Arduino Uno + Ethernet shield. I used it on Arduino 1.0 and standard Ethernet library without having to change anything. It all just worked first time.

Conclusion

This is a terrific little board and if you have an Ethernet Arduino project in mind, I would recommend it over using separate Uno and Ethernet shield combination. Its cheaper and it will keep your Arduino sandwhich from looking like something Scooby-Doo would eat.

If you want to see how I used it in a little test project then read on....



Mini-Project

In reviewing a product, I always like to try it out with some little project I, rather than use simple example sketches, so I decided to try out an Ethernet Telegraph. A bit silly really, but the idea is that the EtherTen would act as a web server connected to my home hub (next to my desk) and would have a homemade Luxeon LED shield attached to it. Then when my beloved wanted to contact me, she could open a browser page (even from work if I open up the firewall) and type in a message, that would be relayed to me as the Luxeon LED flashing me in Morse Code.

I used to know a little Morse, but actually, I'd probably have to note it down then decode each letter. Still, thats not the point.

This is the web page:

Here is the shield attached to the EtherTen:


The shield is from my book '30 Arduino Projects for the Evil Genius'. I had to change the pin it uses from 11 (which is used by the EtherTen) to pin 8. Here are the schematic and protoshield layouts for the shield.



The sketch for all this is listed below. It is a modified version of a sketch from my book 'Programming Arduino' see page 74 for an explanation of the Morse part and Chapter 10 for the Ethernet part.

You may need to change the IP address on line 6, to something compatible with your home network.


#include <SPI.h>
#include <Ethernet.h>

int ledPin = 8;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
EthernetServer server(80);
char line1[256];
int dotDelay = 100;

char* letters[] = {
  ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",    // A-I
  ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",  // J-R
  "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."          // S-Z
};

char* numbers[] = {"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};


void setup()                 
{
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
}

void loop()
{
  EthernetClient client = server.available();
  if (client) 
  {
    while (client.connected()) 
    {
      readHeader(client);
      if (! pageNameIs("/"))
      {
        client.stop();  
        return;
      }
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println();
      // send the body
      client.println("<html><body>");
      client.println("<h1>Morse Sender</h1>");
      client.println("<form method='GET'>");  
      client.println("Message: &nbsp;&nbsp;&nbsp;");
      client.println("<input type='TEXT' name='m' size='100'>");        
      client.println("<input type='submit' value='Send Morse'/>");
      client.println("</form>");
      client.println("</body></html>");
      client.stop();            
      processHeader();
    }
  }
}

void processHeader()
{
  // header lloks like this:
  // GET /?m=Happy+Christmas HTTP/1.1
  // so Morse flash everything from [=] to [space]
  int n = strlen(line1);
  int i = 0;
  while (i < n && line1[i] != '=') i++; // skip to =
  while (i < n && line1[i] != ' ')
  {
    flashCharacter(line1[i]);
    i++;
  }
}

boolean pageNameIs(char* name)
{
   // page name starts at char pos 4
   // ends with space
   int i = 4;
   char ch = line1[i];
   while (ch != ' ' && ch != '\n' && ch != '?')
   {
     if (name[i-4] != line1[i])
     {
       return false;
     }
     i++;
     ch = line1[i];
   }
   return true;
}

void readHeader(EthernetClient client)
{
  // read first line of header
  char ch;
  int i = 0;
  while (ch != '\n')
  {
    if (client.available())
    {
      ch = client.read();
      line1[i] = ch;
      i ++;
    }
  }
  line1[i] = '\0'; 
  Serial.println(line1);
}

void flashCharacter(char ch)
{
    if (ch >= 'a' && ch <= 'z')
    {
      flashSequence(letters[ch - 'a']);
    }
    else if (ch >= 'A' && ch <= 'Z')
    {
      flashSequence(letters[ch - 'A']);
    }
    else if (ch >= '0' && ch <= '9')
    {
      flashSequence(numbers[ch - '0']);
    }
    else if (ch == '+')
    {
     delay(dotDelay * 4);      // gap between words  
    }
}

void flashSequence(char* sequence)
{
   int i = 0;
   while (sequence[i] != NULL)
   {
       flashDotOrDash(sequence[i]);
       i++;
   }
   delay(dotDelay * 3);    // gap between letters
}

void flashDotOrDash(char dotOrDash)
{
  digitalWrite(ledPin, HIGH);
  if (dotOrDash == '.')
  {
    delay(dotDelay);           
  }
  else // must be a -
  {
    delay(dotDelay * 3);           
  }
  digitalWrite(ledPin, LOW);    
  delay(dotDelay); // gap between flashes
}



Note: In the interests of transparency, Freetronics did supply me with a board for review, but I can honestly say that this has not biased my opinion of the board.


About the Author
These are my books. Click on the image below to find out more about them.





4 comments:

Anonymous said...

Hi Simon,

It is a nice board, from their website you can see they involve (end)users in the design of their product. Co-development I like that too.

Q: Are ther boxes to put this board in?

Rob Tillaart
PS, today your book arrived, ordered at amazon.de right before Christmas.

Simon Monk said...

I don't know about boxes. Apart from the Ethernet sticking up further than the normal USB-B socket, its the same size as an Uno. It would be interesting to know if anyone has tried one of these with this: http://www.sparkfun.com/products/10088

UK Dive Boy said...

hi Simon,

I like the Morse sketch! Pretty easy to make a http server on the arduino it seems.

In your Morse circuit, are those resistor values correct? 4ohm for the current limiting resistor into the LED seems low.

Assuming a 3v drop across the LED that leaves 2V pd across the resistor (5v supply) and so .5A current (v/are). Does the LED module have internal current limiting?

BTW, your layout diagram has both Rs labelled "R1".

Regards,
Rik.

Simon Monk said...

@UK Drive,

Its a 1W luxeon LED, so 0.5A at 3V is 1.5W - a bit on the high side, but then its flashing so duty cycle is quite low.

It copes and its oh so bright!