brettmarl / node-ina219

Node.js Driver for Adafruit INA219
7 stars 10 forks source link

Different address not working #7

Closed danny12321 closed 5 years ago

danny12321 commented 5 years ago

I am trying to get an ina219 to work on the address 0x41. It is showing op with the command below.

sudo i2cdetect -y 1

image

But when I try my code below I get this error.

var ina219 = require('ina219');

  ina219.init("0x41");
  ina219.enableLogging(true);

  ina219.calibrate32V1A(function () {

    ina219.getBusVoltage_V(function (volts) {

      console.log("Voltage: " + volts);
      ina219.getCurrent_mA(function (current){

        console.log("Current (mA): " + current );
      });
    });
  });

image

Can you please help me. Thanks in advance!

danny12321 commented 5 years ago

I see my own problem now. In the docs it says the address (in my case 0x41) has to be a string but it needs to be a hexadecimal instead.