Sending data through Ethernet?

Ive got a program written to determine the RMS value of 2 signals at a set rate (as seen below) and im looking for a simple way to send this data to a computer via Ethernet. I only need to achieve an asynchronous data stream, and as long as all data is received on the PC end then im happy (probably will receive it with visual basic, but might just view the data stream first using processing/a web prowser).

Im also new to using the Ethernet shield/Ethernet library, and the examples the arduino program seemed to do a bit more then i really needed.

RMS Code:

//Define the number of voltage/current readings per read burst
const int numReadings = 375;

//Variable to increment voltage/curent variable
int inputReading [numReadings];
int inputReading2 [numReadings];

//Count for data transmission
int count;

//Variables used for calculations
float Vsum;
float Isum;
float Vrms;
float Irms;
float VrmsT;
float IrmsT;
float MeanSumV;
float MeanSumI;

//Default DC offset variables
float Vmean = 1.50;
float Imean = 1.56;

//Sets up th program/its data rate
void setup() 
{
  Serial.begin(115200);
}

//Loop
void loop()
{
  //Voltage/current reading loop 
  for (int i = 0; i < numReadings; i++) {
    inputReading [i]= analogRead(0);
    inputReading2 [i]= analogRead(5);
  }
  
  //Voltage/current calculation loop
  for (int i = 0; i < numReadings; i++) {    
    
    //Stores and converts each sample, one at a time
    float voltage = ((inputReading[i]/1023.0)*4.945);
    float current = ((inputReading2[i]/1023.0)*4.945);   
    
    //Calculates a DC offset over time
    MeanSumV = MeanSumV + voltage;
    MeanSumI = MeanSumI + current;
    
    //Increments transmission count
    count = count + 1;
    
    //Removes DC offset
    voltage = voltage - Vmean;
    current = current - Imean;  
    
    //Sums the squares of the samples
    Vsum = pow(voltage,2) + Vsum;
    Isum = pow(current,2) + Isum;
    
    //Prints RMS values when terminal count is reached
    if (count >= 375){

    //Squareroots the values for a final signal, RMS value
    Vrms = sqrt(Vsum/375);
    Irms = sqrt(Isum/375);
  
     //New scaling and offset equations,
    //converting signal values, to true RMS values 
    VrmsT = ((-20.861*(Vrms)) + 134.37);
    IrmsT = ((11.242*(Irms)) - 0.709);
    
    //Old scaling and offset equations,
    //converting signal values, to true RMS values 
    //VrmsT = ((-27.952*(Vrms)) + 138.33);
    //IrmsT = ((11.39*(Irms)) - 0.7202);
    
    //Prints voltage and current
    Serial.print(VrmsT);
    Serial.print(", ");
    Serial.println(IrmsT);
    
    //Calculates new DC offsets
    Vmean = (MeanSumV/375);
    Imean = (MeanSumI/375);
    
    //Resets values
    count = 0;
    Vsum=0;
    Isum=0;
    MeanSumV = 0;
    MeanSumI = 0;
    }
  }
}

Maybe there is an advantage over USB with longer cables but, other than that, I really can't see the point of doing that.

Nonetheless, before I concluded it was pointless, I used this!

You cant see the the point of doing what? Im trying to send data via ethernet, how is that pointless?....

Well, you have already said

NickPatey:
the examples the arduino program seemed to do a bit more then i really needed.

but maybe you are doing it for the intellectual exercise, in which case it is not pointless. There are simpler and cheaper ways to achieve the same ends, ones that do not do a bit more than you really need, and are probably more versatile as well. Other than the intellectual exercise, the first things to ask are - how long is the cable, and will it be used to power the Arduino? If the answers are - not very, and no, there are simpler choices and your Ethernet shield is better employed elsewhere.

The reason why I took the path in the link I sent was because I misunderstood the destination.

Nick_Pyner:
Well, you have already said

