Secondary frequency control systems, such as Automatic Generation Control (AGC), are used in interconnected power grids. However, when a system failure causes systems to separate into zones (islands), AGC can no longer be used, and the primary frequency control is the only control available. Moreover, load changes may cause frequency drop in some areas and over-frequency in other areas. Therefore, the goal in this article will be to design a neural network-based proportional, integral, and derivative (PID) controller in the primary control architecture to control the over frequency condition. The proposed controller is adaptively optimized in two stages by the honey badger algorithm (HBA). In the first stage, the PID controller gain values are optimized by the HBA algorithm for different values of load loss. While in the second stage, a feed-forward artificial neural network (ANN) is trained to match the tie-line measured power to the corresponding optimized HBA-PID gains obtained in the first stage. Finally, the proposed controller is implemented on a two-area interconnected thermal power system. The proposed controller results qualitatively outperform one of the best tuning methods, the Ziegler-Nichols (ZN) approach, and they show that the proposed controller has better dynamic responses with minimal frequency deviations and fast settling time, creating and guaranteeing a margin of stability for the closed loop.