arduino eth v2 webserver niet werkend

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

  • infinite-reflex
  • Registratie: December 2017
  • Laatst online: 21-02-2022
Mijn vraag
onlang heb ik van robotdyn een arduino eth v2 wiznet5500 bordje gekocht omdat
ik een project in het hoofd heb waar ik een ethernet verbinding voor nodig heb.
zonder ethernet is dit project zinloos.

ik ben met de voorbeelden van arduino bezig geweest en ik krijg het maar niet werkend.
arduino, plug en play my ass. u leest het al mijn frustratie is reeds code oranje.

wat het moet doen, data verzenden van gyro en nog wat sensorwerk over ethernet naar een hmi.
data verzenden via http leek mij het makkelijkste dus ik gebruik de ethernet.h webserver sketch.

na lang etteren ben ik inmiddels op dit punt beland.

arduino verkrijgt op dit moment van de router adres 192.168.0.10 verkregen uit een bind met mac.
dit adres staat in dmz op de router, router herkend mac en kent ook juiste ip toe.
serial output geeft ook aan ip toegekend via dhcp 192.168.0.10.

echter als ik ping geeft 192.168.0.4 antwoord met destination host unreachable, .4 is ook mijn pc waar
van ik de ping verstuur. browser faalt uiteraard dus ook.

na tientallen tuts en pages online hierover ben ik nog geen stap verder gekomen en ik sta op het punt het op
te geven. wie o wie kan mij de juiste hoek in sturen?

Alle reacties


Acties:
  • 0 Henk 'm!

  • Piepersnijder
  • Registratie: December 2009
  • Niet online
Heb je wel de juiste librarie gebruikt?
bijvoorbeeld https://github.com/per1234/EthernetMod/tree/W5x00

Acties:
  • 0 Henk 'm!

  • infinite-reflex
  • Registratie: December 2017
  • Laatst online: 21-02-2022
net geprobeerd, ik heb 2 ethernet voorbeelden nu in arduino.
de standaard ethernet voorbeelden en een nieuwe map ethernetmod(w5x00).

webserver uit ethernet geeft dit aan.
exit status 1
'class EthernetClass' has no member named 'hardwareStatus'

ethernetmod geeft dit aan.
exit status 1
Error compiling for board Arduino Leonardo ETH.

edit;
nu terug naar clean install van arduino 1.8.10 op windows 10

werkend met dit script.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi
 
 */

#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() {
// dit board werkt standaard op spi dus zetten we eerst de sd card uit hierna de w5500 aan. pin 4 en 10
  pinMode(4, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(4, LOW);
  digitalWrite(10, HIGH);
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          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();
    Serial.println("client disconnected");
  }
}


serial output is dit.

Ethernet WebServer Example
server is at 192.168.0.10

router zegt dit.


Host Name IP Address MAC Address Lease
HUAWEI_P20_lite-89a8c22b6 192.168.0.2 30:45:96:1A:F2:68 00:36:51
Galaxy-S8 192.168.0.3 04:D6:AA:3A:21:75 00:54:31
DESKTOP-CAS9OLB 192.168.0.4 04:92:26:D4:04:1F 00:39:53
WIZnetEFFEED 192.168.0.10 DE:AD:BE:EF:FE:ED 00:53:19
Samsung 192.168.0.5 CC:6E:A4:BD:A9:22 00:30:56
LAPTOP-VG5I525M 192.168.0.6 74:E5:F9:C2:74:50 00:59:59

output cmd

Pinging 192.168.0.10 with 32 bytes of data:
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.

Ping statistics for 192.168.0.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

browser.

The connection has timed out

The server at 192.168.0.10 is taking too long to respond.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

vooral verrasend is dat vlak nadat het ip verkregen is, link en act(leds) op mijn rj45 uit gaan en zo blijven.

