ROUGH IDLE

My pickup will start fine and idle fine at about 650 to 700 rpms. After I drive for 5 to 10 minutes, or just let it sit and idle the rpms begin to drop. If I turn my headlights on the rmps drop by about 100 rpms and the lights dim. When the lights are on and the car is warm it idles between 500 and 400 rmps. I replaced the spark plugs and wires. The battery is fine. Was thinking maybe an egr valve. Any ideas would help, Thanks.