Microcontrollers usually don’t have specific ports for measuring currents, but they do have ADC channels through which you can measure analog voltages of a certain range. This means a dc current can be indirectly measured by a microcontroller’s ADC channel by first converting the current into voltage. The simplest way of doing this is to place a resistance in series with the current path and measure the voltage drop across it. But hold on, if you place an additional resistance in the circuit, it will affect the original current. Therefore, we need to use a very small value resistance so that it’s effect in the circuit current won’t be significant.
How to measure dc current with a microcontroller? – [Link]