You are probably better off doing this with MOSFETs. There are two back to back because otherwise the body diode would cause flow from one battery to the other.
When you apply some voltage to R1 from your MCU, Q1 will pull the gates of Q2 and Q3 low, turning them on, so current will be allowed to flow in either direction. When Q1 is off, all transistors will turn off and the two batteries will be isolated.
The R2 pull-up assumes that V1 is the primary source.

simulate this circuit – Schematic created using CircuitLab