我用的是例程啊,为什么会出现编译错误呢???程序:
/* INA226 Bi-directional Current/Power Monitor. Alert Example.
https://cjmcu.taobao.com
*/
#include <Wire.h>
#include <INA226.h>
INA226 ina;
void setup()
{
Serial.begin(115200);
Serial.println("Initialize INA226");
Serial.println("-----------------------------------------------");
// Default INA226 address is 0x40
ina.begin();
// Configure INA226
ina.configure(INA226_AVERAGES_1, INA226_BUS_CONV_TIME_1100US, INA226_SHUNT_CONV_TIME_1100US, INA226_MODE_SHUNT_BUS_CONT);
// Calibrate INA226. Rshunt = 0.01 ohm, Max excepted current = 4A
ina.calibrate(0.01, 4);
// Enable Bus Over-Voltage Alert
// ina.enableBusOvertLimitAlert();
// ina.enableBusUnderLimitAlert();
// ina.setBusVoltageLimit(3.33);
// Enable Shunt Over-Voltage Alert
// ina.enableShuntOverLimitAlert();
// ina.enableShuntUnderLimitAlert();
// ina.setShuntVoltageLimit(0.0055);
// Enable Power Over-Limit Alert
ina.enableOverPowerLimitAlert();
ina.setPowerLimit(0.130);
// ina.setAlertInvertedPolarity(true)
}
void loop()
{
Serial.print("Bus voltage: ");
Serial.print(ina.readBusVoltage(), 5);
Serial.println(" V");
Serial.print("Bus power: ");
Serial.print(ina.readBusPower(), 5);
Serial.println(" W");
Serial.print("Shunt voltage: ");
Serial.print(ina.readShuntVoltage(), 5);
Serial.println(" V");
Serial.print("Shunt current: ");
Serial.print(ina.readShuntCurrent(), 5);
Serial.println(" A");
Serial.println("");
delay(1000);
}
**************************************************************************************************************************************
报错信息:
Arduino:1.8.13 (Windows 10), 开发板:"Arduino Nano, ATmega328P"
INA226_alert:9:8: error: no matching function for call to 'INA226::INA226()'
In file included from C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino:7:0:
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:40:12: note: candidate: INA226::INA226(int8_t, TwoWire*)
explicit INA226(const int8_t address, TwoWire *wire = &Wire);
^~~~~~
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:40:12: note: candidate expects 2 arguments, 0 provided
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:36:7: note: candidate: constexpr INA226::INA226(const INA226&)
class INA226
^~~~~~
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:36:7: note: candidate expects 1 argument, 0 provided
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:36:7: note: candidate: constexpr INA226::INA226(INA226&&)
C:\Users\AOC\Documents\Arduino\libraries\INA226/INA226.h:36:7: note: candidate expects 1 argument, 0 provided
C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino: In function 'void setup()':
INA226_alert:19:3: error: 'ina' was not declared in this scope
C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino:19:3: note: suggested alternative: 'int'
INA226_alert:22:17: error: 'INA226_AVERAGES_1' was not declared in this scope
INA226_alert:22:36: error: 'INA226_BUS_CONV_TIME_1100US' was not declared in this scope
INA226_alert:22:65: error: 'INA226_SHUNT_CONV_TIME_1100US' was not declared in this scope
C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino:22:65: note: suggested alternative: 'INA226_SHUNT_OVER_VOLTAGE'
INA226_alert:22:96: error: 'INA226_MODE_SHUNT_BUS_CONT' was not declared in this scope
C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino: In function 'void loop()':
INA226_alert:47:16: error: 'ina' was not declared in this scope
C:\Users\AOC\Desktop\Arduino-INA226-程序\Arduino-INA226-程序\INA226_alert\INA226_alert.ino:47:16: note: suggested alternative: 'int'
"INA226.h" 对应多个库
已使用: C:\Users\AOC\Documents\Arduino\libraries\INA226
未使用:C:\Users\AOC\Documents\Arduino\libraries\INA226Lib
exit status 1
no matching function for call to 'INA226::INA226()'
在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。
|