I’ve tried working this out before, but now I’ve drew up a few diagrams to try and explain things better. Hope someone can advise.
I made a small data logger that records to a micro SD card. Using SPI, pins 1 and 8 are not normally used. But I connected pin 1 to reset and pull-up resistor because I also use the micro SD card socket to program the logger.
I am now trying to work out a way to use pin 8 to charge the loggers battery. I somehow need this pin to be connected to the battery when charger is connected, and disconnected when the SD card is inserted, so the SD card is not damaged by the higher battery voltage. The logger runs at 3.3v, and the battery has a max charge of 4.23v.
My first idea was to use a diode like in pic1. The only problem is that the forward voltage drop would not allow the battery to charge fully.
My second idea in Pic2 is kind of the same, but I added a pull-up to the pin because I read that all unused SD pins should not be left floating. I know the battery would still not get to full voltage, but would that setup work to protect the SD card from the high battery voltage while pulling the pin up to 3.3v?
Would it protect the 3.3v side of the logger from high charge voltage when charger is connected?
In Pic3 I have kept the pull-up idea but replaced the diode with a P-channel MOSFET. I’m not sure if this is how a MOSFET should be connected. My idea is that the MOSFET is always off until the charger voltage is added to pin 8, at which point it will turn on and allow power to battery. Is there a voltage drop across a MOSFET?
I just realised that the pull-up resistor will always power the MOSFET. So if I get rid of that and let the pin float would the MOSFET idea work?
I would be grateful if anyone has any other suggestions on how to make this work.