Arduino Uno Power Selection

Can we force the Arduino Uno to take power from an external source only

I wish I can bypass the USB power I would like to disable the auto power selection and tell the board to that only the power form an external source! Any way? if we cannot would it be a C++ function or librarie that I would be able to know If the power comes from the USB or from an External source.. Thank you for your suggestion

There is no software indicator for the power path. The auto select circuit is relatively simple. The only way to ensure External Power is used, is to make sure at least 7.5V is present.

Maybe you could setup a voltage divider to monitor Vin and attached the divider's output to an analog input.

Looking at the Uno schematic, it appears that IC U1A controls the switching of the P-channel MOSFET that lets USB power into the board by comparing whether 3.3V from regulator U2 is higher than Vin/2.
Looks to me that one could lift Pin2 of that device and add an isolating pad under it and then ground the lead (via a small switch, perhaps), and thus require that all power come from Vin (to be regulated) or from VCC directly (from a known good 5V source, such as 3 AA batteries, or 5v regulated walwart).
One would also need to connect pin31 of U3, UVCC, to pin 4, VCC, if comm’s via the USB port were still needed.