INA226编译错误-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 748|回复: 1

[未解决] INA226编译错误

[复制链接]
发表于 2021-11-25 11:27 | 显示全部楼层 |阅读模式
我用的是例程啊,为什么会出现编译错误呢???程序:
/*    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()'



在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。


QQ截图20211125112617.png
发表于 2021-11-25 17:40 | 显示全部楼层
貌似库和程序不对版
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 19:43 , Processed in 0.072901 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表