So i tried to put the code to void loop, It works partly. It repeats but without PHP request.
This is my source code:
#include <UIPEthernet.h>
#include <SPI.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//byte ip[] = { 10, 0, 0, 177 };
char server[] = { "www.jakubmiga.eu"}; // Google
EthernetClient client;
double fTemp;
double therm = Thermister(analogRead(A0)); // Read sensor
void setup()
{
Serial.begin(9600);
Serial.println("Starting...");
Ethernet.begin(mac);
}
void loop()
{
client.connect(server, 80);
delay(500);
Serial.println("Connecting...");
if (client.connected()) {
Serial.println("Connected");
client.print("GET /add_temp.php?temp=");
client.print(therm);
client.println(" HTTP/1.1");
client.println("Host: www.jakubmiga.eu");
client.println();
} else {
Serial.println("Connect failed");
}
if (client.available()>0) {
char c = client.read();
Serial.print(c);
}
if (0 == (millis()%1000))
Serial.println(millis()); //debug output
if (!client.connected()) { //never true
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
And in Serial Monitor.
Starting...
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
Connecting...
Connected
It's really in loop, but as you can see, it's just connected but it doesn't use PHP request.