Using DC-DC-step-up and DC-DC-step-down converters

360modena_cs:
What I want to ask is this:

If I connect battery to the ADC of Arduino and at the same time I supply the Arduino from supply jack (or the USB better) don't I have a short circuit? I thought of using an optocoupler, something like this...

https://www.mouser.com/ds/2/365/pc817x_eJ-184297.pdf

What is your opinion?

No. Reading voltages on A/D inputs whose sources are the same (or different) from the power supply source is a vary common thing. But the battery voltage applied still MUST be brought within the accepted range of 5V max. Hence, the voltage divider I suggested. Even if there could be a short, the high resistances in the voltage divider I explained would limit the current to a tiny amount. That current would be the difference in voltage divided by at least 10,000 ohms. But you could use a pair of 100K resistors instead if you feel you need the extra safety or isolation.