New Zealand
Offline
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« on: February 01, 2009, 09:39:47 am » |
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 libraryNow, 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
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #1 on: February 01, 2009, 02:34:39 pm » |
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
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« Reply #2 on: February 22, 2009, 10:23:04 am » |
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
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #3 on: February 22, 2009, 12:41:47 pm » |
Yes, please. Anyone else?
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #4 on: February 22, 2009, 05:47:53 pm » |
Ethernet2 works great for me. I am also getting just over 2.5k smaller code compared to the official ethernet library.
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Sr. Member
Karma: 0
Posts: 261
|
 |
« Reply #5 on: February 24, 2009, 02:58:49 am » |
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
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« Reply #6 on: February 24, 2009, 09:40:32 am » |
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
Sr. Member
Karma: 0
Posts: 261
|
 |
« Reply #7 on: February 24, 2009, 11:40:20 am » |
Thx Phil
I just starated the projrct and I will give you some feedback when something strange happend...
Thx Geko
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 28
I need more space !!! Everyone is closing in on me
|
 |
« Reply #8 on: February 24, 2009, 10:52:53 pm » |
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
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« Reply #9 on: February 24, 2009, 11:13:48 pm » |
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
Sr. Member
Karma: 0
Posts: 261
|
 |
« Reply #10 on: February 26, 2009, 12:44:10 am » |
hmm after 7 hours the arduino does hang.... But why???? This is my 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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #11 on: February 26, 2009, 03:24:09 am » |
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
Sr. Member
Karma: 0
Posts: 261
|
 |
« Reply #12 on: February 26, 2009, 06:49:30 am » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #13 on: February 26, 2009, 07:05:29 am » |
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
Sr. Member
Karma: 0
Posts: 261
|
 |
« Reply #14 on: February 26, 2009, 07:20:50 am » |
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
|
|
|
|
|
|