Giga R1 WiFi + 9 Axis Motion Shield

I am trying to connect a 9 Axis Motion Shield to a Giga R1 WiFi board but cannot seem to get them to communicate with each other.

I suspect that the library is the culprit as the error code is:
"'IMU' was not declared in this scope"

I am using the #include <Arduino_NineAxesMotion.h> library that is recommended for this Shield and it also says that it's compatible with all Arduino architectures according to the library author. However, the product side says it's only comaitble with Uno R3 and UNO Wifi Rev2 Boards, but I tried with my UNO R3 board with no success.

Is there a different library to use that works, or should I opt for a different Motion shield or a different Board, other than Giga R1 or UNO R3?

Took a quick look at the shield and library you are using. Looks like its set up for using Wire as opposed to Wire1. You are going to have to modify the library to use Wire1 instead of Wire. There is no way programmatically to change change.

1 Like

The library author has include this

#if defined(ARDUINO_SAM_DUE)
#define I2C				Wire1	//Define which I2C bus is used. Wire1 for the Arduino Due
#else
#define I2C             Wire    //Or Wire
#endif

for the DUE. I'd raise it as an issue on git and suggest a better approach would be a begin() that accepted an override

I suspect the IMU error is in your code though as I can see no reference to it in the library

1 Like

Thanks @steve9 and @Merlin513 for your answers.

Being a newbie to coding and Arduino, it seem this fast ran up and away from my competence level (posing as a fourth grader by way of CHAT GPT...:wink:).

Having tried several fault-source finding solutions (proposed by Chat GPT) I landed in that the Library might be the culprit. Changing / fixing the library is way out of my league...:upside_down_face:

in my code I start with including the library:

#include <Arduino_NineAxesMotion.h>

And then, in the void setup () initializing the gyro:

 // Initialize Gyro (Motion Shield)
  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }
  Serial.println("IMU initialized.");

This gives the error message "'IMU' was not declared in this scope".

Also, this newbie has never been on Github...

My "Plug & Play" project is turning into a "Plug & Pray" project...

I found a possible solution in another thread:
https://forum.arduino.cc/t/9-axis-motion-shield-not-recognized-on-i2c/661986/8?u=henrikbage

Where it seems to be a problem with the reset function on the Shield and Pin 7.

pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);

Tried including it in the void setup () before initializing the IMU with no success. Result is still the same.

You will need

NineAxesMotion IMU;

after the include and before the void setup()

Take a look at the examples included with the library, start will BareMinimum.ino to see the basic structure and then maybe Motion.ino. You can find them in the IDE under [File]/[Examples]

1 Like

Thanks @steve9, you're the man!!!
I uploaded the Motion.ino to my UNO R3 and got the Motion Shield to work!

So, there is nothing wrong with the hardware or the library (I guess), just some missing code (I got from "Chad", ChatGPT).

Now I just have to include the relevant code into my code...

You just got me a heck of a lot further now than where I was 1 hr ago!
:pray::pray::pray:

Got an update for the Library and it seems like there is a compatibility issue with the Library/9 Axis Motion Shield and the Giga R1 Wifi.

Also, Pin 7 is used by the Shield for communication, so don't use that one for anything else!

I wrote a code for getting values from the Accelerometer and Gyro. Works fine on the UNO R3 but not possible to upload to the Giga:

Warning: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release
No DFU capable USB device available

and

Failed uploading: uploading error: exit status 74

Status 74 is just saying there is no DFU device available.

try pressing the reset button twice in quick succession to put the giga into bootloader mode. the green led should then be blinking fast. then select the new port in the IDE that will have just appeared and try uploading again

Fantastic! Thanks again @steve9!
Got to upload it with only a smaller error code on the dfu, but got the program running.

Now I just got to the correct readings out from gyro and accelerometer as they are 0,00, even if I tilt it. Guess it's a pin-conflict somewhere. I had a pin7 conflict running the same code with the UNO board, and now I get the same readings as before resolving that conflict. Guess I will have to trial and error my way around it... Maybe run a simpler code to do my bugfinding...

Wishing you a Happy New Year!