Hi, i have a arduino mega and a w5100 ethernetshield, after resetting the modem i can get on the server using 4g on my phone. When i power down arduino for a couple of minutes and then start it up again it wont let me connect with the ethernetshield shield anymore. Only lokal network is eble to connect, 4g dont.
The time for my ip which start with 213 is taking to long to respond, that is what google chrome is telling me.
After rebooting the modem i can connect with 4g again...
How to solve this?
Code: [Select]
//zoomkat 1-10-11
//web LED code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html
//address will look like http://192.168.1.102:84/ when submited
//for use with W5100 based ethernet shields
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0x22, 0x22, 0x34, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 0,25);
//byte gateway[] = {
//192,168,0,1
//};
byte gateway[] = {
192,168,0,1
};
byte subnet[] = {
255,255,255,0
};
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(903); //server port
String readString;
//////////////////////
void setup(){
pinMode(22, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
Serial.println("servertest1"); // so I can keep track of what is loaded
}
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c); //uncomment to see in serial monitor
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString);
//now output HTML data header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>HTML form GET example</H1>");
client.println("<FORM ACTION=\"http://213.**.**.**:903\" method=get >");
client.println("Pin 4 \"on\" or \"off\": <INPUT TYPE=TEXT NAME=\"LED\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\">
");
client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\"Change Pin 4!\">");
client.println("</FORM>");
client.println("
");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
/////////////////////
if(readString.indexOf("1005") >0)//checks for on
{
digitalWrite(22, HIGH); // set pin 4 high
Serial.println("Led On");
}
if(readString.indexOf("10051990") >0)//checks for off
{
digitalWrite(22, LOW); // set pin 4 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}