Serial Data between Arduino standalone & Nanode

I have built a energy monitor to monitor power usage/generation, and have since built a Nanode board, and want to connect the two boards together via the Tx/Rx serial pins, to upload the data to Pachube.
So far, both boards work great independently, with the Nanode using random data, but need to get the 2 connected.
The data will consist of 4 different readings, and is presently serial printed (to screen) like;
kw, 3.293
kwt, 13.28
v, 248
h, 2.323
but can be changed to any other format to suit.
This data will be sent every 4 seconds, and needs to totalled/averaged before being uploaded by the Nanode to Pachube every 30 seconds.

I have seen a post below http://arduino.cc/forum/index.php/topic,69734.0.html which seems quite complex, is there an easier way to do this, and I don't need 2 way communication?

and have since built a Nanode board

What is a Nanode board?

and want to connect the two boards together via the Tx/Rx serial pins

I wouldn't use the RX/TX pins on the Arduino. If you do, you won't be able to debug the Arduino side. Use any two other digital pins and NewSoftSerial, instead.

Don't forget that you need to connect the grounds.

Sending data is simple. Use Serial.print() (or nssInstance.print()).
Receiving data is simple. Use Serial.available() and Serial.read().

before being uploaded by the Nanode to Pachube every 30 seconds.

How is the Nanode talking to the Pachube server?

PaulS:

and have since built a Nanode board

What is a Nanode board?

and want to connect the two boards together via the Tx/Rx serial pins

I wouldn't use the RX/TX pins on the Arduino. If you do, you won't be able to debug the Arduino side. Use any two other digital pins and NewSoftSerial, instead.

Don't forget that you need to connect the grounds.

Sending data is simple. Use Serial.print() (or nssInstance.print()).
Receiving data is simple. Use Serial.available() and Serial.read().

before being uploaded by the Nanode to Pachube every 30 seconds.

How is the Nanode talking to the Pachube server?

  1. See http://nanode.eu/, they are brilliant!
  2. OK
  3. Hmm, not so sure how the data would be managed at the receiving end, as I would need attach each of the values to a different variable. So for example the kw figures would need to be identified separately to the kwt, v & h data.
  1. Hmm, not so sure how the data would be managed at the receiving end, as I would need attach each of the values to a different variable. So for example the kw figures would need to be identified separately to the kwt, v & h data.

If you are sending data like:
kw, 3.293
kwt, 13.28
v, 248
h, 2.323
then which value goes with which variable is pretty obvious. You need to collect all the serial data for each packet into an array, and then parse that array, and convert the number parts to values.

Of course, the first part is to determine exactly what constitutes a packet.

If you were to send, instead:
<kw, 3.293>
<kwt, 13.28>
<v, 248>
<h, 2.323>
then the start and end of a packet is pretty easy to detect.

Once you have a packet in the array, parsing is easy. The strtok() function does that. You'd get two tokens ("kw" and "3.293" for instance). The first token tells you where to store the value, and the second token needs to be converted to a number. The atoi() and atof() functions look useful for that.

This code has been suggested, which would fulfil my needs (if it worked!). However it doesn't compile and reports that quite a number of terms 'have not been declared in this scope'. I am still finding my feet with programming, but does that mean that I need to look at the errors and add the declarations one by one after deciding it's respective data type?
Example; dataReady, nextChar, arg2_String, etc

 /* Functions */
 
 // Gets the serial command from the serial port, decodes it and performs action

// Decodes a serial input string in the form  a255,65535,65535,65535,65535 CR
// So an alpha command a (arg0), followed by up to 5 numerical arguments (arg1 to arg5)
// If any of the arguments are missing they will default to zero
// so b1  =  b,1,0,0,0,0 and b,1 = b,1,0,0,0,0
// Always produces 6 comma separated terms, of which the first is alpha 
// (or punctuation character except comma)

// a = command 
// 255 = 8-bit sub address
// , is delimiter
// 65535 is integer arg1
// , is delimiter
// 65535 is integer arg2
// , is delimiter
// 65535 is integer arg3
// , is delimiter
// 65535 is integer arg4
// , is delimiter
// 65535 is integer arg5
/*********************************************************************************************/
 

