GY-63_MS5611/libraries/INA219/examples/INA219_demo/INA219_demo.ino

71 lines
1.5 KiB
Arduino
Raw Normal View History

2022-09-07 09:20:03 -04:00
//
// FILE: INA219_demo.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/INA219
#include "INA219.h"
#include "Wire.h"
INA219 INA(0x40);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("INA219_LIB_VERSION: ");
Serial.println(INA219_LIB_VERSION);
Wire.begin();
if (!INA.begin() )
{
2023-03-31 14:30:08 -04:00
Serial.println("Could not connect. Fix and Reboot");
2022-09-07 09:20:03 -04:00
}
2023-03-31 14:30:08 -04:00
// INA.setMaxCurrentShunt(1, 0.002);
// delay(1000);
// INA.setMaxCurrentShunt(2.5, 0.002);
// delay(1000);
2022-09-07 09:20:03 -04:00
INA.setMaxCurrentShunt(5, 0.002);
delay(1000);
2023-03-31 14:30:08 -04:00
// INA.setMaxCurrentShunt(7.5, 0.002);
// delay(1000);
// INA.setMaxCurrentShunt(10, 0.002);
// delay(1000);
// INA.setMaxCurrentShunt(15, 0.002);
// delay(1000);
// INA.setMaxCurrentShunt(20, 0.002);
// delay(10000);
Serial.println(INA.getBusVoltageRange());
2022-09-07 09:20:03 -04:00
}
void loop()
{
2023-03-31 14:30:08 -04:00
Serial.println("\n\tBUS\t\tSHUNT\t\tCURRENT\t\tPOWER\t\tOVF\t\tCNVR");
2022-09-07 09:20:03 -04:00
for (int i = 0; i < 20; i++)
{
Serial.print("\t");
2023-03-31 14:30:08 -04:00
Serial.print(INA.getBusVoltage(), 2);
Serial.print("\t\t");
Serial.print(INA.getShuntVoltage_mV(), 2);
Serial.print("\t\t");
Serial.print(INA.getCurrent_mA(), 2);
Serial.print("\t\t");
Serial.print(INA.getPower_mW(), 2);
Serial.print("\t\t");
Serial.print(INA.getMathOverflowFlag());
Serial.print("\t\t");
Serial.print(INA.getConversionFlag());
2022-09-07 09:20:03 -04:00
Serial.println();
delay(1000);
}
2023-03-31 14:30:08 -04:00
delay(1000);
2022-09-07 09:20:03 -04:00
}
2023-03-31 14:30:08 -04:00
// -- END OF FILE --