Hi,
I currently have a LAN set up (no internet) through a switch to connect my PC to my arduino with ethernet shield. On my PC I have apache running with a simple php script, and I would like to be able to get data from there on the arduino. My problem is that even though I have everything set up, I can't seem to connect to the PHP script from any computer on the LAN other than the computer running apache.
The IP of the PC is 192.168.0.2, and I have the httpd.conf file set to LISTEN 192.168.0.2:80. The IP of the arduino is 192.168.0.3, and when it is connected I can successfully ping that IP address, but I am unable to connect to the server. I also tried hooking up a laptop to the LAN and was again unsuccessful in connecting to the PHP script, but could ping the IP just fine.
The URL of the script is: 192.168.0.2:80/test2.php
Arduino code is:
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x25, 0xE1 }; // MAC address of ethernet shield
byte ip[] = { 192, 168, 0, 3 };
byte server[] = { 192, 168, 0, 2 };
Client client(server, 80);
void setup(){
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
}
void loop(){
// connect to server
Serial.println("Try to connect to server:");
if (client.connect()){
Serial.println("OK");
} else {
Serial.println("Fail");
}
if (client.connected()){
client.println("GET /test2.php");
char c = client.read();
Serial.print(c);
for(;
;
} else {
Serial.println("Connection problem/discconncted.");
}
client.stop();
Serial.println("Client stopped.");
delay(10000);
}
I'm hoping that someone can suggest something to get this working, and tips would be greatly appreciated.
thanks . . . . .
Tidak ada komentar:
Posting Komentar