Arduino Ethernet shield probléma
Arduino Ethernet shield probléma
Üdv
Vásároltam egy "Ethernet Wiznet shield (W5100 chip, LAN)" -t. Írtam rá egy kódot, de nem működik. Olvasgattam fórumokat, de nem találtam megoldást a problémámra. Itt a kód amit írtam:
http://pastebin.com/mcvNsFSJ
A soros monitoron pedig mindig 0.0.0.0 -t kapok local ip címnek. Valaki tudja, hogy mi a hiba?
Köszönettel
Vásároltam egy "Ethernet Wiznet shield (W5100 chip, LAN)" -t. Írtam rá egy kódot, de nem működik. Olvasgattam fórumokat, de nem találtam megoldást a problémámra. Itt a kód amit írtam:
http://pastebin.com/mcvNsFSJ
A soros monitoron pedig mindig 0.0.0.0 -t kapok local ip címnek. Valaki tudja, hogy mi a hiba?
Köszönettel
Re: Arduino Ethernet shield probléma
A kód (pastebinről):
Milyen oprendszer?
Melyik verziójú Arduino?
Milyen alappanel?
Arduino-0023 ill Arduino-1.0.3 esetén a Webszerver DEMO mit mond?
Kód: Egész kijelölése
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192,168,1,177);
EthernetServer server(80);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac,ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
}Milyen oprendszer?
Melyik verziójú Arduino?
Milyen alappanel?
Arduino-0023 ill Arduino-1.0.3 esetén a Webszerver DEMO mit mond?
Re: Arduino Ethernet shield probléma
Windows 8.1 64bit
Arduino 1.6.4
UNO R3
1.6.4 alatt ugyan úgy 0.0.0.0, ha kiíratom, 1.0.3 esetén szintén..
Arduino 1.6.4
UNO R3
1.6.4 alatt ugyan úgy 0.0.0.0, ha kiíratom, 1.0.3 esetén szintén..
Kód: Egész kijelölése
/* Web_Demo.pde -- sample code for Webduino server library */
/*
* To use this demo, enter one of the following USLs into your browser.
* Replace "host" with the IP address assigned to the Arduino.
*
* http://host/demo
*
* This URL brings up a display of the values READ on digital pins 0-9
* and analog pins 0-5. This is done with a call to defaultCmd.
*
*
* http://host/demo/form
*
* This URL also brings up a display of the values READ on digital pins 0-9
* and analog pins 0-5. But it's done as a form, by the "formCmd" function,
* and the digital pins are shown as radio buttons you can change.
* When you click the "Submit" button, it does a POST that sets the
* digital pins, re-reads them, and re-displays the form.
*
*/
#include "Ethernet.h"
#include "WebServer.h"
// no-cost stream operator as described at
// http://sundial.org/arduino/?page_id=119
template<class T>
inline Print &operator <<(Print &obj, T arg)
{ obj.print(arg); return obj; }
// CHANGE THIS TO YOUR OWN UNIQUE VALUE
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// CHANGE THIS TO MATCH YOUR HOST NETWORK
static uint8_t ip[] = { 192, 168, 1, 64 };
#define PREFIX "/demo"
WebServer webserver(PREFIX, 80);
// commands are functions that get called by the webserver framework
// they can read any posted data from client, and they output to server
void jsonCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
if (type == WebServer::POST)
{
server.httpFail();
return;
}
server.httpSuccess(false, "application/json");
if (type == WebServer::HEAD)
return;
int i;
server << "{ ";
for (i = 0; i <= 9; ++i)
{
// ignore the pins we use to talk to the Ethernet chip
int val = digitalRead(i);
server << "\"d" << i << "\": " << val << ", ";
}
for (i = 0; i <= 5; ++i)
{
int val = analogRead(i);
server << "\"a" << i << "\": " << val;
if (i != 5)
server << ", ";
}
server << " }";
}
void outputPins(WebServer &server, WebServer::ConnectionType type, bool addControls = false)
{
P(htmlHead) =
"<html>"
"<head>"
"<title>Arduino Web Server</title>"
"<style type=\"text/css\">"
"BODY { font-family: sans-serif }"
"H1 { font-size: 14pt; text-decoration: underline }"
"P { font-size: 10pt; }"
"</style>"
"</head>"
"<body>";
int i;
server.httpSuccess();
server.printP(htmlHead);
if (addControls)
server << "<form action='" PREFIX "/form' method='post'>";
server << "<h1>Digital Pins</h1><p>";
for (i = 0; i <= 9; ++i)
{
// ignore the pins we use to talk to the Ethernet chip
int val = digitalRead(i);
server << "Digital " << i << ": ";
if (addControls)
{
char pinName[4];
pinName[0] = 'd';
itoa(i, pinName + 1, 10);
server.radioButton(pinName, "1", "On", val);
server << " ";
server.radioButton(pinName, "0", "Off", !val);
}
else
server << (val ? "HIGH" : "LOW");
server << "<br/>";
}
server << "</p><h1>Analog Pins</h1><p>";
for (i = 0; i <= 5; ++i)
{
int val = analogRead(i);
server << "Analog " << i << ": " << val << "<br/>";
}
server << "</p>";
if (addControls)
server << "<input type='submit' value='Submit'/></form>";
server << "</body></html>";
}
void formCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
if (type == WebServer::POST)
{
bool repeat;
char name[16], value[16];
do
{
repeat = server.readPOSTparam(name, 16, value, 16);
if (name[0] == 'd')
{
int pin = strtoul(name + 1, NULL, 10);
int val = strtoul(value, NULL, 10);
digitalWrite(pin, val);
}
} while (repeat);
server.httpSeeOther(PREFIX "/form");
}
else
outputPins(server, type, true);
}
void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
outputPins(server, type, false);
}
void setup()
{
Serial.begin(9600);
// set pins 0-8 for digital input
for (int i = 0; i <= 9; ++i)
pinMode(i, INPUT);
pinMode(9, OUTPUT);
Ethernet.begin(mac, ip);
webserver.begin();
webserver.setDefaultCommand(&defaultCmd);
webserver.addCommand("json", &jsonCmd);
webserver.addCommand("form", &formCmd);
Serial.begin(9600);
Serial.println(Ethernet.localIP());
}
void loop()
{
// process incoming connections one at a time forever
webserver.processConnection();
// if you wanted to do other work based on a connecton, it would go here
}Re: Arduino Ethernet shield probléma
Arduino 1.0.5
Ethernet könyvtár-ból
Webserver
Ethernet könyvtár-ból
Webserver
Kód: Egész kijelölése
/*
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
*/
#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() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
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 disonnected");
}
}
Re: Arduino Ethernet shield probléma
A D13-12-11-10 lábakon ne legyen semmi, csak az eth. Shield.
A csatlakozás a D13...D10 és a ICSP csatlakozón át is legyen meg.
Fontos! Egyes paneleken a UTP csati és az USB csatlakozó fémháza összeérhet!
A csatlakozás a D13...D10 és a ICSP csatlakozón át is legyen meg.
Fontos! Egyes paneleken a UTP csati és az USB csatlakozó fémháza összeérhet!
Re: Arduino Ethernet shield probléma
Így is ugyan az az eredmény... A shield MAC címét honnan tudom megszerezni?
Nincs meg a kellő jogosultságod a hozzászóláshoz csatolt állományok megtekintéséhez.
Re: Arduino Ethernet shield probléma
Nincs MAC címe. A Szoftverben adod meg neki.
Kód: Egész kijelölése
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };Re: Arduino Ethernet shield probléma
Igen azt értem, csak olvastam egy fórumon, hogy a shielden kellene, hogy rajta legyen. Szóval random mac címet is adhatok?
Re: Arduino Ethernet shield probléma
A "TX" és az "RX" ledek nem világítanak. Lehet esetleg hardware hiba?
Re: Arduino Ethernet shield probléma
Random cím adható.
A W5100 chipnek _nincs_ fix MAC címe.
Tx/Rx a hálózati kábel bedugásakor világít ill. adatforgalom esetén. Még INIT után sem.
Tipp: Az SD kártya kezelés megy? (Ezzel a SPI busz ellenőrizhető ill. a 3V3 tápfesz)
A W5100 chipnek _nincs_ fix MAC címe.
Tx/Rx a hálózati kábel bedugásakor világít ill. adatforgalom esetén. Még INIT után sem.
Tipp: Az SD kártya kezelés megy? (Ezzel a SPI busz ellenőrizhető ill. a 3V3 tápfesz)
Re: Arduino Ethernet shield probléma
Az SD kezelés tökéletesen működik! Egyéb ötlet?

