thanks for pointing that out im trying it out now
it still crashed
and pin 11,12,13,4 will eventually go to the sd card reader
while pins 5,6,8,9 are relays and pin 3 is a ir led while pin 7 is a ir receiver
i got
Oops! Google Chrome could not connect to turnmylightson.no-ip.org
Suggestions:
Go to no-ip.org
Try reloading the page
Search on Google:
it looks like its not connecting to the webserver or not sending the header or something
if i ping 192.168.1.177 it comes back
Pinging 192.168.1.177 with 32 bytes of data:
Reply from 192.168.1.177: bytes=32 time=4ms TTL=128
Reply from 192.168.1.177: bytes=32 time=2ms TTL=128
Reply from 192.168.1.177: bytes=32 time=1ms TTL=128
Reply from 192.168.1.177: bytes=32 time=1ms TTL=128
Ping statistics for 192.168.1.177:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 4ms, Average = 2ms
so its connecting to the arduino so it has to be something with sending the client.write commands to the server
Now I think I understand.
Do you have your public ip registered with no-ip?
Do you have your public ip interface sending port 80 requests to 192.168.1.177?
Can you access the Arduino from the internet by ip address?
Does your ISP block port 80 requests to non-commercial ip addresses? Mine does.
no-ip info>Host Type:DNS Host (A)
i can not access it through either turnmylightson.no-ip.org|24.160.73.173|192.168.1.177
i know the noip works because the other skitch i uploaded worked fine
and i tried to add
byte dns[] = {
192, 168, 1, 1 }; // dns server
and
Ethernet.begin(mac, ip, dns, gateway, subnet);
but i get the error
webserver_home_automation_with_status:35: error: 'byte dns []' redeclared as different kind of symbol
C:\Documents and Settings\Michael\My Documents\Arduino_instalation\arduino-1.0.1\libraries\Ethernet/Dhcp.h:64: error: previous declaration of '<anonymous enum> dns'
as stated before this is the origional one i had that worked fine
I was not sure if you meant it worked on the localnet or with no-ip. I use my own server code, and it has proven to be reliable. Maybe looking at it will help you. http://playground.arduino.cc/Code/WebServerST
D4 has its own purpose if there is a uSD memory card in the slot. That is the slave select for it. If you never plan on using the uSD slot, you can use D4 for other stuff.
heres what i have so far thats working i still dont know how to log the relay states with out crashing it i remember somewere that serial.write is faster then serial.println so i replaced the client.println with client.wite
/*
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
**relay1 - pin 6 //lights
**relay2 - pin 5 //fan
**relay3 - pin 8 //nc
**relay4 - pin 9 //nc
**IRled - pin 3 //pwm
**IRrec - pin 7
*/
#include <SPI.h>
#include <Ethernet.h>
int Relay1 = 6;
int Relay2 = 5;
int Relay3 = 8;
int Relay4 = 9;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = {
192, 168, 1, 177 }; // ip in lan
byte gateway[] = {
192, 168, 1, 1 }; // internet access via router
byte subnet[] = {
255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
void setup(){//start void setup
pinMode(Relay1, OUTPUT); //pin selected to control relay1
pinMode(Relay2, OUTPUT); //pin selected to control relay2
pinMode(Relay3, OUTPUT); //pin selected to control relay3
pinMode(Relay4, OUTPUT); //pin selected to control relay4
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.println("http://turnmylightson.no-ip.org/ server test 1.0"); // so I can keep track of what is loaded
// Open serial communications and wait for port to open:
Serial.begin(9200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}//end while not serial
}//end void setup
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); //for debuging
}//end readString.length
if (c == '\n') { //if HTTP request has ended
//send html data to client
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.write("<HTML><HEAD>");
client.write("<HEAD>");
client.write("<meta name='apple-mobile-web-app-capable' content='yes' />");
client.write("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
client.write("<link rel='stylesheet' type='text/css' href='http://homeautocss.net84.net/a.css' />");
client.write("<TITLE>Home Automation</TITLE>");
client.write("</HEAD>");
client.write("<BODY>");
client.write("<H1>Welcome To My Home Automation Website</H1>");
client.write("<hr />");
client.write("
");
client.write("<a href=\"/?status=1\"\">Turn On Bed Room Light</a>");
client.write("<a href=\"/?status=0\"\">Turn Off Bed Room Light</a>
");
client.write("
");
client.write("<a href=\"/?status=3\"\">Turn On Bed Room Fan</a>");
client.write("<a href=\"/?status=2\"\">Turn Off Bed Room Fan</a>
");
client.write("
");
client.write("<a href=\"/?status=5\"\">Turn On relay3</a>");
client.write("<a href=\"/?status=4\"\">Turn Off relay3</a>
");
client.write("
");
client.write("<a href=\"/?status=7\"\">Turn On relay4</a>");
client.write("<a href=\"/?status=6\"\">Turn Off relay4</a>
");
client.write("
");
client.write("</BODY>");
("</HTML>");
delay(1);
//stopping client
client.stop();
//control arduino pin
//read for Light
if(readString.indexOf("GET /?status=0")>=0){
digitalWrite(Relay1, LOW);
Serial.println("Light is off");
}//end if lightoff
if(readString.indexOf("GET /?status=1")>=0){
digitalWrite(Relay1, HIGH);
Serial.println("Light is on");
}//end if lighton
//read for fan
if(readString.indexOf("GET /?status=2")>=0){
digitalWrite(Relay2, LOW);
Serial.println("Fan is off");
}//end if fanoff
if(readString.indexOf("GET /?status=3")>=0){
digitalWrite(Relay2, HIGH);
Serial.println("Fan is on");
}//end fanon
//read for relay3
if(readString.indexOf("GET /?status=4")>=0){
digitalWrite(Relay3, LOW);
Serial.println("Relay3 is off");
}//end if relay3off
if(readString.indexOf("GET /?status=5")>=0){
digitalWrite(Relay3, HIGH);
Serial.println("Relay3 is on");
}//end relay3on
//read for relay4
if(readString.indexOf("GET /?status=6")>=0){
digitalWrite(Relay4, LOW);
Serial.println("Relay4 is off");
}//end if relay4off
if(readString.indexOf("GET /?status=7")>=0){
digitalWrite(Relay4, HIGH);
Serial.println("Relay4 is on");
}//end relay4on
//clearing string for next read
readString="";
}//end if HTTP request has ended
}// end client.avalible
}//end while client.connected
}//end if client
}//end void loop
That code does not access Relay5 (D10) like the original code you posted, so it should work ok.
You are not using the uSD card now, but you will be. I highly recommend avoiding D4 until you are ready to use the uSD. But you can't use D10 now. It is already used. It should be manipulated by the ethernet library low level read and write functions after the setup() function.
i think my arduino is just dying its been giveing me so much trouble
the serial data is sometimes glitched alot and now i receave no serial data at all that might be why the code works one minute then stops the next
How about posting all of your code (can't make much out of the various parts). How are you powering the relays (if powered directly from the arduino they may be causing the board to reset)? Below is very simple server code you can try and check if pin 5 goes hi/low from the web page using a multimeter.
//zoomkat 4-1-12
//simple button GET for servo and pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html, or use ' instead of "
//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>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString;
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
myservo.write(90); //set initial servo position if desired
myservo.attach(7); //the pin for the servo control
//enable serial data print
Serial.begin(9600);
Serial.println("server servo/pin 5 test 1.0"); // 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);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
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>Zoomkat's simple Arduino button</H1>");
client.println("<a href=\"/?on\">ON</a>");
client.println("<a href=\"/?off\">OFF</a>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf("on") >0)//checks for on
{
myservo.write(40);
digitalWrite(5, HIGH); // set pin 5 high
Serial.println("Led On");
}
if(readString.indexOf("off") >0)//checks for off
{
myservo.write(140);
digitalWrite(5, LOW); // set pin 5 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}