aiuto per webserver

buongiorno a tutti,
vi scrivo perchè non riesco a vedere più il mio arduino in rete...
il problema è nato con il passaggio alla versione IDE arduino 1.0...
dichiaravo i parametri x la rete

byte mac[] = { 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- };
byte ip[] = { 192, 168, 1, 128 };
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = {255, 255, 255, 0};

Server server(80);
void setup(){
Ethernet.begin(mac, ip, subnet, gateway);
....

void loop(){
Client client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
readString.concat(c);
if (c == '\n' && currentLineIsBlank){
valore = analogRead(A0);
Serial.println(valore);
// INIZIO DICHIARAZIONE PAGINA HTML
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("");
client.println("");

e poi facevo fare delle operazioni...
ora con la versione 1.0 ho fatto l'upload dello sketch webserver base e nulla....
qualcuno sa cosa fare?
grazie mille

Il mac-address l'hai indicato così per non pubblicarlo o hai compilato lo sketch im quel modo?

byte mac[] = { 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- };

A parte quello, non vedo le librerie, non capisco perché si debba passare a 1.0 quando ci sono le nuove release

Prova a compilare ed eseguire questo codice inserendo il giusto mac address al posto di FF FF FF FF FF FF.
Se hai un router con server DHCP abilitato sulla seriale dovresti leggere i vari parametri.

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

void setup() 
{
  Serial.begin(9600);
  Serial.println("Start!");
  // start Ethernet
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  else
  {
    Serial.println("Ethernet configured using DHCP");
    Serial.print("Local IP: ");
    Serial.println(Ethernet.localIP());
    Serial.print("SubnetMask: ");
    Serial.println(Ethernet.subnetMask());
    Serial.print("Gateway: ");
    Serial.println(Ethernet.gatewayIP()); 
    Serial.print("DNS Server: ");
    Serial.println(Ethernet.dnsServerIP());
  }
}

void loop()
{
}

Comunque il codice del WebServer versione 1.0 è:

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // 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 analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

grazie mille per avermi risposto!
il mac nn l'ho messo x non comunicarlo in rete XD ..
ho scritto lo sketch e cosa mooooooooooolto strana non entra nè nell'if nè nell'else!!! :astonished: :astonished: :astonished:
esce scritto solo

Start!

non mi esegue l' Ethernet.begin $)

Sostituisci il mac del listato (FF FF FF FF FF FF) con il tuo.

ovviamente avevo messo il mio :smiley:

questo è il codice :
metto un fake mac ma nel compilare qll reale
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- };
IPAddress ip(192,168,1, 45);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192,168,1, 1);
int a=1;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac,ip,dns,gateway,subnet);
Serial.println("Start!");
}

void loop()
{
Serial.print("Local IP al ciclo numero ");
Serial.print(a);
Serial.print(" : ");
Serial.println(Ethernet.localIP());
Serial.print("SubnetMask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("Gateway: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("DNS Server: ");
Serial.println(Ethernet.dnsServerIP());
delay(1000);
a=a+1;
}

l'output è :

Local IP al ciclo numero 1 : 0.0.0.0
SubnetMask: 0.0.0.0
DNS Server: 192.168.1.1
e va avanti all'infinito...
ricordo che mi da qst problema solo con la versione 1.0 mentre se usavo le vecchie dichiarazioni di ip etc con la 022 andava tutto

il tasto reset fa miracoli... grazie a tutti

michelegnocchi:
il tasto reset fa miracoli... grazie a tutti

:fearful: XD XD