Re: Arduino Ethernet shield probléma
Feltöltöttem egy WebServer példaprogramot és megfigyeltem, hogy ugye a shield egy routerhez csatlakozik, és a laptop is, ha a laptopból kihúzom az UTP-t, majd visszadugom akkor elkezdnek villogni a shielden a TX és RX ledek. (gondolom van valamiféle adatforgalom) Viszont a böngészőből nem tudom elérni a shieldet és szintúgy 0.0.0.0 -t ír ki a soros monitor. Ha a D10 nincs csatlakoztatva az alappanelhez akkor 255.255.255.255 -t ír ki 
Re: Arduino Ethernet shield probléma
A panelen a mosi/miso/sck/cs vonalak be vannak "ragadva". En zarlatot, forrasztasi hibat keresnek ill tesztrlnem h az sd kartya mit csinal.
Re: Arduino Ethernet shield probléma
Az SD-vel tudok írni/olvasni is!
Re: Arduino Ethernet shield probléma
Sziasztok,
ugyan ez a problémám nekem is, esetleg valami megoldás született? SD kártyával minden ok, de az ethernet nem működik 0.0.0.0 - 255.255.255.255ig random kapok IP címet.... ötlet?
ugyan ez a problémám nekem is, esetleg valami megoldás született? SD kártyával minden ok, de az ethernet nem működik 0.0.0.0 - 255.255.255.255ig random kapok IP címet.... ötlet?
