Today, with the increasing penetration of microgrids, the degree of complexity and non-linearity of power systems has increased, causing conventional and inflexible controllers not to perform well in a wide range of operating points. In this paper, a self-tuning proportional-integral (PI)-controller based on a soft computation of a combination of genetic algorithm (GA) and artificial neural network (ANN). The GA-ANN is used to control the frequency of a microgrid in an island mode to automatically adjust and optimize the coefficients of a PI-controller. The proposed PI-controller is located in the frequency control secondary loop of an island microgrid. Since the ANN is a local search algorithm and can be located in local minimum points and on the other hand improving its performance requires a lot of training data. The ANN parameters are optimized using the GA algorithm's proposed controller. Train ANN online to adapt to the system and change the PI-control coefficients without a lot of training data, in addition to avoiding being in the local minimum points.The microgrid tested included various distributed generation units including battery energy storage that tried to create a more realistic frequency response for the microgrid by considering nonlinear factors on the model of these resources. Finally, the simulation results with different perturbations indicate the proper performance of the proposed controller.