I know this is an old thread, but I've searched many forums and haven't found any with a permanent solution.
I've been having this problem on my 2005 Baja Turbo 5MT w/ 72K miles since I bought it in May, but hasn't been a problem with my 2004 Baja Turbo 4EAT w/176K miles that I bought in February. The RPMs would fluctuate to 1500 rpms and below at idle or I could feel small surges in gear just before the CEL would come on. I would notice sometimes that the cruise light would flash before the CEL would illuminate. I don't know if this problem is related to the difference in ECUs and people usually don't post about their trans configuration, so I cannot say for sure. This is just my experience. Seems unusual that the car with 176K miles operates fine and the 72K mile car is plauged with this issue.
So far, I've done all the tests in the service manual, more than twice. I haven't done any data logging, but I hooked up my Subaru Select Monitor and both signal outputs seem to be normal when I depress the accelerator through it's full range of motion. I've tried swapping the pedals and have even replaced the pedal with a new Subaru OEM part. Nothing has worked. It has started to become a daily occurence and can be quite dangerous in certain situations. I think it has to do with humidity like others have mentioned, because it usually occurs more on cloudy/rainy days and early in the morning/late in the evening. The P2138 code refers to a difference in the voltage output of the two potentiometers in the pedal assembly. I thought that maybe I'd try hooking both signal inputs going to the ECU to one of the signal outputs on the pedal assembly so that there would never be any differences in voltage, causing the ECU to go into limp mode. It has been three days so far and the idle is much smoother, there are no longer any surges, and I have not yet had a CEL.
DISCLAIMER !!!!
Try this mod at your own risk, but I think that limp mode is much more dangerous and have had many close situations where I've lost the pedal on a busy highway, crossed dangerous intersections or even stalled out on hills. If you try this mod and you have a surge or wide open throttle situation, just be aware that the simplest thing to do is to put the car in neutral before pulling over and turning off the ignition. I say this as a disclaimer, because this situation happened with the Toyota pedal recalls and people died.
Below is a link to pictures of the schematic for the pedal position sensor and my jerry rigged wiring job. I unhooked the connectors and used some other terminals I had from another harness to make my mod reversible without cutting any wires. The signal input wires on my car are the blue with white stripe and the white with blue stripe. They are terminals 2 and 5 on the wiring harness.
imgur.com/a/io0Fm
I hope this helps. Every forum I've read hasn't found a solution and I've even read about individuals selling their car because of this. I'm too stubborn and I love my Bajas.
The wife says I have to sell one though.
I will report back if I have any further issues.