Tips for improving pitch detection
I'm guessing the other frequencies it gets are harmonics of the fundamental?  Like you're playing 100 Hz and it picks out 200 Hz or 300 Hz instead?  First, you should limit your search space to the frequencies that a guitar is likely to be.  Find the highest fundamental you're likely to need and limit to that.

Autocorrelation will work better than FFT at finding the fundamental, if the fundamental is lower in amplitude than the harmonics (or missing altogether, but that's not an issue with guitar):



You can also try weighting the lower frequencies to emphasize the fundamental and minimize harmonics, or use a peak-picking algorithm like this and then just choose the lowest in frequency.

Also, you should be windowing your signal before applying the FFT.  You just multiply it by a window function, which tapers off the beginning and end of the waveform to make the frequency spectrum cleaner.  Then you get tall narrow spikes for frequency components instead of broad ones.

You can also use interpolation to get a more accurate peak.  Take the log of the spectrum, then fit a parabola to the peak and the two neighboring points, and find the parabola's true peak.  You might not need this much accuracy, though.

Here is my example Python code for all of this.