Asked — Edited
Resolved Resolved by Jeremie!

Hmc5883

Hi,

Has anyone successfully connected and used a HMC5883L compass on I2C port without systematically crashing at init ?

I'm kind of stuck and wish to know if I should go on trying again or give up.

Did read former threads about same topics Did find datasheet and Hex address of chip DId use I2Cwrite and Read commands Did use tutorial's script did use everything I can think of. Wires are connected sda to sda scl to scl and then 3.3V.

Let me know if any of you guys have a robot capable to know where it's heading thanks to a compass.

Is there not a more simple compass hardware like with an analog output readable on ADC ? Just asking in case it makes any sense.

Thanks in advance.


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

PRO
Canada
#9  

I'm not sure about your compass readings, I'd have to look further into it.

All the accelerometer, gyro, and compass readings are all available via I2C. Please check out this tutorial for more info. The Variable Watcher in ARC is likely what you'll want to use.

#10  

@Jeremie (or @elfege)

Have you had any luck looking at the compass question? I just got a 4in1 from Brookstone, and am seeing the same thing, the $CompassHeading variable seems to be fairly meaningless. It changes when the robot changes direction, but in no way that makes any sense. Is there a preferred orientation to mount the device? I have tried almost every position/orientation and it doesn't seem to make a difference.

The other compass variables also appear to jump randomly around when the device is sitting still. Gyro and Accel are relatively stable, but since they return to their starting positions when movement stops, they are not going to meet the need I have (I want to adapt Rich's "Ping roam" script so that rather than doing timed moves left and right, I can get the current heading, set a new heading 45 or 90 degrees left or right, and then move until current heading = new heading).

Thanks,

Alan

PRO
Canada
#11  

Sorry, I got distracted with other priorities but yes I will definitely look into this.

#12  

The pull ups resistors did the trick. Thanks a lot Jeremie!

#13  

Pull up Resistors? I have the same 4in1 I got from a local Brookstone, and have the same issues with the compass. I am wanting to make the compass read north, and then the robot be able travel based on the north starting position.

#14  

@Robohappy, the pull up resisters were for making a different board with the same chip work. Jeremie is going to look into the compass problem. I should hav started a seperate thread for it.

Alan

#15  

Hi Alan, I bought a compass a while ago and haven't used it yet. I assume you want to build a tracker that tracks on a compass heading until it pings a distance, then does another compass reading then tracks that heading. Am I correct.

I want to use a script like I just mentioned in my adventure bot to prove out, then into my R2D2.

Is this your idea ?

Ron R

#16  

Ron, basically. I am not worried about actual direction (ie, compass does not need to be accurate, but doea need to be precise). I want, when I reach an obstacle, to turn a certain number of degrees to the the left, if still blocked turn double that number of degrees right, and so on until not blocked.

The ping roam script dies this but it uses timers to decide how long to turn. Since different surfaces can determine the turn rate, I want to ise relative compass heading instead.

Accurate compass headings would be a bonus for navigation scripts too.

Alan