Si ton Arduino est derrière une box ou un routeur, il faut aussi que tu fasses une redirection de port. C'est à dire que les connexions entrantes arrivant sur ton routeur seront renvoyées vers l'Arduino. je ne peux 'en dire plus, la configuration est propre à chaque routeur...
Oui bien sur j'ai redirigé le port 80 comme précisé dans mon message.
J'ai bien vérifié que mon shield utilisé bien l'ip associé à la redirection.
Redirection qui fonctionne très bien dans le cas d'un serveur web hébergé sur ma machine (PC & non arduino), qui devient accessible depuis l’extérieur.
si tu est chez free , comme moi , le port 80 ne voulais pas marcher j'ai fais sur un autre !
après pour accéder de l’extérieur il faut faire avec l'ip de la box
type :
//ip distante http://88.xxx.xxx.xxx:8081 par exemple , pour moi sa a fonctioner comme sa , aprés je suis un novice la dedans donc c'est peut'etre pas cela!
avec webclient est ce que tu force l'adresse ip car la derniere mise a jour de la librairie prent en charge le DHCP et du cout il la demande a la box avec seulement l'adrese mac j'ai eu des souci la dessu aussi :Ethernet.begin(mac);
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
*/
#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 };
byte ip[] = { 192,168,1,19 };
byte server[] = { 94,23,253,8 }; // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
ARDUINO 1.01 - FONCTIONNE
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
modified 9 Apr 2012
by David A. Mellis
*/
#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 };
IPAddress server(94,23,253,8); // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
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:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET / HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}
je suis pas sur mais il me semble que c'est juste la librairie ethernet qui a changer (un peut plus grosse) est ce quelle ne fonctionnerai pas si tu la placer dans le répertoire de la version 023 ?
Quelle est la configuration IP de ton Arduino ?
DHCP ou statique ?
Si statique, il ne faut pas oublier de donner aussi
ip du routeur (gateway)
ip du serveur DNS (pour convertir les noms xxx.com en adresses ip)
Le plus simple étant le DHCP quoi configure tout tout seul.
Et si tu veux forcer l'adresse IP de ton Arduino, tu déclares dansta box un baud permanent qui affecte définitivement une adresse IP donnée (en dehors de la game DHCP) à l'adresse MAC de ta Duino.
Vue comme ça ^^ pas cool alors car j'ai un sield wifi et ehthernet que je ne pourrais donc pas utiliser en même temps à moins qu'on puisse changer l'adresse sur l'un des deux shields...