# Not good at circuit, wander the voltage and current will burn out my board.

I'm using INA219 to measure the current and voltage change of when a motor is running

INA219: Zio Current and Voltage Sensor - INA219 (Qwiic) - SEN-15176 - SparkFun Electronics
"This sensor can measure voltage up to 26VDC and current up to 3.2A."

I'm using a power source which shows: "output: 12V --- 1A"

and I can't find the information of the motor I'm using online, but it can work just fine with my code and the board i have

So what i did is i connect the power source to "Vin+" on INA219 then connect "Vin-" with motor using the red wire on the motor.

But the INA219 turns out really hot and i don't know if that is normal.

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Posting images:

I'm using INA219

I've never used that chip but a quick-look at the datasheet tells me the current shouldn't pass through the chip so it shouldn't be getting hot. The current is supposed to go through a shunt resistor.

Consider buying a multimeter... If you are going to be an electronics hobbyist a multimeter is an essential tool and a cheap meter is better than no meter.

Current measurement can be tricky and it can be a pain because you have to "break" the circuit and insert the meter in series. And in current mode, the meter is a essentially a short circuit so you have to be careful that you don't short something out and/or blow the fuse in the meter. For that reason, most multimeters have a separate connection for the current measurement so you don't accidentally put the meter in current-mode and short something. Current is the least common of the 3 basic measurements (voltage, current, and resistance).

You can measure the resistance and use [u]Ohm's Law[/u] to calculate the current. This will give you the maximum "worst case" current which is the start-up or stall current. (When the motor is spinning with no load the resistance goes up and the current goes down.)

Hi Doug,

This is not strictly true:

(When the motor is spinning with no load the resistance goes up and the current goes down.)

The resistance doesn't change, what does change is the EMF produced by the motor acting as a generator, this EMF opposes the supply voltage with the result being the effective voltage across the motor falls so the current falls as there is less voltage across the motor's resistance.

I use the LED bubble as a test to see if the INA219 can measure the current and voltage, and turns out work out just fine.

The top part is when the bubble light up, the bottom part is when the bubble is off.

``````#include <Wire.h>

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  12;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup(void)
{
Serial.begin(115200);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}

uint32_t currentFrequency;

Serial.println("Hello!");

// Initialize the INA219.
// By default the initialization will use the largest range (32V, 2A).  However
// you can call a setCalibration function to change this range (see comments).
if (! ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) { delay(10); }
}
// To use a slightly lower 32V, 1A range (higher precision on amps):
//ina219.setCalibration_32V_1A();
// Or to use a lower 16V, 400mA range (higher precision on volts and amps):
//ina219.setCalibration_16V_400mA();
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.println("Measuring voltage and current with INA219 ...");
}

void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float power_mW = 0;

shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
loadvoltage = busvoltage + (shuntvoltage / 1000);

Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");
delay(1000);
// read the state of the pushbutton value:

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}

}
``````

This is the code I use to read the above data from the bubble
I use the same wiring as the video shows at "6:24"

Then I use the exact same method, want to measure the current and voltage change of the motor

The only difference is I connect the power source (blue arrow: 12V, 1A) to the qwiic step board to run the motor,
then I use the same wiring method to connect INA219 (purple board) to the motor power wire.

INA219 turns out extremely hot right after I run the program.
I was afraid I would burn out the board so I stop everything right away.

``````{
Serial.begin(115200);
Wire.begin();

//Check if Qwiic Step is correctly connected to I2C
if (motor.begin() == false)
{
Serial.println("Device did not acknowledge! Freezing.");
while (1)
;
}
Serial.println("Motor acknowledged.");
pinMode(buttonpin, INPUT);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
if (! ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) { delay(10); }
}

}
void loop()
{

if (buttonstate == HIGH){
motor.setModeRunContinuous(); //Tell the motor to run at the given speed... forever
motor.setSpeed(-350); // give the motor a speed
//Speeds are in steps per second.
//Positive is clockwise, negative is counter clockwise.
//Speeds of more than 1000 are unreliable.
//Decimal values are allowed. 0.1 = 1 step every ten seconds.
}
delay (2000);
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float power_mW = 0;

shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
loadvoltage = busvoltage + (shuntvoltage / 1000);

Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");

delay(500);
}

if (buttonstate2 == HIGH){
motor.stop();
}
}
``````

This is the code I run with, but never actually read the data because I stop it immediately.

## Blackboad, Qwiic StepredboardINA219 power source: 12v, 1A motor: random motor, can’t find much information.

You appear to be monitoring one of the windings of a stepper motor driven from an A4988
driver board?

What is the current limit set to?

It seems unusual that an A4988 could produce enough current to worry a 0.1 ohm shunt resistor
as in that sensor without itself frying.

1. Can you verify that the stepper driver works with the motor and has the correct
current set for that particular motor?

2. Can you monitor the supply current to the driver itself rather than the motor winding circuit?

Remember that you must fully power down before working on any wiring between a stepper
driver and a stepper motor, otherwise you'll probably fry the driver instantly.