How do you get grade to work properly again?

I have a problem with my Garmin Edge 540.  I have it since 2023.  The grade percentage used to work properly.  Then a few times last year when I was riding in heavy rain the numbers were totally messed up.  I assumed it was caused by the rain.  The Garmin returned to normal later.

Then in 2025 I started riding outside again recently.  The grade stat doesn't work anymore.  It doesn't matter whether it rains or not.  I ride on a flat road and it gives me -2% the whole time.  I go slightly uphill on 1% grades and it gives me -1%.  I shut down my Edge and it still did the same thing after.

Is there a way to fix this?