Thanks for you suggestions @Hedges & @BiduleOhm.
Did some sketching of the schematic are here are the thoughts:
+5V, 40mA signal from microprocessor is reduced to 1.4V, 20mA that drives the IC817 optocoupler, acting as switch.
Isolated +12V is fetched from PV panels via Zener @1mA and fed to...