查看: 99|回复: 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

签到天数: 71 天

[LV.6]常住居民II

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

本版积分规则

热门推荐

esp8266  Node mcu多用 含土壤温湿度和DHT11和四路继电器
esp8266 Node mcu多用 含
原来有空气湿度 和四路继电器 现在新加了土壤湿度的在这个里面 这个是为什么?
ArduinoBox
ArduinoBox
这个软件具体是做什么用的? 可以导入程序进行模拟吗?
按键个数上限
按键个数上限
使用ESP32 arduino 蓝牙开发时,设置了许多按键,前12个没有问题,之后的都不会响应如
ESP32 S2 的 SPI
ESP32 S2 的 SPI
ESP32 S2的Arduino环境对于 SPI 的定义是有问题的。 打开ESP32-S2技术参考手册 (“es
啃萝卜可不可以用于arduino UNO R3 开发板
啃萝卜可不可以用于arduin
啃萝卜可不可以用于arduino UNO R3 开发板
Copyright   ©2015-2016  Arduino中文社区  Powered by©Discuz!   
快速回复 返回顶部 返回列表