CTI Sensor(Tilt Meter) Data to Serial Connections(2X) on Due

Hello, I’m trying to get data from a CTI Sensor or tilt meter to the Arduino Due from a second serial connection. I’m having problems finding examples or tutorials on how to use serial and serial1 at the same time on the Due. I was trying to get the data into an array to easily call the data. I have added the code I’m working with. This was from an example I found and I tried to modify to no avail. I would like to see data from the sensor show up on the serial monitor from a PC. I’m using the Arduino Editor for the project.

I tried TextFinder and I had problems getting the library into the sketch using Arduino Editor. It looked simple as far as getting the data.

I’ll continue to work on the solution, but it would be awesome if I could get some help with the two serial connection portion. Thank!

/*
Gathering tilt meter data from the tilt sensor to arduino due on serial1.
*/
#include<string.h>

/*String firstStr[8];
float Ax = 0;
float Ay = 0;
float Az = 0;
float aroundY = 0;
float aroundX = 0;
float aroundZ = 0;
float trash = 0;*/

char inData[80];
char tiltData[80];
byte index = 0;

void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
}


void loop()
{
  while(Serial1.available() > 0)
  {
     char aChar = Serial1.read();
     if(aChar == '\n' || index == 20)
     {
        // End of record detected. Time to parse
        
        char *p = inData; //point to *p to the string in inData
           char *str;        //declaring *str
           int counter = 0; //initialise the counter

           while (str = strtok_r(p, ",", &p)) // delimiter is the comma
           {
                 tiltData[counter] = *str; //use the counter as an index to add each value to the array
                 counter++; //increment the counter

              p = NULL;
             
           }
          Serial.print("First: ");
          Serial.println(tiltData[0]);
        

        index = 0;
        inData[index] = NULL;
     }
     else
     {
        inData[index] = aChar;
        index++;
        inData[index] = '\0'; // Keep the string NULL terminated
     }
  }
}

IMG_7457.JPG

Hello,

When you were connected to the PC, how did you connect the sensor to the PC? Is it a FTDI cable? Do you know the voltage level?
When connecting the sensor directly to the Arduino, is there any voltage level converter?

Until you get the communication worked out I would simply read the character from Serial1 and directly print aChar to Serial. Once the data looks ok, then you can add the parsing sections. If you comment out the parsing sections will it print anything to the screen?