I have loaded the AHRS Adafruit library into my arduino. I am following your AHRS tutorial for the LSM6DS33 and LIS3MDL. However, once I get to the step of the Adafruit AHR Calibration, I get the following error:
Loaded existing calibration
Failed to find sensors
I am using the Mega2560 board with the I2C connections. Please help. Thank you.
Take a step back.
Are your modules with the sensors compatible with a 5V Arduino board ?
Can you run a I2C Scanner sketch to check if the I2C bus is working ?
Can you give a link to that tutorial ?
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project See About the Installation & Troubleshooting category.
In response to the questions from Koepel. I am using the Arduino Mega2560 board, with the LSM6DS33 + LIS3MDL chip. It is connected to the Vin-Vin, GND-GND, SCL-SCL (21), SDA-SDA(20).
From everything I see, it is the correct type of board and sensors per the tutorial. Thank you.
C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino:1:1: error: expected unqualified-id before '/' token
/ ---------------------------------------------------------------- /
^
In file included from C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino:11:0:
C:\Users\T\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:86:8: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
extern TwoWire Wire;
^~~~~~~
TwoWire_h
C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino: In function 'void setup()':
C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino:15:3: error: 'Wire' was not declared in this scope
Wire.begin(); // Wire communication begin
^~~~
C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino: In function 'void loop()':
C:\Users\T\AppData\Local\Temp.arduinoIDE-unsaved202282-1436-dt3rkl.194er\sketch_sep2a\sketch_sep2a.ino:34:5: error: 'Wire' was not declared in this scope
Wire.beginTransmission(address);
^~~~
exit status 1
Compilation error: expected unqualified-id before '/' token
Whoever published that is an idiot. Take everything out before the #include <Wire.h> //include Wire.h library. The problem is the two lines that start with a single forward slash; that should have been two.
Adafruit makes their sensor modules compatible for 3.3V Arduino boards and for 5V Arduino boards. Can you give links to you sensor modules ?
You need a I2C Scanner to be sure that the I2C bus is working.
I'm sorry that you found the only I2C Scanner sketch that does not work
I turned it into a working one:
#include <Wire.h>
void setup()
{
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
Serial.println("\nI2C Scanner");
Wire.begin(); // Wire communication begin
}
void loop()
{
byte error, address; //variable for error and I2C address
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(3000);
}
Now we can continue with your question about the AHRS software using the tutorial.
Is that tutorial for your sensor board ?
Which steps did you take and where is the step for the AHRS Calibration ? (which sketch, using software on your computer or just the Arduino board).
That tutorial does not specify exactly which sensors. From everything I see, it fits that tutorial. I also have the Clue board and would use that if necessary.
I made it successfully through the tutorial to the Calibration Write Check step, where I got the error for failed to find sensors.
That is not easy.
It seems that the calibration sketch is already set to your sensor board. If you have not changed the address of the sensors, then it should work, I think.
I assume that you have installed the "Adafruit AHRS" library with all the libraries that it needs ?
Then you could try an example from the LSM6DS33 library and a example from the LIS3MDL. For example this one and this one. They are in the menu of the Arduino IDE.
Are you sure that you have not changed something to the library and that you have the latest versions of all the libraries ?
Adafruit has extra layers of libraries, so they don't have to write the same code over and over again. But now they have layers of code on top of layers of code, and it is hard to see what is going on.
Loaded existing calibration
Failed to find sensors
The sensor calibration program and AHRS program are completely independent, but they communicate via calibration data stored in EEPROM.
It looks to me like you have not correctly set up the AHRS program for the sensors you are actually using.
I gave up on Adafruit device libraries long ago, because they have become so bloated and try to hide every detail from the user.
The accelerometer and magnetometer sensors can be individually calibrated using a more hands-on approach, which is what Adafruit is trying to hide from you, by following the basic outlines in this forum post. If you work your way through that, in the end you should understand what is actually happening.