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
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!!