send data to a website using arduino uno.

I am trying to send data (letters, symbols and numbers) to a website I created (theonymfiloizouapp.tk using Arduino uno and ethernet. However the data I am trying to send appear on the serial monitor and not on the website. How can I make it work? I have read of using a string for that but Id appreciate any suggestions on how I can alter my code.

#include <SPI.h>
#include <Ethernet.h>

byte mac = { 0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xEF};
IPAddress ip(192, 168, 0, 6);
EthernetServer server(80);

void setup()
{

Serial.begin(9600);
Ethernet.begin( mac,ip); //or mac,ip
delay(1000);
Serial.println(“connecting…”);

}

void loop(){
EthernetClient client = server.available();
String data;
data+="";
data+=“data=send that”; // Use HTML encoding for comma’s
data+=“on the website”; // Submitting data

if (client.connect(“www.theonymfiloizouapp.tk”,80)) {
Serial.println(“connected”);
client.println(“POST /pageThatTakesPostData.php HTTP/1.1”);
client.println(“Host: www.theonymfiloizouapp.tk”);
client.println(“Content-Type: application/x-www-form-urlencoded”);
client.println(“Connection: close”);
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println();

Capture.JPG

String data;
data+="";

Start with an instance that is not initialized. Add nothing to it. Why?

if (client.connect("www.theonymfiloizouapp.tk",80)) {

Are you trying to be a client (as this suggests) or a server, as getting a client from the server suggests?

client.println("POST /pageThatTakesPostData.<span class=");

The doesn’t even look remotely correct.

Posting a picture of text just wastes bandwidth AND everyone’s time. Do NOT do that again.

Im sorry, I just wanted to show you what the serial monitor prints. I am trying to be a server that posts data to the website. From there clients accessing the website can access the data.

PaulS: Posting a picture of text just wastes bandwidth AND everyone's time. Do NOT do that again.

It's not just a picture of text.

Hopefully someone who knows what he is trying to do can assist by using that JPG as a debugging tool.

http://www.tweaking4all.com/hardware/arduino/arduino-ethernet-data-push/

Perhaps you have issues on your server. How have you tested the server to verify it is functioning as expected?

The only way i have tested it its by using the ethernet examples available on the arduino webpage (webserver and webclient) and altered the code to the point where it can access my webpage if i remember correctly. Lately I have been trying to send a series of data to that website but nothing really works.

My main aim is to basically create a server-client communication. Hence send the data to the webpage using arduino , and the client will then be able to access those data published and use them.

ieee488: It's not just a picture of text.

Hopefully someone who knows what he is trying to do can assist by using that JPG as a debugging tool.

http://www.tweaking4all.com/hardware/arduino/arduino-ethernet-data-push/

It was a screen shot of the Serial Monitor window. Aside from the information displayed on the title bar, which the OP should have told us, there is NOTHING but the text from the output pane shown. That TEXT should have been copied and pasted here.

theonimfi95: Im sorry, I just wanted to show you what the serial monitor prints. I am trying to be a server that posts data to the website. From there clients accessing the website can access the data.

You need to understand client/server roles and communication processes.

A server responds to GET and POST requests, made by a client, in some way. It does not make GET or POST requests. The server response is typically html, xml, or json data. In some cases, the response is plain text.

A client makes GET or POST requests, and, typically, responds to the data that the server provides.

A "website" is a browser's (a client) rendering of the server response into visual form.

The statement that you want to "be a server that posts data to the website" simply means that you don't understand what clients do, what servers do, or what a "website" is.

PaulS: It was a screen shot of the Serial Monitor window. Aside from the information displayed on the title bar, which the OP should have told us, there is NOTHING but the text from the output pane shown. That TEXT should have been copied and pasted here.

I prefer to see what is actually there, than have him tell me.

Ok, I am very confused about you attempting to use an HTTP POST request to “send data to a web page”.

An HTTP request (GET, POST, DELETE, OPTIONS, HEAD, etc etc etc) talks to a web server. The server then replies with a response message. (eg: “HTTP/1.1 200 OK”, or “HTTP/1.1 404 NOT FOUND”)

You can do two different things to get data off your arduino via HTTP.

The arduino can push data up to a web server by opening a connection to a web server and making a POST request. That web server will then stuff the data in a database and serve up web pages containing the data that it has recieved.

or:

The arduino can reply to HTTP requests with an HTTP response. The content of that response can be HTML, if you want.

You probably want the second thing. You open a web browser and navigate tou your arduino’s IP address. That is, the web browser sends a GET request.

GET / HTTP/1.1

The arduino replies

HTTP/1.1 200 OK
Content-Type: text/plain

Here is some plain text! Yay!

or

HTTP/1.1 200 OK
Content-Type: text/html

<HTML><BODY>Here is some <i>formatted</i> text.</BODY></HTML>

and that message appears on your browser.

If you want something more complex and dynamic, I have put an example in the playground.

A server responds to GET and POST requests, made by a client, in some way. It does not make GET or POST requests. The server response is typically html, xml, or json data. In some cases, the response is plain text.

A client makes GET or POST requests, and, typically, responds to the data that the server provides

Since what I am trying to do is a communication link, I want the client to make get and post requests to which the server will respond.

What i want to do initially, is the client asking data from the server (GET) . However my thought around it was that i need to post those data somewehere (website). And what i need to figure is how to post data, and how the client can GET them.

The codes and resources around it are complicated and not straight to the point. Thus i need to find a code or try understand what to include in the code so that i will get the job done. Any information or code I can test would be helpful.

http://www.tweaking4all.com/hardware/arduino/arduino-ethernet-data-push/

I have come accross this link many times. Even though I have ordered the components and I will try figure it out this code , it posts sensor data like any other website i have found. I just want to post data i will input in the code.

client.println("POST /pageThatTakesPostData.<span class=");

//client.println(hiddenSpellError">php HTTP/1.1");
client.println(“Host: www.theonymfiloizouapp.tk”);
client.println(“Content-Type: application/x-www-form-urlencoded”);
client.println(“Connection: close”);
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println();





> I don't get that first line - the POST request. It should read
> 
> POST http://some-url HTTP/1.1
> 
> that "<span class=" is not valid.

Below is basic client code that makes a GET request from somebody’s web server out there somewhere per a recent client code question. Try it unmodified and see if the server answers.

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString 

#include <SPI.h>
#include <Ethernet.h>
String readString;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "www.assatena.it"; // myIP server test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  Serial.println();
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /Atena/arduTrial.php HTTP/1.1"); //download text
    client.println("Host: www.assatena.it");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor 
  Serial.println();  
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}