enc28j60 WampServer--> 408 Request Timeout

Hi all,

After many hours of reserching on PHP and MySQL I think I have half of the proyect done, but I believe that my arduino code is missing something. I am using an enc28j60 module and UIPEthernet lib, like most of the examples on the internet I want to save my temperature and humudity on the DB.

The LAN is built up with a router (IP 192.168.0.1), a workstation (IP 192.168.0.102), an enc28j60-(IP 192.168.0.103), and a computer_1 (IP 192.168.0.104), by now, if I type "192.168.0.102/habitacion.php?t=25&h=51" on the computer_1 google chrome URL, it works fine (the data is saved into the DB), it seems like the PHP file and MySQL tables are working and the devices of the LAN can access to localhost and MySQL as well.

The arduino code that I used is a modification from example TcpClient on UIPEthernet lib, dont take too seriously since there is no code about temperature and humedity, I didnt consider that cause I thought that there was an error writting the char string to be sent, mixing chars with integers.

#include <UIPEthernet.h>

EthernetClient client;
signed long next;

void setup() {

Serial.begin(9600);

uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
Ethernet.begin(mac);

Serial.print("localIP: ");
Serial.println(Ethernet.localIP());
Serial.print("subnetMask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("gatewayIP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("dnsServerIP: ");
Serial.println(Ethernet.dnsServerIP());

next = 0;
}

void loop() {

if (((signed long)(millis() - next)) > 0)
{
next = millis() + 5000;
Serial.println("Client connect");

if (client.connect(IPAddress(192,168,0,102),80))
{
Serial.println("Client connected");
client.println("GET /192.168.0.102/habitacion.php?t=25&h=65 HTTP/1.1");
while(client.available()==0)
{
if (next - millis() < 0)
goto close;
}
int size;
while((size = client.available()) > 0)
{
uint8_t* msg = (uint8_t*)malloc(size);
size = client.read(msg,size);
Serial.write(msg,size);
free(msg);
}
close:
//disconnect client
Serial.println("Client disconnect");
client.stop();
}
else
Serial.println("Client connect failed");
}
}


and this is what I get from serial monitor:

localIP: 192.168.0.103
subnetMask: 255.255.255.0
gatewayIP: 192.168.0.1
dnsServerIP: 192.168.0.1
Client connect
Client connected
HTTP/1.1 408 Request Timeout
Date: Mon, 17 Nov 2014 15:22:35 GMT
Server: Apache/2.4.9 (Win64) PHP/5.5.12
Content-Length: 305
Connection: close
Content-Type: text/html; charset=iso-8859-1

**408 Request Timeout** **** **

Request Timeout

** **

Server timeout waiting for the HTTP request from the client.

**
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80 Client disconnect

I think thats it, hope someone can give me a hand on this since I am out of ideas on how to keep on going, I will really appreciate it!!

I don't know the UIPEthernet library, but with the default Arduino Ethernet library I connect to a string.
Ethernet.connect ("192.168.0.102", 80);
But since your client is connected, I think that is okay.
Your 'GET' should have a few lines, followed by an empty line.
And your 'GET' should only have the filename, not the IP address, not the server name.
So it is "GET /habi.... and so on
And also a "Hostname: ", and a "Connection: close" for HTTP 1.1.
And an empty line: client.println();

After that you can check for client.available().
Google for how to use the GET.

I'm not sure if your client.available() with the timeout is working.

thanks for your answer Peter! you took me to the right place, its kicking now! I found a code with the same ideas you told me, I just cange the line it was wrong to this code:


client.print( "GET /habitacion.php?");
client.print("t=");
client.print( "2" );
client.print("&&"); //There is no mistake! there is 2 of &, some texts say just one &
client.print("h=");
client.print( "3" );
client.println( " HTTP/1.1");
client.print( "Host: " );
client.println(server);
client.println( "Connection: close" );
client.println();
client.println();
client.stop();


in case you or someone who need the MsQL configuracion just msg!! thanks Peter!!

Nice 8)
After "Connection: close" you do twice a println(). I think one is enough for a 'GET'.

I deleted 1 line of those client.println() and stops saving data :o I also tried later on to use only one & between variables and it also works fine, even if I try with 3 "&" :astonished:

Bambo_Klaat:
I deleted 1 line of those client.println() and stops saving data :o I also tried later on to use only one & between variables and it also works fine, even if I try with 3 "&" :astonished:

you can show you code pls