Go Down

Topic: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! (Read 8854 times) previous topic - next topic



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.



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.


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


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.


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


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.


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?


Got it working:

Code: [Select]

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.


That message about being invalid,  always seems to occur.


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.


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 ?



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: [Select]
#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;

void setup()
  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("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.

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("   ");   
   Serial.print("   ");   
   Serial.print("   \tScaled:\t");
   Serial.print("   ");   
   Serial.print("   ");   

   Serial.print("   \tHeading:\t");
   Serial.print(" Radians   \t");
   Serial.println(" Degrees   \t");

Go Up