als ik namelijk dit script draai krijg ik wel leds en een ping.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
  DHCP-based IP printer

  This sketch uses the DHCP extensions to the Ethernet library
  to get an IP address via DHCP and print the address obtained.
  using an Arduino Wiznet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13

  created 12 April 2011
  modified 9 Apr 2012
  by Tom Igoe
  modified 02 Sept 2015
  by Arturo Guadalupi

 */

#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[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

void setup() {
  pinMode(4, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(4, LOW);
  digitalWrite(10, HIGH);
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
}


serial output

Initialize Ethernet with DHCP:
My IP address: 192.168.0.10

ping output

Pinging 192.168.0.10 with 32 bytes of data:
Reply from 192.168.0.10: bytes=32 time<1ms TTL=128
Reply from 192.168.0.10: bytes=32 time<1ms TTL=128
Reply from 192.168.0.10: bytes=32 time<1ms TTL=128
Reply from 192.168.0.10: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.0.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

[ Voor 115% gewijzigd door infinite-reflex op 03-12-2019 18:39 . Reden: aanvullende info ]


Acties:
  • 0 Henk 'm!

  • Piepersnijder
  • Registratie: December 2009
  • Niet online
In het eerste voorbeeld geef je wel een ipadress op maar doe je er vervolgens niets mee.
verander dit ipadress eens in IPAddress ip(192, 168, 0, 15).
vervolgens wijzig Ethernet.begin(mac) in Ethernet.begin(mac, ip)

Acties:
  • 0 Henk 'm!

  • infinite-reflex
  • Registratie: December 2017
  • Laatst online: 21-02-2022
had ik al vaker geprobeerd maar om dit verhaal zo compleet mogelijk te maken,

router herkent geen arduino bord.
geeft geen lease vrij.
192.168.0.15 staat niet in mijn dhcp binds.

en dit komt uit de ping.

C:\Windows\System32>ping 192.168.0.15

Pinging 192.168.0.15 with 32 bytes of data:
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.
Reply from 192.168.0.4: Destination host unreachable.

Ping statistics for 192.168.0.15:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)

dus een fixed ip aandragen is tot nu toe een complete no go.
het verste kom ik nog door een ip adres via dhcp aan te vragen.
vandaar dat ik het script ook zo opgesteld heb.

vooral het feit dat ik met andere scripts wel door de router heen kom lijkt het mij duidelijk dat die
dus niet het probleem is maar eerder iets in het script icm dit bordje wat problemen geeft.

wat weer logisch klinkt aangezien ik met pin 4 en 10 moet switchen.
ook dit werd slechts mondjesmaat besproken online.

eigenlijk zoek ik iemand die exact dit bordje heeft en het wel werkend heeft gekregen.

Acties:
  • 0 Henk 'm!

  • Piepersnijder
  • Registratie: December 2009
  • Niet online
Ik gebruik ook een w5500 bordje aangesloten op een arduino due.
Dit werkt probleemloos.

Probeer ook eens de gateway in te stellen.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192, 168, 0, 15};
byte DNS[] = {8, 8, 8, 8}; // of de DNS van je router
byte gateway[] = {192, 168, 0, 1};
byte subnet[] = {255, 255, 255, 0};

Ethernet.begin(mac, ip, DNS, gateway, subnet);

Acties:
  • 0 Henk 'm!

  • infinite-reflex
  • Registratie: December 2017
  • Laatst online: 21-02-2022
blijft hetzelfde probleem.

geen ip, router herkent niets.
geen ping of browser mogelijk.

nog even snel een usb 3 ethernet controller opgezet, gegevens ingevuld... niks nada.
en dat jij een bordje op een due prikt en dat het werkt geloof ik onmiddelijk.
daarom dat ik dus ook deze weg wilde bewandelen omdat het zo makkelijk moet zijn.

ware het niet dat ik na onderzoek geen enkel bordje leonardo eth v2 werkend online heb gezien.
is hier dan onder de motorkap echt iets anders gedaan dan met de uno, due, mega etc etc?

Acties:
  • 0 Henk 'm!

  • Piepersnijder
  • Registratie: December 2009
  • Niet online