/*************************************************************************************************/
int serialReader(){ 
  
  initStrings();                          // Clear the string buffers before we start
  dataReady = 0;                           // Clear the serial flag
  
  if  (Serial.available() > 0) {          // if there are bytes waiting on the serial port
    inByte = Serial.read();               // read a byte
    delay(10);                            // *** added to make it work ***

    if (inByte == 13){                    //  follow the false code until you get a CR - this packs inString with the complete string
      dataReady = true;
      
// Work your way through inString and parse out the various comma separated fields  
// Put them into six seperate strings arg0_String to arg5_String so that they can be ennumerated or acted upon

       k =  0;                    //reset the string pointer
       q = 0 ;
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg2_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
     if (nextChar == 44 || nextChar == 13 ) {          // if it's a comma (ASCII 44) then bail out
      
       
       break;
       
      }
        
      arg0_String[k] = nextChar;    // start packing the arg0_String
      
      k++;                             // increment the pointer to arg1_String
        
      }

      // Now we process the arg1_String  checking whether we are b1 or b,1 format
      
      k =  0;                    //reset the string pointer
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg2_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
     if (nextChar == 44 || nextChar == 13 ) {          // if it's a comma (ASCII 44) then bail out
      
       
       break;
       
      }
        
      arg1_String[k] = nextChar;    // start packing the arg1_String
      
      k++;                             // increment the pointer to arg2_String
      
     
        
      }
      
      
      // Now we process the arg2_String in the same way

      k =  0;                    //reset the string pointer
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg2_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
     if (nextChar == 44 || nextChar == 13 ) {          // if it's a comma (ASCII 44) then bail out
      
       
       break;
       
      }
        
      arg2_String[k] = nextChar;    // start packing the arg1_String
      
      k++;                             // increment the pointer to arg2_String
      
     
        
      }
      
      // Now we process the arg3_String in the same way
      
      k =  0;                    //reset the string pointer
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg3_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
      if (nextChar == 44 || nextChar == 13 ) {          // if it's a comma (ASCII 44) then bail out
      
       break;
       
      }
        
      arg3_String[k] = nextChar;    // start packing the arg1_String
      
      k++;                             // increment the pointer to arg3_String
    
      }
      
      // Now we process the arg4_String in the same way

      k =  0;                    //reset the string pointer
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg4_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
      if (nextChar == 44 ) {         // if it's a comma (ASCII 44) then bail out
      
       break;
       
      }
        
      arg4_String[k] = nextChar;    // start packing the arg1_String
      
      k++;                             // increment the pointer to arg4_String
     
      }
      
      
      // Now we process the arg5_String in the same way

      k =  0;                    //reset the string pointer
       
      for (int p = q+1; p <34; p++) {   // Now start at the location after the 2nd comma and strip out the arg5_String
      
      nextChar = inString[p];         // get the next Char
      
      q++;
      
     if (nextChar == 44 || nextChar == 13 ) {          // if it's a comma (ASCII 44) then bail out
    
       break;
       
      }
        
      arg5_String[k] = nextChar;    // start packing the arg1_String
      
      k++;                             // increment the pointer to arg5_String
        
      }
      
     
       
       arg0 = atoi(arg0_String);          // get enumerated arg0
       arg1 = atoi(arg1_String);          // get enumerated arg1
       arg2 = atoi(arg2_String);          // get enumerated arg2
       arg3 = atoi(arg3_String);          // get enumerated arg3
       arg4 = atoi(arg4_String);          // get enumerated arg4
       arg5 = atoi(arg5_String);          // get enumerated arg5
      arg6++;                            // increment the message number
  
       
   // Print out the ennumerated arguments noting that arg0 is a character   
      
      sprintf( statusstr, "%u,%u,%u,%u,%u,%u,%u", arg0,  arg1,  arg2, arg3,  arg4 ,  arg5, arg6 );
      Serial.println(statusstr);   // print out the string for debug purposes
      
 //     clear the inStrings
 
      for (int j = 0; j < 34; j++) {        // clear the inString for next time
     inString[j] = 0;
      }
 
      
      i = 0;
      
      return incoming;
    }
    else dataReady = false;      // No CR seen yet so put digits into array
//    Serial.print(inByte); 


    inString[i] = inByte;
    
    i++;
  
  }


}

// Initialise the strings to zero 

 int initStrings()  {

      for (int j = 0; j < 4; j++) {        // clear the arg0_String
      arg0_String[j] = 0;
      }
      
      for (int j = 0; j < 6; j++) {        // clear the arg1_String
      arg1_String[j] = 0;
      }
      
      for (int j = 0; j < 6; j++) {        // clear the arg2_String
      arg2_String[j] = 0;
      }
      
       for (int j = 0; j < 6; j++) {        // clear the arg1_String
      arg3_String[j] = 0;
      }
      
      for (int j = 0; j < 6; j++) {        // clear the arg2_String
      arg4_String[j] = 0;
      }
      
      for (int j = 0; j < 6; j++) {        // clear the arg2_String
      arg5_String[j] = 0;
      }
      
    }

but does that mean that I need to look at the errors and add the declarations one by one after deciding it's respective data type?

Yes, it does.