INA219 LED Test

From Federal Burro of Information
Jump to navigationJump to search

refernce

https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout

How much current does this LED draw?

What is the voltage drop?

Wired up an Uno and a INA219 current sensor to see what the draw is for this car light LED I found on the road.

I pumped 5v through it with a 480 Ohm Resistor.

Arduino Script:

#define PIN 13
#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219(0x41);
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;

void setup() {
  pinMode(PIN, OUTPUT);

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

  uint32_t currentFrequency;

  Serial.println("setup()");

  if (! ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) { delay(10); }
  }
  ina219.setCalibration_16V_400mA();
  Serial.println("INA219 setup done OK");
  
}

void loop() {
  digitalWrite(PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  
  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.print(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.print(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.print(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.print(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");

  delay(1000);              // wait for a second
  
  digitalWrite(PIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000); 
  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.print(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.print(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.print(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.print(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  delay(1000);
}

Serial output:

Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       0.00 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: 0.00 mVLoad Voltage:  0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: 0.00 mVLoad Voltage:  0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.48 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: 0.00 mVLoad Voltage:  0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.17 VShunt Voltage: -0.47 mVLoad Voltage:  2.17 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.80 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.17 VShunt Voltage: -0.47 mVLoad Voltage:  2.17 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: 0.00 mVLoad Voltage:  0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.48 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       0.00 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: 0.00 mVLoad Voltage:  0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.16 VShunt Voltage: -0.47 mVLoad Voltage:  2.16 VCurrent:       -4.70 mAPower:         10.00 mW
Bus Voltage:   0.00 VShunt Voltage: -0.01 mVLoad Voltage:  -0.00 VCurrent:       -0.10 mAPower:         0.00 mW
Bus Voltage:   2.15 VShunt Voltage: -0.48 mVLoad Voltage:  2.15 VCurrent:       -4.70 mAPower:         10.00 mW