Pages: [1]   Go Down
Author Topic: Webserver on Freetronics Ethernet with POE board  (Read 1380 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I just got the Freetronics Ethernet with POE sheild and I'm trying to get the Webserver example to work with my arduino duemilanove.

So far I can't ping it and I can't get any response using curl

CCH-638775A:~ tomcat$ ping 192.168.0.196
PING 192.168.0.196 (192.168.0.196): 56 data bytes
Request timeout for icmp_seq 0
--- 192.168.0.196 ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
CCH-638775A:~ tomcat$ curl http//192.168.0.196


Some noob questions:
Can I use the Freetronics sheild as just an ethernet sheild (not using the POE feature)?

Are the jumpers irrelevant in this mode? If not, What jumper settings should I set?

I can load and run the Webserver sketch, and I've added some serial debug but it never gets past the

if(client) {

I've set the IP to
byte ip[] = { 192, 168, 0, 196 };

The host's IP is 192.168.0.197 which it received via DHCP.

I've left the mac to the default DEADBEAFFEED

Any ideas?


Logged

Melbourne, Australia
Offline Offline
Full Member
***
Karma: 1
Posts: 226
Cyborg-in-progress
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can I use the Freetronics sheild as just an ethernet sheild (not using the POE feature)?

Absolutely. The PoE header simply exposes the connections necessary to pass power to the shield / Arduino through the LAN cable, but if you leave the jumpers off the PoE header it does nothing at all and the shield should behave just like the official shield.

When you plug in the LAN connection do you see any of the LEDs illuminate? The normal behavior is for there to be about a 1 to 2 second delay while the Wiznet chip figures out the type of connection, then at least the LNK ("link") LED should illuminate, and possibly FDX ("full duplex") and 100 ("100 megabit") LEDs as well. Then if there's other traffic on the network (including your ICMP PING requests) the RX LED should flicker.

Does any of that stuff happen?
--
Jon
Freetronics: www.freetronics.com
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Jon, I left the two jumper's off. I see the status LEDs are on
LNK  on steady
100  on steady
FDX  on steady
COL off
RX   pulses irregularly
TX  pulses

The TX led flickers in correspondence to the ping requests,

Here's the sketch

Quote
/*
 * Web Server
 *
 * A simple web server that shows the value of the analog input pins.
 */

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//byte ip[] = { 10, 0, 0, 177 };
//byte ip[] = { 192, 168, 0, 196 };
byte ip[] = { 192, 168, 0, 196 };
Server server(80);

void setup()
{
    Serial.begin(9600);
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.println(ip[0], DEC);
  Serial.println(ip[1], DEC);
  Serial.println(ip[2], DEC);
  Serial.println(ip[3], DEC);
  Serial.println("WebServer init exit");
}

void loop()
{
  //Serial.println("loop enter");
  Client client = server.available();
  if (client) {
    Serial.println("got client");
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          // output the value of each analog input pin
          for (int i = 0; i < 6; i++) {
            client.print("analog input ");
            client.print(i);
            client.print(" is ");
            client.print(analogRead(i));
            client.println("<br />");
          }
          break;
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}

« Last Edit: September 03, 2010, 06:36:26 pm by ejy@summitbid.com » Logged

Melbourne, Australia
Offline Offline
Full Member
***
Karma: 1
Posts: 226
Cyborg-in-progress
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just tested this with a TwentyTen, Ethernet shield, and the exact same sketch (but with the IP address changed to suit my local network) and it worked perfectly.

Could you please open the serial console at 9600bps and see what messages you get after resetting the Arduino?
--
Jon
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dang. Still not working.  Cry

Please note that I've just upgrade my Arduino IDE to version 019 which requires the additional

#include <SPI.h>

Which I added to the sketch above.

Other elements of the system are a MacBook Pro w/ OSX 10.6.4

Also note that the mac is connected via my local wifi lan, and so the arduino is connected to the mac's ethernet port.

 I mounted the ethernet sheild with POE (no jumpers) to my Twenty ten.  
Then connected the ethernet cable between my computer (IP 192.168.0.199) and the ethernet sheild.
  Then connected the usb between my computer and the Twenty Ten



I compiled and loaded the sketch above into the Twenty Ten and got this:
192
168
0
196
WebServer init exit

I then did a reset and got this (again):
192
168
0
196
WebServer init exit

I then opened a command prompt on my computer and issued the commands:

Ping returns:
CCH-638775A:~ eyoung2297k$ ping 192.168.0.196
PING 192.168.0.196 (192.168.0.196): 56 data bytes
ping: sendto: Host is down
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

curl returns:
CCH-638775A:~ eyoung2297k$ curl http://192.168.0.196
curl: (7) couldn't connect to host

Any other ideas?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Works!!! When I connected the arduino + freetronics ethernet to my router I got the response from the arduino:

CCH-638775A:~ eyoung2297k$ curl http://192.168.0.196
analog input 0 is 522<br />
analog input 1 is 451<br />
analog input 2 is 428<br />
analog input 3 is 377<br />
analog input 4 is 316<br />
analog input 5 is 320<br />

I know I tried this before (the connection to the router), but I turned off mac address filtering this time. I'd added it to the table, but must have foo bar'd it. I'll have to verify that's the fix tomorrow.

This link made me decide to try the router again:
http://tronixstuff.wordpress.com/2010/09/12/moving-forward-with-arduino-%E2%80%93-chapter-16-ethernet/

This is with the Duemilanove. Tomorrow I'll try the Twenty Ten.

I've been trying it connected to my laptop till now, which I thought should work too...

Thanks for your help and patience!
 smiley-grin
« Last Edit: September 12, 2010, 01:27:40 am by ejy@summitbid.com » Logged

Melbourne, Australia
Offline Offline
Jr. Member
**
Karma: 6
Posts: 93
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi EddyTheJekyll
Thanks for sharing your experiences with the group. You have given me a couple of ideas to improve my Ethernet article. Keep an eye out in the next few days for chapter two  smiley http://tronixstuff.com/tutorials.
Logged

Check out my Arduino tutorials at http://tronixstuff.com/tutorials - Order my  Arduino book from http://nostarch.com/arduino

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...and I should add that the problem I had were related to mac address filtering on my router. Still not sure why that doesn't work, but I currently need to disable mac address filtering when using the arduino as ethernet ready.

Thanks!
Logged

Pages: [1]   Go Up
Jump to: