Reading from uart ports and restream over ethernet (UDP)

would like to ask you for some suggestions about my project.

I have 5 sensors connected to my Arduino over UART (I'm using some external interface to connect uart over spi to Arduino but let say that I have 5 uarts :slight_smile: )...

(each uart represent different sensor)

uart1 = oxygen sensor
uart2 = temp sensor
uart3 = salinity sensor
uart4 = pressure sensor
uart5 = clorophile sensor

Each of this sensor sends me a Stream in this format:


"," is a delimiter...

My job is to "resend" data over Ethernet (UDP) to a PC... in this way

1.) first I must parse each stream to some kind of array adding a letter before a parsed value for example if I parse temp data the result on udp must be

if i parse salinity data the result od udp mus be


So I'm looking for some suggestion how to parse a stream from serial into some array or buffer and adding a letter (char) before parsed value and how to resend parsed data over ethernet.

(I don't need any checksum control etc..) only to resend parsed data line by line over ethernet.
The Ethernet "interface" is w5100 over SPI...

thank you for any help and info


here is my first example of code to parse data from a string… let say if I have this kind of string


#include <string.h>

const byte numChars = 20;
char receivedChars[numChars];

byte ndx = 0;
boolean isFirst = 0;

void setup() {


void loop() {

  //read from serial port..
  if (Serial.available() > 0) {
    char rc =;

    //if flag is true then begin to parse
    if (isFirst == true)
      //if read char is ',' then send string over ethernet... and erase array..
      if (rc == ',')
        ndx = 0;
        memset(&receivedChars[0], 0, sizeof(receivedChars));
        receivedChars[ndx] = rc;


    //read until frist ',' thern set a flag to isFirst == true;
    if (rc == ',' && isFirst == false)
      isFirst = true;

Please correct me if I’m wrong…

When I begin to read from serial port I first check if I get ‘,’ then isFrist flag is set to true…
In next loop if the flag is set and if char is <> ‘,’ then add a char to buffer…
If I find ‘,’ then I send a buffer over UDP (now I have only serial.println…)…

Is this approach ok? or is there some better option to be used?

thank you