Speed sensor malfunction?

I own a 97 Camry with about 180k miles on it. So my speed sensor has been fairly funky.

2 Weeks Ago
My check engine light went on, but car works fine. Went to Auto Shop to use their free check engine light reader and it stated P0500 aka Speed Sensor Malfunction, didn’t clear the check engine light. Drove to work. On lunch, the light went off.

Next Day (Still 2 weeks)
Driving for about 15 mins… then the speedometer just went down to Zero and stayed there (even though I am doing about 70 MPH). Got to my destination fine. After that left my destination… drove for about 20 minutes (at around 70 MPH, but the speedometer showed 0 MPH) and the speedometer works again (showing the actual speed I am going).

It has been working since… till today. Similar thing happened. Halfway to work, my speedometer stopped working and check engine light went on. Left work today, speedometer works now, but check engine light is still on.

So my question is, do i replace my speed sensor? is it just “dirty”? i found a video on how to change the speed sensor If it is dirty, how do you clean it?

The video I found:

I did not watch the video.

I don’t think you clean the sensor itself, I think you just clean the electrical contacts and make sure the connection is clean and tight.

If that doesn’t work, and considering 180K miles, replace the sensor.