Need help with battery powered system design

Before I start, I'd like to say that I am not an electrical engineer or anything, just a high student, before ya start bashing me.

Power info :

  • Arduino -> 100mA @ 5V peak (always under I2C load + averaging data, SPI,UART bursts)
  • Gas Sensors (MQ2 to MQ135) -> 200mA Each @ 5V peak
  • WiFi Module (CC3000) /ESP8266-> 300mA peak
  • Bluetooth Module (HC05) -> 40mA ~ peak
  • Basically also an emergency power bank.

+++

  • 5x 18650 (3.5V - 4.2V) (powerbank + backup power)
  • 5x TP4056 1A 5V with DW01 protection

+++

  • Mains SMPS : 12V 3A , for both charging 5V 5A (11W overheard, just in case) - lets name it mains smps.
  • Supply A (XL4015) :[12V -> 5V when mains powered (Arduino/sensors + charging); 5V->5V USB port( battery powered, only for USB receptacle)]
  • Supply B (LM2577+LM2596) :[3.7V -> 5V]

Now my question is,
I want my circuit + supply A(it has minimum 5V input, useable - just want to power the usb reptacle so it works like a powerbank) to be powered by supply B (i.e. batteries to 5V) when 5V supply A (i.e. powered by 12V mains smps normally) goes down.
Can I connect them in parallel, with maybe a diode in wire (they have input protection, not sure about output) ?
And also, my power goes through minimum 2 supplies with smps noise, will it affect my analog devices (gas sensors) ? [/list]

I'm not sure if I understand it. You could draw a picture a make a photo of that.

Normally, a power supply charges the battery, and the battery voltage goes to the device (using DC-DC converters). That is a simple and safe way. Without a shortcut, without a bypass via a diode.

The gas sensors require a steady voltage for the heater, but a ripple is not a problem. The analog value can be averaged, to remove most of the ripple that has gotten into the analog section.

Koepel:
Normally, a power supply charges the battery, and the battery voltage goes to the device (using DC-DC converters). That is a simple and safe way. Without a shortcut, without a bypass via a diode.

That's how I have set up my power supplies, one charges the batteries by sending power to BMS [step down], other steps up the voltage from the batteries [step up].
But I would like to use the USB-A 2.0 port on my step down power supply (which can accept 5.5V) and then maybe step it down to (4.8V), just because it has a USB port :stuck_out_tongue:
I would want my batteries to charge and the power supply to supply power independently though, because the USB port is for the power bank, and if I pass all the power through the batteries then they'll never charge completely.
Maybe a relay or something (I'll probably use the NO pin)?
My goals are :

  • Use the batteries only when main power adaptor is disconnected
  • Always have 5.2V power on the USB port, whether from batteries or from 12V supply(itself)