Standalone DC microgrids can potentially influence intelligent energy systems in the future. They accomplish this by employing droop control to smoothly integrate various renewable energy sources (RESs) to satisfy energy demands. This method ensures equitable allocation of load current among RESs, promoting efficiency and smooth operation. Utilizing droop control typically leads to a reduction in the voltage of the DC bus. Hence, to uniformly distribute current among several RESs while simultaneously regulating the DC bus voltage, this research proposes a distributed secondary control technique. The proposed technique ensures fair distribution of current and eliminates bus voltage variations by integrating both current and voltage errors within the designed control loop. An innovative hybrid firefly and particle swarm optimization algorithm (FFA–PSO) is introduced to aid in parameter selection for the distributed control approach, facilitating the attainment of the intended control objectives. A DC microgrid state-space model was developed, which incorporates eigenvalue observation analysis to evaluate the impacts of the optimized secondary distributed control on the stability of the microgrid. A real-time testing setup is built using MATLAB/Simulink® R2022b software. and implemented on a Speedgoat™ real-time machine to verify the practical performance of the proposed approach in real-world applications. The results showcase the robustness of the proposed control technique in achieving voltage stabilization and even current allocation within the DC microgrid. This is evidenced by minimal oscillations and undershoots/overshoots and swift response times.