Hello
I use INA219 sensor with the library from Adafruit.
When I get Voltage value or current value I get always an answer. Even when the INA219 sensor is not connected ....
Is there a way to know if the received value from this function is valid ?
the problem is not my software
I get the standard adafruit exemple wich display Volt and Amp.
If I connect the INA219 between a load and the arduino
I get the real Voltage and the real current.
But if I did not connect the INA219 to the arduino I get also some values for Volt and Amp...
Which is not possible!
So my question is : how to be sure that value are real one or "fake" because the INA219 is not responding...
The INA219 is a current sensing transducer using I2C comms, therefore the lack of this device on your network will mean that zero data will come over the network. I think this is the reason why dyso has asked you to upload your code. Clearly there is some default condition which allows the system to display something even though nothing has been received.
What have you got to lose by showing your code? There are some clever and talented people on here that will help you if you allow them to.
Thanks for help !
Of course I have no problem to show my code (below)
It was just I was wondering if my first explanation of the problem was clear enough
Serial.begin(9600);
Serial.println("Serial");
delay(50);
ina219_Solar.begin();
// ina219_Solar.setCalibration_16V_400mA(); // set measurement range to 16V, 400mA
Serial.println("Solar");
delay(50);
ina219_Battery.begin();
// ina219_Battery.setCalibration_16V_400mA(); // set measurement range to 16V, 400mA
Serial.println("Battery");
delay(50);
ina219_Load.begin();
// ina219_Load.setCalibration_16V_400mA(); // set measurement range to 16V, 400mA
Serial.println("Load");
delay(50);
Serial.println("*******");
delay(50);
}
Serial.print("solar ");
Serial.print(solar_busVoltage);
Serial.print(" V ");
Serial.print(solar_shuntVoltage);
Serial.print(" V ");
Serial.print(solar_current);
Serial.println(" mA ");
Serial.print("battery ");
Serial.print(battery_busVoltage);
Serial.print(" V ");
Serial.print(battery_shuntVoltage);
Serial.print(" V ");
Serial.print(battery_current);
Serial.println(" mA ");
Serial.print("load ");
Serial.print(load_busVoltage);
Serial.print(" V ");
Serial.print(load_shuntVoltage);
Serial.print(" V ");
Serial.print(load_current);
Serial.println(" mA ");
Serial.println("*******");
delay(5000);
}
And the result with no INA219 sensor connected to Arduino:
16:17:27.543 -> Serial
16:17:27.609 -> Solar
16:17:27.643 -> Battery
16:17:27.709 -> Load
16:17:27.743 -> *******
16:17:27.843 -> solar 0.14 V 2.72 V inf mA
16:17:27.843 -> battery 8.35 V 167.06 V inf mA
16:17:27.909 -> load 8.35 V 167.06 V inf mA
16:17:27.909 -> *******
16:17:32.870 -> solar 0.14 V 2.72 V inf mA
16:17:32.870 -> battery 8.35 V 167.06 V inf mA
16:17:32.935 -> load 8.35 V 167.06 V inf mA
Yes I know it is a solution but this sketch is only a way to chek INA219 works.
After it will be a raspberry that will automaticly get the value send by arduino in serial
And the begin test is only at arduino initialisation.
I would like a way to test the validity of the get INA219 command....
Wawa ramdom is normal for mesurment value of voltage at arduino pin or even at INA219 pin.
But if arduino request via a numerical bus to INA219 and INA219 did not answer (as he is not connected) I expect somme error or warning or constant value from the arduino software function requesting the value...
Dyso I will have a look of the cpp source code of the function to understand.
I don't think it will change with HW executing the same software
ewok2:
Wawa ramdom is normal for mesurment value of voltage at arduino pin or even at INA219 pin.
But if arduino request via a numerical bus to INA219 and INA219 did not answer (as he is not connected) I expect somme error or warning or constant value from the arduino software function requesting the value...
Dyso I will have a look of the cpp source code of the function to understand.
I don't think it will change with HW executing the same software
So your assumption is that since there is no I2C device connected to the I2C pins, then the Adafruit Library should be able to know that, and return ideally a value of ZERO when it queries the device for a value. HOWEVER, when you leave the I2C pins floating, there is still random noise on the pins and the Adafruit Library could be interpreting that noise as a value that it reports back to you.
Look at the library code and see what it's doing.
I would be curious, however, if you set the I2C pins to INPUT_PULLUP (Like this for an Arduino Nano):