Pages: [1]   Go Down
Author Topic: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module!  (Read 3450 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I've recently purchased this device:

 
And would like to ask help to connect it to Arduino.
Would be nice if somebody could guide me in the right direction.

Thanks.

Logged

Dubuque, Iowa, USA
Offline Offline
Edison Member
*
Karma: 44
Posts: 2460
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a typical I2C wiring; here's a similar example. You will still need to chase down the software libraries to interface with each of your specific sensors.

Some tutorials will show a level shifter, but you do not need a level shifter with this board as it already has one.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for link.
Looks like it explains it better than any I found.


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's photo of my Arduino and Sensors.


So hopefully I didn't mess with power!?

According to this now I have to choose to connect other things to analog or digital pins.
Still need to figure out what are they.
I would appreciate any help.
Logged

Dubuque, Iowa, USA
Offline Offline
Edison Member
*
Karma: 44
Posts: 2460
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yours follows the "classic" (as Adafruit describes it) wiring. SDA to analog pin 4 and SCL to analog pin 5.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

That's only for Gyro?
Logged

Dubuque, Iowa, USA
Offline Offline
Edison Member
*
Karma: 44
Posts: 2460
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's for all three chips; no more wiring needed. I2C devices have a built-in address that your code (or more specifically the library to interface with the chips) will report when it's communicating with a specific chip.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right about to test magnetometer  with this tutorial - https://www.loveelectronics.co.uk/Tutorials/8/hmc5883l-tutorial-and-arduino-library

Do I need any resistors between SDA and VCC, and SCL and VCC?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it working:

Code:
Setting scale to +/- 1.3 Ga
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Setting measurement mode to continuous.
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Raw: -93   -68   482   Scaled: -85.56   -62.56   443.44   Heading: 3.77 Radians   216.17 Degrees  
Raw: -93   -69   477   Scaled: -85.56   -63.48   438.84   Heading: 3.78 Radians   216.57 Degrees  
Raw: -94   -68   483   Scaled: -86.48   -62.56   444.36   Heading: 3.77 Radians   215.88 Degrees  

Chagrin thank you very much for help. That's a good start for me.
Understood all logic, so should be able to get data from all sensors and use it in my app.

P.S. hopefully I didn't need any resistors, as I was running it without them.
Logged

Offline Offline
Faraday Member
**
Karma: 58
Posts: 2778
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That message about being invalid,  always seems to occur.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think that might happen due to connection/disconnection of sensor.
I was holding everything in hands - so few times sensor disconnected and shown following error few times through log.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, i bought that same module
can you put your code on the forum?
i dont understand how to adress the chip from the links given on this page
do you have any datasheet ?
thx
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Sorry for delay, didn't see message updates.

Following code works with compass:
(it was copied from somewhere on internet,
don't remember the author)

Code:
#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Serial started.");
 
  compass = HMC5883L();
 
  Serial.println("Setting scale to +/- 1.3 Ga");
  int error = compass.SetScale(1.3); // Set the scale of the compass.
  if(error != 0) // If there is an error, print it out.
    Serial.println(compass.GetErrorText(error));

  Serial.println("Setting measurement mode to continuous.");
  error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
  if(error != 0) // If there is an error, print it out.
    Serial.println(compass.GetErrorText(error));
}

void loop()
{
   // Retrive the raw values from the compass (not scaled).
  MagnetometerRaw raw = compass.ReadRawAxis();
  // Retrived the scaled values from the compass (scaled to the configured scale).
  MagnetometerScaled scaled = compass.ReadScaledAxis();
 
  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  float heading = atan2(raw.YAxis, raw.XAxis);
   
  // Correct for when signs are reversed.
  if(heading < 0)
    heading += 2*PI;
   
  // Convert radians to degrees for readability.
  float headingDegrees = heading * 180/M_PI;

  // Output the data via the serial port.
  Output(raw, scaled, heading, headingDegrees);
}

void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees)
{
   Serial.print("Raw:\t");
   Serial.print(raw.XAxis);
   Serial.print("   ");   
   Serial.print(raw.YAxis);
   Serial.print("   ");   
   Serial.print(raw.ZAxis);
   Serial.print("   \tScaled:\t");
   
   Serial.print(scaled.XAxis);
   Serial.print("   ");   
   Serial.print(scaled.YAxis);
   Serial.print("   ");   
   Serial.print(scaled.ZAxis);

   Serial.print("   \tHeading:\t");
   Serial.print(heading);
   Serial.print(" Radians   \t");
   Serial.print(headingDegrees);
   Serial.println(" Degrees   \t");
}
Logged

Pages: [1]   Go Up
Jump to: