code 31

Code 31 is the EGR valve PFE( Pressure Feedback EGR) sensor is below the minimum voltage of .24v.

You need to check the voltage at the EGR valve sensor. If this is the 91 notch in your signature, then you need to make sure you have 5v between the orange wire and the grey/red wire first.
 
Not always. Next would be to check the voltage at the brown/light green wire to the grey/red wire, then compare that voltage to PIN 27 at the ECM and a ground. If the voltage at the sensor is between .25v and .67v but not the same at the ECM. Then the first thing is to clean the 10 PIN connectors behind the intake and see if that helps. You may also do a resistance check from PIN 27 to the brown/ light green wire. 0-5ohms is OK. If the wire checks out, and the voltage at the ECM doesnt change after the 10 PINs are cleaned, then it would point to a faulty PFE sensor on the back of the EGR valve assembly.