Pages: [1]   Go Down
Author Topic: LSM303 problem  (Read 1634 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using the LSM303DLH board from pololu, I am working on an arduino uno and I have connected the sensor in the following way:
                   Uno      LSM303DLH
                    5V  ->  VIN
                   GND  ->  GND
          Analog Pin 5  ->  SCL
          Analog Pin 4  ->  SDA

The library https://github.com/ryantm/LSM303DLH doesn’t work for me, I can’t interface the sensor by using the Wire library because my arduino freezes at Wire.beginTrasmission().
Any idea?
Does this breakout board work at 5V or at 3.3V?
Thanks.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The I2C bus requires pull-up resistors on both lines.  If the breakout board doesn't have them you have to provide them.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the board has the pullup resistors.

Is it hanging  when you call the enable function?

I supply 3.3V to it haven't tried the 5V

« Last Edit: July 29, 2011, 02:31:09 pm by btsp » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The library https://github.com/ryantm/LSM303DLH doesn’t work for me, I can’t interface the sensor by using the Wire library because my arduino freezes at Wire.beginTrasmission().

If your code isn't working you might get better advice if you posted your code.

They say the Vin line will take 2.6V to 5.5v and there are two regulators to provide 3.0V VDD and 1.8V VIO.  The chip requires 2.5V to 3.3V for VDD and is run off the 3.0V regulator.  I guess if you give it 2.6V for Vin you can get 2.5V out of the regulator.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

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

the board has the pullup resistors.

Is it hanging  when you call the enable function?

I supply 3.3V to it haven't tried the 5V


Yes, my arduino is hanging when I call the enable function. It freezes at Wire.beginTrasmission.
My code comes from the example:
#include <Wire.h>
#include <LSM303DLH.h>

LSM303DLH compass;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  compass.enable();
}

void loop() {
  compass.read();

  Serial.print("A ");
  Serial.print("X: ");
  Serial.print(compass.a.x);
  Serial.print(" Y: ");
  Serial.print(compass.a.y);
  Serial.print(" Z: ");
  Serial.print(compass.a.z);

  Serial.print(" M "); 
  Serial.print("X: ");
  Serial.print(compass.m.x);
  Serial.print(" Y: ");
  Serial.print(compass.m.y);
  Serial.print(" Z: ");
  Serial.println(compass.m.z);
 
  delay(100);
}



void LSM303DLH::enable(void)
{
   //Enable Accelerometer
   Wire.beginTransmission(ACC_ADDRESS);
   Wire.send(CTRL_REG1_A);
   //0x27 = 0b00100111
   // Normal power mode, all axes enabled
   Wire.send(0x27);
   Wire.endTransmission();
 
   //Enable Magnetometer
   Wire.beginTransmission(MAG_ADDRESS);
   Wire.send(MR_REG_M);
   //0x00 = 0b00000000
   // Continuous conversion mode
   Wire.send(0x00);
   Wire.endTransmission();
}



Can I try to supply 3.3V?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am assuming the
void LSM303DLH::enable(void)
function is in the LIB. and you are not putting it in the code?

but try supply the 3.3 volts to it and let me know how that goes.
Logged

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

Yes, the void LSM303DLH::enable(void) function is only in the library
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you tried using 3.3v?

Logged

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

you tried using 3.3v?


Yes, I have connected VIN to 3.3v but my code doesn't work.
Any idea?
Thanks.
Logged

Pages: [1]   Go Up
Jump to: