A saltwater F250 that logs a knock sensor message twice a season, always after a wet run and never when the mechanic looks at it, probably doesn't have a bad knock sensor. Look at the check steps the ECU attaches to almost every fault on a Yamaha outboard. Before sensor resistance, before voltage, the first step usually reads "check the wiring connection and for damage." On a boat that lives in salt, that line deserves more weight than the rest.
Why corrosion passes for a bad sensor
Green crust inside a connector adds resistance. A temperature sensor or a TPS reports by changing its resistance or voltage, so the ECU can't tell a drifting sensor from a contact that has picked up a few hundred extra ohms. Switch inputs like the shift position switch or the engine shut-off switch are even touchier, because a damp contact can read closed when it should be open. The result is a message that names a perfectly good part, and a parts bill to match.
Patterns in the fault memory worth noticing
Irregular signal rather than out of specification
Messages worded as an irregular signal (knock sensor, pulser coil, cam position sensor, shift position switch) describe a signal that comes and goes. That fits a loose or corroded pin better than a dead component, which tends to stay dead.
Messages that return, but not every time
A sensor that has truly failed usually logs again on the next run. One that comes back only after rain, a washdown or a choppy day is pointing at moisture getting in somewhere.
Several messages from the same corner of the engine
Two or three faults from parts that share a harness branch or a ground point suggest the shared piece. Three sensors rarely fail in the same week.
To spot these patterns you need history, so save the fault list each time you read the fault codes instead of clearing and forgetting.
Catching it in live data
Live data catches what the memory misses. With the M-JET Diagnostic on the engine's diagnostic port, key on and engine off, watch a suspect value while you gently wiggle the harness near its connector. A temperature reading that jumps by ten degrees when you move a plug isn't a sensor problem. Same for the shift position switch flipping without the lever moving, or TPS voltage flickering with the throttle held still. On the big V6 and V8 engines with paired sensors for port and starboard, a gap between the two that changes when you touch a connector tells you the same thing. Which values your engine offers is listed on the live data page.
Fixing it so it stays fixed
Unplug, look, clean with electrical contact cleaner, and check the pins for green or white deposits and the seals for cracks or flattening. Replace a connector with pitted pins. Cleaning won't bring metal back, and a pitted pin will start the same cycle again. A bit of dielectric grease on the seal helps keep water out, though it doesn't repair anything already damaged. Then clear the memory and run the boat several times in the conditions that triggered the message. A fault that stays away through three or four wet outings is about the best proof you'll get.
Some spots take more abuse than others. I'd start with anything low on the powerhead close to the water, the harness where it passes through the bottom cowling, and the main battery connections at both ends of the cable.