Arduino DAQ w/strain gage

We’re conducting a static tensile test to calibrate our setup of a breadboard, Arduino Uno, and Gobetwino/Arduino software. I tried following the template available through the Gobetwino sample files to create a log of the data input from analog channel 1. We’re getting really strange values that appear to be random.

Programming is not my forte and before we begin troubleshooting our circuitry, I’m hoping to eliminate any errors in the code.

// This sketch demonstrates the use of the Gobetwino commandtypes LGFIL and CPFIL

int serInLen = 25;
char serInString[25];
int logValue1=0;
int result;

int xPin = A1; 

void setup() 
{ 
  // Setup serial comm. Initialize random function.
  Serial.begin(9600); 
  // Use the CPTEST copy file command to make a copy of a new empty logfile
  Serial.println("#S|CPTEST|[]#");
  readSerialString(serInString,1000);
  pinMode(xPin, INPUT);
  // There ought to be a check here for a non 0 return value indicating an error and some error handeling
} 
 
void loop() 
{ 
   //Create some random values to log to a file on the PC.  This could be sensor readings or whatever
   //but for this example it's just 3 random values
   logValue1= analogRead(xPin);
   logData(logValue1);
   delay(500); 
}

// Send the LOGTEST command to Gobetwino the 3 random values are seperated by semicolons
 
void logData( int value1)
{
   char buffer[5];
  
   Serial.print("#S|LOGTEST|[]#");
   Serial.print(itoa((value1), buffer, 10));
   Serial.println("]#");
   readSerialString(serInString,1000);
   // There ought to be a check here for a non 0 return value indicating an error and some error handeling
} 

//read a string from the serial and store it in an array
//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut) 
{
   long startTime=millis();
   int i;

   while (!Serial.available()) {
      if (millis()-startTime >= timeOut) {
         return;
      }
   }
   while (Serial.available() && i < serInLen) {
      strArray[i] = Serial.read();
      i++;
   }
}

Here’s an image of the data outputted to the Excel file:

Thank you so much for any and all help!
-Kinza

If, instead of sending data to excel, you simply send the data to the Serial Monitor, do you still see the random data?

What is connected to pin 15? Why not use the correct number for the analog pin (1)?

The serial monitor outputs the same random data values. Where in the code is it referencing pin 15 (that may or may not be a stupid question :/)?

Where in the code is it referencing pin 15 (that may or may not be a stupid question :/)?

A1 is an alias. On a 328-based Arduino, the alias has a value of 15.

It looks like whatever you have connected to analog pin 1 is not providing a voltage that the Arduino can read, so it appears that the pin is floating. You do have whatever is connected to analog pin 1 also connected to ground, right?

We have a breadboard for signal conditioning. The output of the breadboard is connected to A1. We also have it attached to ground.