NickPatey:
the examples the arduino program seemed to do a bit more then i really needed.

but maybe you are doing it for the intellectual exercise, in which case it is not pointless. There are simpler and cheaper ways to achieve the same ends, ones that do not do a bit more than you really need, and are probably more versatile as well. Other than the intellectual exercise, the first things to ask are - how long is the cable, and will it be used to power the Arduino? If the answers are - not very, and no, there are simpler choices and your Ethernet shield is better employed elsewhere.

The reason why I took the path in the link I sent was because I misunderstood the destination.

The tutorial actually was a lot simpler then i thought, and have it up and running.

Anyway my cable is ~5-10ft to the switch, and no i do not power the arduino via ethernet.

What do you mean by "simpler choices and your Ethernet shield is better employed elsewhere", are you saying i should use another program, or not bother using the shield this way at all? My project is centered around Ethernet so i HAVE to use the shield in this application.

Ive achieved basic ethernet printing using:

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

byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0D, 0xA3, 0x12 };
IPAddress ip(10,200,158,31);

byte gateway[] = { 10, 200, 159, 254 };
byte subnet[] = { 255, 255, 252, 0 };

EthernetServer server(80);

void setup() {
  Serial.begin(9600);
  
  // start the Ethernet connection and the server: 
  Ethernet.begin(mac, ip, gateway, subnet);   
  
  server.begin();
}


void loop() {
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      
          client.print(analogRead(0));
          client.print(", ");
          client.println(analogRead(5));      
          
     
    }
    client.stop();
  }
}

Now i just have to figure out how to get visual basic to take this data in.

Server test code foe getting the analog pin input from an arduino using an Ethernet card.

// zoomkat's meta refresh data iframe test page 12/24/12
// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart 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(){
  Serial.begin(9600);
    // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  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
          Serial.println(readString);

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

          //generate data page
          if(readString.indexOf("data") >0) {  //checks for "data" page
            x=x+1; //page upload counter
            client.print("<HTML><HEAD>");
            //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>
");
            client.print("page refresh number ");
            client.print(x); //current refresh count
            client.print("

");
              //output the value of each analog input pin
             for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
             client.print("analog input ");
             client.print(analogChannel);
             client.print(" is ");
             client.print(analogRead(analogChannel));
             client.print("
");
             }
            client.print("</BODY></HTML>");
           }
          //generate main page with iframe
          else
          {
            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("

Arduino analog input data frame:
");
            client.print("&nbsp;&nbsp;<a href='http://192.168.1.102:84/datastart' target='DataBox' title=''yy''>META-REFRESH</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/data' target='DataBox' title=''xx''>SINGLE-STOP</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/datafast' target='DataBox' title=''zz''>FAST-DATA</a>
");
            client.print("<iframe src='http://192.168.1.102:84/data' width='350' height='250' name='DataBox'>");
            client.print("</iframe>
</HTML>");
          }
          delay(1);
          //stopping client
          client.stop();
          //clearing string for next read
          readString="";
        }
      }
    }
  }
}

NickPatey:
What do you mean by "simpler choices and your Ethernet shield is better employed elsewhere", are you saying i should use another program, or not bother using the shield this way at all? My project is centered around Ethernet so i HAVE to use the shield in this application.

and previously

as long as all data is received on the PC end then im happy).

I have no idea why your project is centred around the ethernet or why you have to use the shield. It sounds like a simple exercise in sending data to the PC and then processing it there. You can do this with a 10 ft USB cable. I use a $5 bluetooth over 20 feet. Both are a lot simpler, and the bluetooth is probably cheaper than the cable. If the ethernet is a personal whim, then OK, that's the choice. It seems to me that the real exercise is what you do with the data when it gets to the PC rather than the mode of travel.

I just think an ethernet shield is better employed talking to the world, rather than merely down 10 feet of cable to your PC. The link I sent worked fine first time and should adapt OK to your needs. It just didn't do anything better than what I had already done.