I’m working on a project for the Electron that will normally be powered from 120VAC via a 5V power supply, but it will still need to supply 5V to a sensor when the power goes out and it is running off of the battery. I have an idea for a circuit I’d like to share and hopefully get some feedback from others, since I’ve only tested it in theory on a simulator and won’t be able to actually test it with the Electron for a few more weeks.
It requires a boost converter or charge pump, a PMOS transistor with a logic level gate and enough current capacity to handle the load, and a NOT gate. It also uses one pin on the Electron. I’m using a second PMOS and a pulldown resistor for the NOT gate in the simulation, but other configurations should work.
Here is the simulation and schematic for it. When there is power coming in from the 5V power supply, it will be used to power the sensor and the boost converter will be turned off. When the external power is turned off, the boost converter can automatically be switched on or it can be manually controlled with a GPIO pin.
The power supply on the right is simulating the boost converter and the gate of the NMOS is just to simulate its enable pin. The boost converter would be drawing power from the battery via the Li+ pin on the Electron when it is enabled.
The power supply on the left is simulating the external 5V power supply. It is connected to the input of the NOT gate and through a reverse current protection PMOS (similar to this example, except its gate is connected to the output of the NOT gate) and to the load.
The middle power supply is simulating a GPIO pin on the Electron and is supplying power to the NOT gate. When the pin is HIGH and the 5V power supply is turned off, the output of the NOT gate goes HIGH, which turns on the boost converter and puts voltage on the gate of the reverse current protection PMOS which prevents its power from going into the VIN pin. If the external 5V supply is off and you turn the GPIO pin LOW, it will turn off the boost converter to save battery power. This will also allow the boost converter to be automatically turned off if the Electron is put into deep sleep or if the battery gets low enough that the PMIC shuts it down.