Interfacing website with arduino

I am developing a project which requires me to design a website that can receive values from arduino microcontroller. So far i have been successful in sending data to a my local IP address using ethernet shield. The next step requires me to develop a website,assign it an IP AND THEN receive sensor values from multiple microcontrollers and log them against user accounts in a database.

Please answer the following queries:

1.How to interface arduino with the ethernet shield in such a way that it sends data to an IP address which is outside its network?
2.How to write a script for the website such that it receives data from the controllers?
3.Should i use a dedicated server or utilize web hosting?

Replies from Users with knowledge of embedded & CONTROL systems+ Networking are highly appreciated!

I am developing a project which requires me to design a website that can receive values from arduino microcontroller.

Then you don't understand what you are doing. A web site is some html code that a server sends and a client renders.

Either the Arduino is serving up the HTML or it is not doing anything.

1.How to interface arduino with the ethernet shield in such a way that it sends data to an IP address which is outside its network?

The Arduino can make GET requests to any server, by IP address. If the server has a script that accepts data, the Arduino can send data to the script.

2.How to write a script for the website such that it receives data from the controllers?

EXACTLY the same way you would if it were just two PCs involved.

3.Should i use a dedicated server or utilize web hosting?

Do you have a choice? A dedicated server is MUCH easier to deal with.

I can't really help with 1. , but I think if you simply change the IP address to point to your webserver then that should work. You will probably want to look at DNS resolving so that you can use your website address "www.mywebsite.com" to get the IP address "1.1.1.1"

  1. Web hosting with scripting and databases (eg PHP and MySQL) is sufficient, but you might want to look at dedicated hosting if you need to do lots of processing (or just need more control generally). As PaulS pointed out, you dont seem too sure of what you're doing, so maybe just stick to webhosting for now as you wont need to do any setting up.

  2. PHP is probably the easiest to get started, the code below will take the data from your arduino, and write it to separate text files based on the ID you have sent (see below for the arduino part, i have used 'mynameis' as an example)

log.php - on your webhosting website

<?php

$id = $_GET['id'];
$data = $_GET['data'];

$fp = fopen("./logs/".$id.".txt", "a"); //open the file logs/mynameis.txt and append to it ('a' mode)
fwrite ($fp, $data.','); // write the data, followed by a comma (this will create a basic csv file)
fclose($fp);//close the file
?>

Reading the data back can be done in php using fread.

arduino code. look at webclient code and replace the connection stuff with

....
    client.println("GET /log.php?id=mynameis&data=12.53 HTTP/1.1"); //id= & data= get fed into your php script
    client.println("Host: www.mywebsite.com");
    client.println("Connection: close");
    client.println();
....

This is only the start - there is a lot more to do (for example not writing to a text file but instead a database), but hopefully this will get you on the right track.