Ik gebruik een chinese w5500.

Afbeeldingslocatie: http://www.ries-hoogland.nl/download/w5500.jpg

Acties:
  • +1 Henk 'm!

  • Santford
  • Registratie: Juli 2004
  • Laatst online: 17:32

Santford

FP PowerMod
Dit bord gebruikt DIO-pinnen om de W5500 te initialiseren. Concreet wordt D11 van de Atmega gebruikt om een hoog signaal aan te bieden op de laag actieve reset ingang van de W5500:

https://robotdyn.com/pub/...ARDO-EthernetW5500-V2.pdf

Op de achterkant van het bord is een soort van jumper aanwezig, standaard zou 'RST' met '3.3V' verbonden moeten zijn, waarschijnlijk zit bij jou de soldeerverbinding tussen 'D11' en 'RST'.

Probeer eens in de code pin D11 als output te definiëren en hoog te zetten voor het initialiseren van de ethernet module:
code:
1
2
3
4
5
6
7
8
9
10
11
void setup() {
  pinMode(4, OUTPUT);       
  pinMode(11, OUTPUT);      
  pinMode(10, OUTPUT);      

  digitalWrite(4, LOW);     
  digitalWrite(11, HIGH);   
  digitalWrite(10, HIGH);

  [...]
}

Acties:
  • 0 Henk 'm!

  • cowandchicken
  • Registratie: September 2018
  • Laatst online: 10-02 22:23
je hebt zo'n smal ethernetprintje van Robotdym met zo'n 12 polige header erop?
Die gebruik ik ook op een custom made arduino mega bnoard (dus met een MEGA2560)
Ook hier werkt dat "gewoon"
Let wel even op de init pin inderdaad, ik neem aan dat je geen arduino bordje met een standaard ethernet shield gebruikt?
Naast de SPI heb je namelijk ook wat GPIO lijntjes inderdaad die de voorbeelden gaan er vanuit dat je de standaard arduino shield pinout gebruikt. Daar ging het bij mij even mis. In je eerste post ziet je router die wizznett module toch wel?
Ik weet niet of ping mogelijk genegeerd wordt door de whizznet dat zou ook nog kunnen.

Maar buitendat als je juist dingen wilt versturen is een webserver niet logisch.

Acties:
  • 0 Henk 'm!

  • infinite-reflex
  • Registratie: December 2017
  • Laatst online: 21-02-2022
met dank aan Santford voor het verlossende antwoord.

het robotdyn bordje met w5500 en sd card geintegreerd moet inderdaad iets anders behandeld worden dan de standaard arduino.

regel 1
altijd voeding aansluiten.

regel 2
stel je standaard aangesloten pinnen juist in.
op dit bord is het of sd of w5500.
zoals santford dus terecht aangaf, pin 4, 10 en 11.

regel 2
stel je netwerk configuratie goed in.

dan gaat je bordje met dit script werken.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi
 
 */

#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, 137, 10);

// 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() {
// dit board werkt standaard op spi dus zetten we eerst de sd card uit hierna de w5500 aan. pin 4 en 10 en 11 voor initialisatie
 
  pinMode(4, OUTPUT);       
  pinMode(11, OUTPUT);      
  pinMode(10, OUTPUT);      

  digitalWrite(4, LOW);     
  digitalWrite(11, HIGH);   
  digitalWrite(10, HIGH);
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");

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

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          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();
    Serial.println("client disconnected");
  }
}



ik wilde overigens liever via udp data versturen maar aangezien ik dit al niet eens werkend kreeg en ik meer ervaring met webservers heb dan ruwe data transmissie leek mij dit een eerste stap.

Acties:
  • 0 Henk 'm!

  • Santford
  • Registratie: Juli 2004
  • Laatst online: 17:32

Santford

FP PowerMod
Wat goed dat je het aan de praat hebt gekregen.
Leuk dat je laat weten dat het gelukt is met de oplossing erbij. 👍🏻
Pagina: 1