Hello to all.
After making the code for an arduino + enc28j60 + 2 thermistors and web server to work, now i want to send a POST to a server so i can log the informations to a mysql server and then read them from outside the house network.
The link to wich i want to send the POST is http://domain.biz/a/index.php?tur=XX&retur=YY
Can someone help me to include into my existing code the part of code witch will do what i want?
My actual code is:
#include <UIPEthernet.h> // Used for Ethernet
int ThermistorPin = 0;
int ThermistorPin1 = 1;
int Vo;
int Va;
float R1 = 4600;
float R4 = 9900;
float logR2, logR3, R2, R3, T, T1, Tc, Tr;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
// **** ETHERNET SETTING ****
// Ethernet MAC address - must be unique on your network
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
// ethernet interface IP address (unique in your network)
IPAddress ip(192, 168, 0, 200);
// ethernet interface IP port (80 = http)
EthernetServer server(80);
EthernetClient client;
void setup() {
// Open serial communications:
Serial.begin(9600);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.println("CrazyDesign.biz - Temperature Drone - v1.0");
Serial.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
Serial.println();
}
void loop() {
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;
Va = analogRead(ThermistorPin1);
R3 = R4 * (1023.0 / (float)Va - 1.0);
logR3 = log(R3);
T1 = (1.0 / (c1 + c2*logR3 + c3*logR3*logR3*logR3));
Tr = T1 - 273.15;
// listen for incoming clients
client = server.available();
if (client)
{
Serial.println("-> New Connection\n");
Serial.print("Tur: ");
Serial.print(Tc);
Serial.print(" C ");
Serial.print("Retur: ");
Serial.print(Tr);
Serial.println(" C");
delay(1000);
// a http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected())
{
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank)
{
client.print("<font color=blue size=5>");
client.print("Tur: ");
client.println(Tc);
client.println("<p></font><font color=blue size=5>");
client.print("Retur: ");
client.println(Tr);
client.print("</font>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(10);
// close the connection:
client.stop();
Serial.println(" Disconnected\n");
}
}
P.S. i have allready triyed all i could find on internet about this.
Thank you all for your hints or help.