Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: March 01, 2013, 02:06:07 pm
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");
}
2  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 20, 2013, 10:27:07 am
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.
3  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 19, 2013, 10:49:14 pm
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.
4  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 19, 2013, 08:38:56 pm
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?
5  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 19, 2013, 09:41:09 am
Thanks,

That's only for Gyro?
6  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 18, 2013, 07:44:48 pm
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.
7  Using Arduino / Sensors / Re: Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 18, 2013, 04:48:23 pm
Thanks for link.
Looks like it explains it better than any I found.


8  Using Arduino / Sensors / Need help with connecting 9DOF (ITG3205 ADXL345 HMC5883L) module! on: January 18, 2013, 10:37:39 am
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.

Pages: [1]