Strange behavior in a non-inverting op amp
Not only can the TL082 output not swing to the negative rail, the input common mode range only starts 4V above the negative rail worst case (see datasheet). 

You don't need a rail-to-rail op-amp  but  you do need a "single supply" op-amp or an op-amp with rail-to-rail input and output capable of handling your 12V supply (many modern op-amps are not able to handle such a high voltage). 

For example, LM358 would work. Not the most accurate in the world, but quite usable, cheap as chips, relatively rugged electrically, and will easily give your 5V output with a 12V supply. 

Note that amplifiers like the LM358 have a bias current which flows out of the input pin, so a floating GPIO pin will result in the op-amp output floating up towards the positive rail. If the pin is tristated and the driver chip is powered, it will likely exceed your 5V output. A 10K from the GPIO to ground would prevent that.