This circuit is designed for quick switching of high current loads, as well as measuring current consumption of the load.

The microcontroller switches a MOSFET (Q1) which in turn performs low-side switching of an external load.
A diode (D1) is in place to suppress transients from inductive loads.

The circuit measures current by means of a shunt resistor (R1).
R1 is a 1W resistor and can as such handle up to SQRT(1W/0R001) or just above 30A with a voltage drop of 1mV/A.
The resistor is connected via kelvin sensing to a precision op-amp (U2) which amplifies the potential by a factor of 101 producing a voltage of up to 3.03V as an input to the microconroller 10-bit DAC via CURRENT (24).

This leaves room to add a 3.3V voltage reference to the microcontroller AREF (20) should we decide that the 5V VCC from the TWI port is not stable enough to produce a readout of the required tolerance.

The ideal resolution using 5V is roughly 50mA or, using a 3.3V reference, roughly 30mA.

However, the op-amp has a maximum offset voltage of 70µV, which translates to a measurement error of about 700mA meaning that the circuit needs to be calibrated to provide accurate results in contrast to being used for simple fault monitoring.

Calibration can be performed in software by running a known current through the device and recording the results.

If additional readout quality is required a two point calibration can be performed to account for stray resistance and shunt resistor tolerance.