DC microgrids are composed of loads, renewable sources, and storage devices that require control and protection to operate safely. The flyback converter is an alternative to connect paralleled batteries with nominal voltage DC buses; however, until now, complex controllers have been proposed, making difficult their implementation. On the other hand, when the voltage of a DC microgrid is not properly controlled, the loads may be damaged due to the voltage outside of the safe range. Therefore, proposed in this paper are two adaptive PI-structures to control a battery charger based on a flyback converter to be used in DC microgrids. The first adaptive current controller regulates the magnetizing current for stabilizing the system, and the second adaptive voltage controller regulates the voltage of the DC bus to protect the elements of the microgrid. The methodology to design the adaptive parameters of the PI-structures is developed as follows: first, the power stage of the flyback converter is introduced to derive a control-oriented model. The battery and the DC bus of the microgrid, which are interfaced by the flyback converter, are represented with widely accepted approaches. The second step is focused on modeling the system. The flyback converter, which includes a capacitance to model the DC microgrid, is represented by a dynamic model. The differential equations are averaged, and several transfer functions of the main variables are obtained. In the third step, the transfer functions are used to design the PI adaptive current controller and the PI adaptive voltage controller. In the last step, several recommendations are made to implement the power and control stages in low-cost hardware. An application example with realistic parameters is carried out in PSIM to validate the controller loops design. A battery of 12 V is connected to a DC microgrid of 48 V through a flyback converter with a switching frequency of 50 kHz. The settling time and deviation of the DC microgrid voltage, after a perturbation, are 0.845 ms and 2.04 V respectively, while the maximum values are adjusted to be 1 ms and 2.4 V. The simulation results validate the proposed procedure and the effectiveness of the PI-structures in regulating the magnetizing current and the DC bus voltage.