How do I communicate with a sensor via an Arduino's RX/TX ports?
You don't mention the sensor brand or a datasheet so this will be a very general answer to the problem.

Firstly, how you have the sensor connected now should just spool info into the Serial monitor of the Arduino IDE without any code on the Arduino.

What are the data speed and the exact way the Serial comes out from the sensor?

If you want to interpret the data as it is coming through you should use Software Serial as you can't relay info to the PC with an Arduino's RX TX lines connected to something else.

What you can do is below(Untested):



#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySer(3, 4); //RX TX

//these are char areay because its from Serial
char accel[3] = {'0'};
uint8_t place = 0;

// array to print in sync with the accelerometer values array
const char* SerialText[3] = {
   "\nX Axis: ",
   "\nY Axis: ",
   "\nZ Axis: ",
};


char inData = '0';
char separator = ','; // separator you described



void setup(){
//set to the normal baud, mines for the example
     Serial.begin(9600); 

     mySer.begin(9600);

}//~ end setup

void loop(){

    if(mySer.available()){

     inData = mySer.read(); // get the value at the instance of the serial data being there

        if(inData != separator){
          accel[place] = inData;
          Serial.print(SerialText[place]); // print the current values identifier
          Serial.print(accel[place]); // print value
          place++; // increment for the next time
     }
   }

if(place &gt;= 3) place = 0;
}//~ end loop


The above gives this output at the moment, with an input of $CSACC,-0156.4,-0226.3,+0981.2*49

X Axis: $
Y Axis: C
Z Axis: S
X Axis: A
Y Axis: C
Z Axis: C
X Axis:  
Y Axis: -
Z Axis:  
X Axis: 0
Y Axis: 1
Z Axis: 5
X Axis: 6
Y Axis: .
Z Axis: 4
X Axis:  
Y Axis: -
Z Axis:  
X Axis: 0
Y Axis: 2
Z Axis: 2
X Axis: 6
Y Axis: .
Z Axis: 3
X Axis: +
Y Axis: 0
Z Axis: 9
X Axis: 8
Y Axis: 1
Z Axis: .
X Axis: 2
Y Axis: *
Z Axis: 4
X Axis: 9
Y Axis:  
Z Axis: 
X Axis: 


The code doesn't filter this the way it should but is a stepping stone. I will update it to do it properly when I have a chance.