Detecting external electron spins using nitrogen-vacancy centers