No No ...
I have seemingly expressed me wrong, I'm sorry ...
what I'm trying to say is ..
I have access to a server where I can send data to.
I have used in different situations where I have used the browser as I mention.
after I have on the server been able to use the data in a SQL data base.
So now I would do it a little more automatic.
I wanted to do a few experiments with some temperature sensing.
what I know is that I can use: "xxxxxx.yyyyyyy.dk: 8000/invput? id = kim & data = 1,2,3,4,5" in an http browser, but how do I get it to work on a arduino.
I have tried to do something in this style:
/*
Web client sketch for IDE v1.0.1 and w5100/w5200
Uses POST method.
Posted November 2012 by SurferTim
*/
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//Change to your server domain
char serverName[] = "xxxx.yyyyyyyy.dk";
// change to the page on that server
char pageName[] = "/invput";
EthernetClient client;
int totalCount = 0;
int loopCount = 0;
// insure params is big enough to hold your variables
char params[32];
void setup() {
Serial.begin(9600);
// disable SD SPI
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
Serial.print("Starting ethernet...");
if(!Ethernet.begin(mac)) Serial.println("failed");
else Serial.println(Ethernet.localIP());
delay(2000);
Serial.println("Ready");
}
void loop()
{
if(loopCount < 30)
{
delay(1000);
}
else
{
loopCount = 0;
// params must be url encoded.
sprintf(params,"id=kim&data=1,2,3,4,5,6,7,8,9",totalCount);//"id=kim&data=1,2,3,4,5,6,7,8,9"-> This I change to a variable when things run.
if(!postPage(serverName,pageName,params)) Serial.print("Fail ");
else Serial.print("Pass ");
totalCount++;
Serial.println(totalCount,DEC);
}
loopCount++;
}
byte postPage(char* domainBuffer,char* page,char* thisData)
{
int inChar;
char outBuf[64];
Serial.print("connecting...");
if(client.connect(domainBuffer,8000))
{
Serial.println("connected");
// send the header
sprintf(outBuf,"POST %s HTTP/1.1",page);
client.println(outBuf);
sprintf(outBuf,"Host: %s",domainBuffer);
client.println(outBuf);
client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded");
sprintf(outBuf,"Content-Length: %u\r\n",strlen(thisData));
client.println(outBuf);
// send the body (variables)
client.print(thisData);
}
else
{
Serial.println("failed");
return 0;
}
int connectLoop = 0;
while(client.connected())
{
while(client.available())
{
inChar = client.read();
Serial.write(inChar);
connectLoop = 0;
}
delay(1);
connectLoop++;
if(connectLoop > 10000)
{
Serial.println();
Serial.println("Timeout");
client.stop();
}
}
Serial.println();
Serial.println("disconnecting.");
client.stop();
return 1;
}
but it does not work. I get a 405 error see below:
Starting ethernet...192.168.10.150
Ready
connecting...connected
HTTP/1.1 405 Method Not Allowed
Date: Mon, 18 Feb 2013 13:24:36 GMT
Server: Apache/2.2.22 (Ubuntu)
Allow: GET,HEAD
Content-Length: 742
Vary: Accept-Encoding
Connection: close
Content-Type: text/html; charset=UTF-8
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>Error: 405 Method Not Allowed</title>
<style type="text/css">
html {background-color: #eee; font-family: sans;}
body {background-color: #fff; border: 1px solid #ddd;
padding: 15px; margin: 15px;}
pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
</style>
</head>
<body>
<h1>Error: 405 Method Not Allowed</h1>
<p>Sorry, the requested URL <tt>'http://xxxx.yyyyyyy.dk/invput'</tt>
caused an error:</p>
<pre>Method not allowed.</pre>
</body>
</html>
disconnecting.
Pass 1
I hope that you now understand my problem.