Shield Arduino Ethernet « new IDE » : Connexion impossible avec IP Publique
Bonjour,
Peut-être pourrez-vous me conseiller : Après plusieurs jours de recherche je n’arrive pas à trouver la solution pour me connecter de l’extérieur, avec mon adresse publique fixe Free, malgré la redirection de port, alors que tout se passe normalement en local.
OS : Windows XP SP3
IDE Arduino 1.7.8
Arduino UNO R3 (Officiel)
Shield Arduino Ethernet “newIDE” ->Implique les bibliothèques :
#include <Ethernet2.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp2.h>
Code compilé joint : Tutorial « WebServer » du site Arduino (Avec quelques ajouts de variables)
Box : FreeBox Révolution (Firmware à jour).
Je possède plusieurs caméras de surveillance un NAS Synology et 3 serveurs Web IPX-800 de GCE, pour lesquels j’ai fait les redirections de ports. Tout fonctionne parfaitement en local et de l’extérieur avec mon IP Fixe Free.
Redirection effectuée pour le Shield Ethernet Arduino New IDE :
IPAddress ip(192, 168, 0, 100);
EthernetServer server(700);
« Port redirigé sur la FreeBox » :
700 - 192.168.0.100 – 700
80 - 192.168.0.100 - 80
UNO + nouveau Shield Ethernet Arduino “ NewIDE” (officiels) + Code « WebServer » :
En local : J’accède parfaitement au serveur Arduino avec mon IPAD AIR ou mon iPhone :
Sur navigateur Google : 192.168.0.100:700 j’obtiens sans problème une page HTML avec les valeurs des 6 entrées analogiques de la UNO. Le shield reconnaît donc le port 700… J’obtiens le même résultat avec 192.168.0.100:80
Par contre si je souhaite me connecter de l’extérieur avec mon adresse publique comme je le fais avec mes webServeurs IPX800-V3, impossible alors que le port 700 est bien redirigé !
Dans le navigateur : « XX.XXX.XXX.XX :700 » //Adresse publique fixe
Réponse : Page Web inaccessible
ERR_CONNECTION_REFUSED
J’ai réalisé plusieurs codes Arduino avec des capteurs DHT22, BMP180, Tiny I2C RTC, Servo SG90 LCD 4x20, relais pompes et SEN0114 avec lecture « Serial »et LCD en local, mais jamais à distance.
J’ai certainement oublié quelque chose dans le code, car c’est la première fois que j’utilise un Shield Ethernet… Peut-être pouvez-vous m’aider ?
Cordialement.
[#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet2.h> //Carte shield Ethernet "new IDE" + Arduino UNO R3 (Arduino officiel))
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp2.h>
#include <util.h>
/*
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
*/
// 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, 0, 100);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(700);
int valueMap;
void setup() {
// 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 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);
valueMap=map(sensorReading,0,1023,0,5);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.println(sensorReading);
client.print("Tension : ");
client.println(valueMap);
client.print(" Volts");
client.println("
");
}
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");
}
}/code]