Go Down

Topic: Arduino web server ideas. (Read 798 times) previous topic - next topic


I'm actually doing a project for high school, it is a weather station, i need to get the sensors data, and be able to check it on a web page, so I made a quick program wich hosts a webpage, but the HTML is integrated into the C code which is not really clean, so I read about something to call a webpage hosted on the SD card. But doing that I don't know how to transfer the data from the C code to the HTML. I was thinking of ad txt file which would be edited by the C and got back by the HTML to display it on the webpage. Any ideas ?
Thanks by advance for your responses.
Hope my english is comprehensible because it is not my native language.


Normally, I would recommend my code in the playground, but zoomkat is the guy with the SD interface examples working. You might want to look at the code in this link:


Thanks a lot i'll read this.


I think you could use the Arduino IDE language println(); function and just put the readings and HTML code inside it.

For example: to display a text you could do the following:

Code: [Select]

print("<h3> Reading from termometer is: " );

print("<h3> Humidity is: " );


Better still would be to use the "F()" macro with your prints, so you don't clog up RAM with constant strings
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


@mixania : it will become so crappy, and I can't include CSS


Besides, there are some files too big to fit into program memory. Here is zoomkat testing a 253k file download speed.


i need to get the sensors data, and be able to check it on a web page

If you are interested in monitoring data input, the below may be one method. The below code provides a web page that will display the current analog pin values (with nothing connected to the pins, the pins have random floating values).

Code: [Select]

// zoomkat's meta refresh data iframe test page 12/24/12
// use in your brouser for main page
// static data page
// meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
unsigned long int x=0; //set refresh counter to 0
String readString;


void setup(){
    // disable SD SPI if memory card in the uSD slot

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  Serial.println("meta refresh data frame test"); // so I can keep track of what is loaded

void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readString.length() < 100) {
          readString += c;
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received

          //output HTML data header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");

          //generate data page
          if(readString.indexOf("data") >0) {  //checks for "data" page
            x=x+1; //page upload counter
            //meta-refresh page every 1 seconds if "datastart" page
            if(readString.indexOf("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>");
            if(readString.indexOf("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>");
            client.print("<title>Zoomkat's meta-refresh test</title></head><BODY><br>");
            client.print("page refresh number ");
            client.print(x); //current refresh count
              //output the value of each analog input pin
             for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
             client.print("analog input ");
             client.print(" is ");
          //generate main page with iframe
            client.print("<HTML><HEAD><TITLE>Zoomkat's frame refresh test</TITLE></HEAD>");
            client.print("Zoomkat's Arduino frame meta refresh test 2/20/13");
            client.print("<BR><BR>Arduino analog input data frame:<BR>");
            client.print("&nbsp;&nbsp;<a href='' target='DataBox' title=''yy''>META-REFRESH</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='' target='DataBox' title=''xx''>SINGLE-STOP</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='' target='DataBox' title=''zz''>FAST-DATA</a><BR>");
            client.print("<iframe src='' width='350' height='250' name='DataBox'>");
          //stopping client
          //clearing string for next read

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up