I power a 12V 0,84 W fan from a 5V power supply through MT3608 step-up converter. I would like the fan to work for about 5 seconds more after main power is down. Is it possible to do it using a capacitor? What should be its capacitance and connection to the fan?
You can power the MT3608 from a large capacitor on its input.
You will need a diode between the 5V supply and the capacitor to prevent the capacitor from back-powering the 5V supply once the 5V is off, . This could be either a schottky diode, or an ideal diode controller such as those made by Linear Tech.
Assuming you really get the 93% efficiency stated in the MT3608 datasheet, the input power will be 0.84W / 0.93 = 0.903W.
You say you want to power the fan for 5s, so the total energy is 5s * 0.903W = 4.515J.
The MT3608 has a 2V to 24V input range.
If the capacitor is to supply power to the fan, the energy lost by the capacitor will be equal to the energy input to the converter to power the fan, which is 4.515J.
The initial voltage on the capacitor is 5V minus a diode drop. Lets assume the initial voltage is 4.5V. The final voltage is 2V, which is the lower limit of the input range for the MT3608. So...
0.5 * C * ((4.5V)^2 - (2V)^2) = 4.515J
So C = 4.515J * 2 / ((4.5V)^2 - (2V)^2) = 555mF.
So you need a capacitor rated to at least 5V and 555mF.
You will need to size the capacitor larger than 555mF to account for any voltage drop on the output due to the internal ESR of the capacitor, as well as decreasing efficiency on the converter as the input voltage gets lower.