Pages: [1] 2   Go Down
Author Topic: Ethernet library -- Smaller and more functional  (Read 9209 times)
0 Members and 1 Guest are viewing this topic.
New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm wanting to make other people aware of the work Peter from tinker.it London has been doing on shrinking the size of the Ethernet library and adding additional functionality. The code is available here:

Arduino Ethernet2 library

Now, I'm pretty sure he wanted me to sign a whole load of disclaimers about it being untested before agreeing to me posting about it but I think it's important work and think others would be interested in trying it out.

I haven't yet tested it out but wanted to post about it before I forgot to do so again. :-)

--Phil.
« Last Edit: February 01, 2009, 09:42:23 am by follower » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, please test it out and let me know how it works.  I'd love to have a smaller library but didn't want to include it until it was tested (and I didn't have time to do it).
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just used the Ethernet2 library for the first time and my sample code seemed to function the same as with the original Ethernet library. Obviously there could be some subtle incompatibly I'm not seeing but certainly IWFM at the moment.

Size difference:

  7810 bytes (with Ethernet2)

10252 bytes (with original Ethernet)

So, currently a saving of ~2.5KB it seems.

Would be worth other people trying it out.

--Phil.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, please.  Anyone else?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ethernet2 works great for me. I am also getting just over 2.5k smaller code compared to the official ethernet library.
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

for how long did you get the arduino working without a reset?
With the old libary I only get around 12 hours without a hanging, I hope this libary hasn't got this bug...

Thx
Geko
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Geko,

I didn't test uptime. Would you be able to test the Ethernet2 library with your project for us?

If you need assistance to do so, let us know. :-)

--Phil.
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thx Phil

I just starated the projrct and I will give you some feedback when something strange happend...

Thx
Geko
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would love to test it ... just have a quick question ... If I copy the client, server, ethernet2, and print files to a folder named ethernet2 in my libraries folder then all I have to do is change the #include <Ethernet.h> to #include <Ethernet2.h> ???
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To make this easier for people to try I out I have exported revision 43 of the code from the SVN repository and zipped it up*.

You should be able to unzip the archive and then place the Ethernet2 folder and content in your libraries directory. Then you can change your include line to be Ethernet2 and it should work.

Here is the Ethernet2 library zip file.

--Phil.

* I used svn export http://tinkerit.googlecode.com/svn/trunk/Ethernet2\ library tinkerit-ethernet2-read-only to do so.
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm after 7 hours the arduino does hang.... But why????

This is my code:
Code:
#include <Ethernet2.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
  192, 168, 0, 177 };
byte server[] = {
  111, 111, 111, 111 };
unsigned long lastmillis = -300000;
long sek = 300;
int s1;
float s2;
int s3;
int incomingByte;
int count_i = 0;
Client client(server, 80);

void setup(){
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("Start!");  
  delay(1000);
}

void loop(){  


  if (millis() >= (lastmillis + (sek * 1000))){
    Ethernet.begin(mac, ip);
    if (client.connect()){
      client.print("GET MYSITE/daten_mysql.php?s1=");
      s1 = (analogRead(0) * 1000.0)/1023.0;
      if ((long)s1 >= 50){        
        client.print((long)s1);
      }
      else{
        client.print("0");
      }
      client.print("&s2=");
      s2 = ((((analogRead(1) * 1000.0)/1023.0)/(1000.0))*222.22)-61.11;
      client.print((long)(s2*10));
      client.print("&s3=");
      s3 = ((((analogRead(2) * 1000.0)/1023.0)/1000.0)*190.6)-40.2;
      client.print((long)(s3*10));
      client.println();
      lastmillis = millis();
    }
  }

}


The loop funcion is quite easy. As soon as 5 minutes are over arduino is going to a Webpage with a MYSQL Database and stores 3 Sensor values to this Database. That's it.
What's wrong about that???

Thx
Geko
« Last Edit: February 26, 2009, 03:21:38 am by GekoCH » Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wonder if you are running Arduino 0011 and millis is overflowing.

Anyway, why not replace:
  if (millis() >= (lastmillis + (sek * 1000)))
with
  delay(sek * 1000) ;
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thx, but I think it isn't a millis overflow. Yes I use the Arduino 0011 does this one have a problem with millis()??

Thx
Geko
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I recall millis() overflowed after 9 hours in Arduino  0011.  Why not try to use delay instead, if only see if that makes the problem go away.
« Last Edit: February 26, 2009, 07:06:11 am by mem » Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ok this migth work but I got further code... For example an XBee wich is receiving data from other stations...
And the server will answer to the data I sent...

Geko
« Last Edit: February 26, 2009, 07:23:14 am by GekoCH » Logged

Pages: [1] 2   Go Up
Jump to: