# How to measure DC current with a microcontroller?

I have a project where I need to measure DC currents in the range of 0-150 A. I am using an STM32F446RE MCU. I can't use the solution where I convert current to voltage using resistors and reading them using the ADC pin of my MCU. I have found some components like the ACS712 Current Sensor that internally converts current (0-30 A) into a voltage, which I could later read using my MCU, but I can only find cases where they use a PIC MCU. For example: https://circuitdigest.com/microcontroller-projects/digital-ammeter-circuit-using-pic16f877a-acs712 .

What changes would I need to do the make this work on my MCU?. Does anyone have any ideas?

• Why can't you use a shunt resistor? What resolution do you need? – awjlogan Apr 19 '18 at 18:02
• I could use a Shunt resistor if I was only measuring currents from 0-5A.Because I need to measure from 0 to 150 A the power rating of the resistors would need to be very high while the value of Ohm would need to be low. – Pedro Lopes Apr 19 '18 at 18:05
• It doesn't matter if it's 150 A, you can still use a shunt, it would just have to be (very) high powered. – awjlogan Apr 19 '18 at 18:07
• The ACS712 is a Hall effect current sensor, something like that is probably your best bet. – awjlogan Apr 19 '18 at 18:09
• Google hall sensor 150A. – StainlessSteelRat Apr 19 '18 at 18:40

The ASC712 output range is 0 to 5V, the STM32 ADC pins accept 0 to 3.3V*, therefore you need a Voltage Divider. simulate this circuit – Schematic created using CircuitLab

Using the general formula gives $$V_{ADC} = \frac{R_{2}}{R_{1}+R_{2}} \cdot VI_{OUT} = \frac{3000\Omega}{2000\Omega+3000\Omega} \cdot 5V=3V$$

which is accepted by the ADC input pin.

* If the STM32 supply voltage is less than 3V, adjust the resistor values to match it.

• Does the ASC712 accept currents from 0 to 150 A? – Pedro Lopes Apr 24 '18 at 12:11
• I found this current transdutor , Hais 50-P, that has a wide current range -150 to 150A . Do you think i can use this one in the place of the ACS712? – Pedro Lopes Apr 24 '18 at 12:24