The main focus of the battery management system is the estimation of the battery’s State of Charge (SOC) which is an indicator to determine the driving range of an electric vehicle. The Extended Kalman Filter (EKF) algorithm is the most promising for SOC estimation when the system is running. The EKF state estimation algorithm is sensitive to the process noise covariance matrix Q and measurement noise covariance matrix R. Inappropriate noise covariance matrices reduce the accuracy and make divergence in state estimation. In this paper, the Sunflower Optimization algorithm (SFO) is used to optimize the noise covariance matrices before applying EKF for online SOC estimation. This simply indicates that the iterative SFO does not affect the instantaneous response of EKF in online estimation because the SFO is only performed once to determine the optimal values. The effectiveness of the proposed identification is examined through the constant discharge rate test and dynamic stress test. As observed, the performance indices such as maximum error, Mean Absolute Error, Mean Square Error and Root Mean Square Error of both SOC and voltage obtained by the proposed SFO-EKF are low compared to the other three methods. Besides accuracy, the proposed method quickly converges even when the initial SOC is inaccurate. The simulation results show that the proposed method has high accuracy and a better convergence rate in terms of estimating SOC under static and dynamic operating conditions.