INA219 current sensor with PWM Ruideng 3W LED driver

  • I have set up an INA219 to measure current draw and voltage on 3 X1W LEDs connected in parallel. I set up exactly as the INA219 instructions and it seems to be working fine. I also added a PWM dimmer to the power supply and using a pot I can alter the brightness from 0 to full brightness. Now the problems occur when I try to use the INA219 to measure the current between the LEDs and the PWM Ruideng dimmer. If I don't run a ground lead from the power supply back to my Arduino Nano, the LEDs dim like they should but the INA219 readings are erratic and only occasionally show readings that I believe are correct. So I run a ground lead from the negative of the power supply - as it leaves the PWM Ruideng module -back to my Arduino. That makes the readings from the INA219 look good and are very stable, however, I lose all the dimming of my PWM Ruideng module and the pot doesn't make any difference and power to the LEDs jumps to full.

  • @petere said in INA219 current sensor with PWM Ruideng 3W LED driver:

    PWM Ruideng

    Your dimmer is apparently just a N-channel mosfet, it switches ground on and of to dim led. So when you connect led's ground to arduino's ground mofet switching is basically disabled. Try to connect ground not to LED- but to IN-. That should work.

  • @monte said in INA219 current sensor with PWM Ruideng 3W LED driver:

    N-channel mosfet

    Thank you monte,
    I tried connecting the GND directly to IN- but, although the Load voltage on the INA219 is pretty stable at 9.4 V , the current is still jumping from -1.4 up to 160mA.

  • This post is deleted!

  • @petere Can you describe your connection scheme? It will help to find a solution.

  • This post is deleted!

  • This post is deleted!

  • This post is deleted!

  • Without knowing the circuitry I assume that INA's readings interfere with your PWM. As soon as you're in an off-state current for sure is 0mA in an on-state it is like you said160mA.
    You should buffer the readings of your INA with a elec-cap to smooth the voltage over your shunt. But as said this is an assumption. We need your circuit to understand what the cause is.
    Hope that helps.

  • Mod

    @petere the INA219 readings are erratic because the current is erratic. When the PWM pulse is off, there will be roughly 0 current (but negative right after the cutoff). When the pulse is on, the current will be the same as if you didn't use PWM.
    This will change about 500 times per second (on a normal Arduino PWM, not sure if the Ruideng uses a different frequency), so INA219 will read different current at different times.

    See if setting a longer sample time helps. Not sure which library you are using but the Adafruit library defaults to 532us sample time. The longest sample time for INA219 is 69ms which should give you readings that are stable enough.

    EDIT: I see now that you already got a similar (but slightly less detailed) answer 5 days ago at

Log in to reply

Suggested Topics

  • 9
  • 1
  • 19
  • 2
  • 10
  • 4
  • 50
  • 5