Error compiling for board Arduino NANO 33 IoT

I am attempting to use the adafruit BNO055 orientation sensor with Arduino Nano 33 iot. The code I am using is from the adafruit example project and works perfectly with Arduino Uno and Arduino Mega. However, when uploading to the Arduino Nano 33 iot it produces "Error compiling for board Arduino NANO 33 IoT".

I have installed the following libraries...

  • Adafruit BNO055
  • Adafruit Unified Sensor
  • Adafruit Bus IO

The code I am using is below...

#include <Wire.h>
#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

Adafruit_BNO055 bno = Adafruit_BNO055(55);

void setup() {
  Serial.begin(9600);

  Serial.println("Orientation sensor test...");
  if(!bno.begin())
  {
    Serial.print("No BNO055 detected");
    while(1);
  }
  Serial.print("BN055 detected");
  delay(1000);
    
  bno.setExtCrystalUse(true);

}

void loop() {
  sensors_event_t event; 
  bno.getEvent(&event);
      
  Serial.print(event.orientation.x);
  Serial.print("\t");
  Serial.print(event.orientation.y);
  Serial.print("\t");
  Serial.println(event.orientation.z);

  delay(10);

}

The full error message is below

In file included from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/WVariant.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\variants\nano_33_iot/variant.h:25,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\libraries\Wire/Wire.h:24,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_BusIO_Register.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp:1:
C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined
 #define LITTLE_ENDIAN          1
 
In file included from c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,
                 from c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/Print.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/Stream.h:25,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/HardwareI2C.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\libraries\Wire/Wire.h:23,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_BusIO_Register.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp:1:
c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition
 #define LITTLE_ENDIAN _LITTLE_ENDIAN
 
In file included from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/WVariant.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\variants\nano_33_iot/variant.h:25,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\libraries\Wire/Wire.h:24,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:
C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined
 #define LITTLE_ENDIAN          1
 
In file included from c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,
                 from c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/Print.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/Stream.h:25,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\cores\arduino/api/HardwareI2C.h:22,
                 from C:\Users\hugos\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.12\libraries\Wire/Wire.h:23,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:1,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:
c:\users\hugos\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition
 #define LITTLE_ENDIAN _LITTLE_ENDIAN
 
In file included from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_BusIO_Register.h:1:0,
                 from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp:1:
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:36: error: 'TwoWire' has not been declared
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                    ^~~~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:28:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
   TwoWire *_wire;
   ^~~~~~~
   TwoWire_h
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:55: error: could not convert '& Wire' from 'arduino::TwoWire*' to 'int*'
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                                       ^~~~~
In file included from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:0:
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:36: error: 'TwoWire' has not been declared
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                    ^~~~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:28:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
   TwoWire *_wire;
   ^~~~~~~
   TwoWire_h
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:55: error: could not convert '& Wire' from 'arduino::TwoWire*' to 'int*'
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                                       ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:11:1: error: prototype for 'Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t, arduino::TwoWire*)' does not match any in class 'Adafruit_I2CDevice'
 Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire) {
 ^~~~~~~~~~~~~~~~~~
In file included from C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:1:0:
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:7:7: error: candidates are: constexpr Adafruit_I2CDevice::Adafruit_I2CDevice(Adafruit_I2CDevice&&)
 class Adafruit_I2CDevice {
       ^~~~~~~~~~~~~~~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:7:7: error:                 constexpr Adafruit_I2CDevice::Adafruit_I2CDevice(const Adafruit_I2CDevice&)
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:9:3: error:                 Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t, int*)
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
   ^~~~~~~~~~~~~~~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::begin(bool)':
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:30:3: error: '_wire' was not declared in this scope
   _wire->begin();
   ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:30:3: note: suggested alternative: 'Wire'
   _wire->begin();
   ^~~~~
   Wire
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::detected()':
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:51:3: error: '_wire' was not declared in this scope
   _wire->beginTransmission(_addr);
   ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:51:3: note: suggested alternative: 'Wire'
   _wire->beginTransmission(_addr);
   ^~~~~
   Wire
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::write(const uint8_t*, size_t, bool, const uint8_t*, size_t)':
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:90:3: error: '_wire' was not declared in this scope
   _wire->beginTransmission(_addr);
   ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:90:3: note: suggested alternative: 'Wire'
   _wire->beginTransmission(_addr);
   ^~~~~
   Wire
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::_read(uint8_t*, size_t, bool)':
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:176:17: error: '_wire' was not declared in this scope
   size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);
                 ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:176:17: note: suggested alternative: 'Wire'
   size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);
                 ^~~~~
                 Wire
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::setSpeed(uint32_t)':
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:246:3: error: '_wire' was not declared in this scope
   _wire->setClock(desiredclk);
   ^~~~~
C:\Users\hugos\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp:246:3: note: suggested alternative: 'Wire'
   _wire->setClock(desiredclk);
   ^~~~~
   Wire
exit status 1
Error compiling for board Arduino NANO 33 IoT.

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).


have you checked if Adadruit's library are compatible with that platform?
have you installed the libraries? (including dependencies like the latest version of Adafruit Bus IO Library for example?)
post the full error message (and edit first post to add code tags)

Hello, I have amended as you have suggested and included Adafruit Bus IO Library and full error message. I hope that makes more sense now.

According to Arduino website Adafruit unified sensor and Adafruit BNO055 libraries are compatible with all Arduino architectures.

Hi
the point is not to add everything at the start or your sketch

#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>

they are not needed. What's needed is for you to download the latest version of all the libraries from GitHub or through the Library manager as well as the latest board package for your Arduino Nano 33 iot

I just gave it a try and it compiled fine.

Thanks for your help, sorted it. Just uninstalled everything and started again

You probably had something outdated

Glad it’s now OK