GPS Sensor only returning 0 for x and y positons

Hello, I am using a GPS sensor for auton this year and I was testing the GPS’ position but it kept returning 0 for both x and y positions. The GPS Sensor is called GPSSensor and I calibrated the sensor in the pre_auton function. Here is the code:

void Calibrate() {
  GPSSensor.setOrigin(0,0, inches);
  while (true) {
    double xPos = GPSSensor.xPosition(inches);
    double yPos = GPSSensor.yPosition(inches);
    Brain.Screen.print(xPos);
    Brain.Screen.print(", ");
    Brain.Screen.print(yPos);
    wait(5, sec);
    Brain.Screen.newLine();
  }
}

*Sorry the code isn’t formatted nicely, I don’t know how to do that
edit: code tags added by mods

Also, I checked the GPS Sensor on the brain and it is seeing everything correctly and even displays the position correctly but for some reason it is just not returning the values correctly.

I am not experienced at text coding but won’t your code simply fill all the rows with recorded positions then run off the screen and stop updating the screen?

1 Like

As what above stated, it could be working but the values are outside of the V5 screen. It was so long ago but maybe try:

Brain.Screen.setCursor(0,0);
Brain.Screen.print(xPos);
Brain.Screen.setCursor(1,0);
Brain.Screen.print(yPos);

Thank you for the suggestions, but it turns out I just had the wire in the wrong port. Sorry for the inconvenience.

1 Like