0

Unable to compile project with INA260
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Unable to compile project with INA260

by wesg on Mon May 17, 2021 9:24 pm

I am building a project that uses a BNO055 IMU and INA260 current sensor. Originally I had the INA219 but require more current capacity so I am trying to compile my project with the new library. I am not using the Arduino IDE but instead the arduino-cmake toolkit (it's on Raspberry PI using the Robot Operating System framework).

All of that to say that I was successfully able to compile the INA219 library after fairly basic import lines. Once I changed out to the 260, nothing worked, despite making similar import changes.

Here are my top level firmware imports:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <Adafruit_INA260.h>
#include <utility/imumaths.h>


The compiler says it can't find the Adafruit_I2CDevice.h file inside the 260 library. I have this file inside the Adafruit_BusIO library but it can't find it.

Code: Select all | TOGGLE FULL SIZE
In file included from /home/raspi/ros-project/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:37:0:
/home/raspi/ros-project/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.h:21:32: fatal error: Adafruit_I2CDevice.h: No such file or directory
compilation terminated.

I spent a long time trying to get it to compile by changing the imports not only on the top level sketch but the library files as well. Nothing worked. I suspect one of the big issues is that the library folder doesn't match the header (Adafruit_BusIO vs Adafruit_I2CDevice.h). Any suggestions for how I can tell the compiler where the file is located and ideally not have to edit the library folders?

wesg
 
Posts: 118
Joined: Thu Mar 18, 2010 10:00 pm
Location: Toronto, Ontario

Re: Unable to compile project with INA260

by wesg on Mon May 17, 2021 9:41 pm

Additionally, if I do work through the errors by changing the import statements, eventually I come full circle and instead of the error I get the following instead. I means nothing has actually connected.

Code: Select all | TOGGLE FULL SIZE
libmega2560_Adafruit_INA260.a(Adafruit_INA260.cpp.obj): In function `Adafruit_INA260::alertFunctionFlag()':
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:326: undefined reference to `Adafruit_BusIO_RegisterBits::Adafruit_BusIO_RegisterBits(Adafruit_BusIO_Register*, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:327: undefined reference to `Adafruit_BusIO_RegisterBits::write(unsigned long)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:327: undefined reference to `Adafruit_I2CDevice::Adafruit_I2CDevice(unsigned char, TwoWire*)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_I2CDevice::begin(bool)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_RegisterBits::Adafruit_BusIO_RegisterBits(Adafruit_BusIO_Register*, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::read()'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_RegisterBits::read()'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:327: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::read()'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:327: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::read()'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:327: undefined reference to `Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice*, unsigned int, unsigned char, unsigned char, unsigned char)'
/home/raspi/ros-floatbot/src/floatbot_arduino/firmware/libraries/Adafruit_INA260/Adafruit_INA260.cpp:328: undefined reference to `Adafruit_BusIO_Register::read()'

wesg
 
Posts: 118
Joined: Thu Mar 18, 2010 10:00 pm
Location: Toronto, Ontario

Re: Unable to compile project with INA260

by adafruit_support_mike on Tue May 18, 2021 3:49 am

Reinstall a copy of the original BusIO library, relaunch the Arduino IDE, and see if the example sketches for BusIO show up under the File -> Examples menu.

adafruit_support_mike
 
Posts: 63059
Joined: Thu Feb 11, 2010 2:51 pm

Re: Unable to compile project with INA260

by wesg on Tue May 18, 2021 8:27 am

Thank you Mike. Noted in the original question is that I'm not using the IDE directly but the cmake framework. I suppose the errors/issues would have to go through that instead?

wesg
 
Posts: 118
Joined: Thu Mar 18, 2010 10:00 pm
Location: Toronto, Ontario

Re: Unable to compile project with INA260

by adafruit_support_mike on Tue May 18, 2021 6:05 pm

Ah.. I have no idea how cmake handles its library search paths.

If it can't match the Arduino IDE, it will probably be easier to build your own #include directory and copy files to that. That will be a trial-and-error process. Build environments are complicated things.

adafruit_support_mike
 
Posts: 63059
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.