Ina219 module - arduino uno - dc motor - l298n

Hi

I want to measure the current of the motor for that i have this INA219 breakout board(module) and i want to collect the current of the brushed dc motor.
i have followed this connections, but values i am getting in serial monitor is not understandable.
Please help me with this

In the IDE on the Menu bar, click on Edit then Copy for Forum. Then paste your code here.

okay

Do you actually have the INA219 board plugged into the breadboard that way?
If yes , you are shorting all the pins.

Not quite right follow the instructions in post#2

#include <Wire.h>
#include <Adafruit_INA219.h>

#define INA219_ADDRESS (0x40)

Adafruit_INA219 ina219;

const int ENA_PIN = 9;
const int IN1_PIN = 11;
const int IN2_PIN = 12;

void setup() {
  Serial.begin(9600);
  
  // Initialize INA219 sensor
  ina219.begin(INA219_ADDRESS);
  ina219.setCalibration_32V_1A();
  
  // Set motor control pins as outputs
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);
}

void loop() {
  // Set PWM speed and direction for the motor
  int inputPWM = 150; // Example PWM value (adjust as needed, 0-255)
  
  // Set motor direction and speed
  analogWrite(ENA_PIN, inputPWM);
  digitalWrite(IN1_PIN, HIGH);
  digitalWrite(IN2_PIN, LOW);
  
  // Read current from INA219
  float current_mA = ina219.getCurrent_mA();
  Serial.print("Current: ");
  Serial.print(current_mA);
  Serial.println(" mA");
  
  // Delay for stability and to see the output
  delay(1000);
}

Perfect

Looks OK so what is the problem?

when i am changing the delay to 1ms, then only i am able to see some values, for slower sampling rate, i see no response. Also the values are fluctuating. for the same pwm and without load

1ms is too fast

Also the values are fluctuating. for the same pwm and without load

Without a load the readings are meaningless. You can't measure a current without a load.

okay, i'll check it with load and share the results for better understanding

Since you are using the Adafruit library I assume you are using the Adafruit board, is that correct?

I am using this board